The cl-patterns Reference Manual

This is the cl-patterns Reference Manual, version 0.7, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 04:21:15 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-patterns

Pattern library for algorithmic music composition and performance in Common Lisp

Author

modula t.

Contact

Home Page

https://w.struct.ws/cl-patterns/

Source Control

(GIT git@github.com:defaultxr/cl-patterns.git)

Bug Tracker

https://github.com/defaultxr/cl-patterns/issues

License

MIT

Version

0.7

Dependencies
  • alexandria (system).
  • mutility (system).
  • mutility/loopy (system).
  • bordeaux-threads (system).
  • closer-mop (system).
  • named-readtables (system).
  • local-time (system).
  • dissect (system).
Source

cl-patterns.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 cl-patterns/patterns

Dependency

event.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 cl-patterns/cl-patterns.asd

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

ASDF Systems

cl-patterns.


4.1.2 cl-patterns/package.lisp

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Packages

cl-patterns.


4.1.3 cl-patterns/utility.lisp

Dependency

package.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.4 cl-patterns/conversions.lisp

Dependency

utility.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.5 cl-patterns/scales.lisp

Dependency

conversions.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.6 cl-patterns/event.lisp

Dependency

scales.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.7 cl-patterns/patterns/patterns.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface
Internals

4.1.8 cl-patterns/patterns/pdef.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface
Internals

4.1.9 cl-patterns/patterns/pmeta.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface
Internals

4.1.10 cl-patterns/patterns/bjorklund.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface

4.1.11 cl-patterns/patterns/cycles.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface
Internals

4.1.12 cl-patterns/patterns/track.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).

Public Interface
Internals

4.1.13 cl-patterns/patterns/export.lisp

Source

cl-patterns.asd.

Parent Component

patterns (module).


4.1.14 cl-patterns/eseq.lisp

Dependency

patterns (module).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.15 cl-patterns/backend.lisp

Dependency

eseq.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.16 cl-patterns/render.lisp

Dependency

backend.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

find-backend-supporting-render (function).


4.1.17 cl-patterns/clock.lisp

Dependency

render.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface
Internals

4.1.18 cl-patterns/extensions/sequence.lisp

Dependency

clock.lisp (file).

Source

cl-patterns.asd.

Parent Component

cl-patterns (system).

Public Interface

5 Packages

Packages are listed by definition order.


5.1 cl-patterns

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
  • mutility.
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Special variables

Special Variable: *c4-midinote*

The MIDI note number of note C, octave 4. This sets the global tuning of the various pitch conversion functions.

Package

cl-patterns.

Source

conversions.lisp.

Special Variable: *cl-patterns-temporary-directory*

The default directory to store ‘render’ed files in.

Package

cl-patterns.

Source

render.lisp.

Special Variable: *clock*

The default clock to run tasks on.

Package

cl-patterns.

Source

utility.lisp.

Special Variable: *default-pattern-length*

The default value of a pattern’s LENGTH parameter.

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: *default-pattern-repeats*

The default value of a pattern’s REPEATS parameter.

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: *display-server*

The display server type that ‘mouse-location’ should default to. Attempts to auto-detect the correct display server on load.

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: *event*

The event special variable. Can be referenced inside a pattern’s code.

Package

cl-patterns.

Source

utility.lisp.

Special Variable: *max-pattern-yield-length*

The default maximum number of events or values that will be used by functions like ‘next-n’ or patterns like ‘protate’, in order to prevent hangs caused by infinite-length patterns.

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: *note-names*

List of note names in the equal temperament 12-tone tuning.

Package

cl-patterns.

Source

conversions.lisp.

Special Variable: *post-pattern-output-processors*

List of functions that are applied as the last step of pattern output generation. Each output yielded by an "outermost" pattern (i.e. one without a ‘pattern-parent’) will be processed (along with the pstream as a second argument) through each function in this list, allowing for arbitrary transformations of the generated outputs. The return value of each function is used as the input to the next function, and the return value of the last function is used as the output yielded by the pattern.

This can be used, for example, to implement mappings from friendly instrument names to the full parameters needed to specify the instrument in question for backends such as MIDI which require it; in fact this feature is already implemented more conveniently with the setf-able ‘instrument-mapping’ function.

See also: ‘*instrument-map*’, ‘remap-instrument-to-parameters’

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: *screen-size*

The combined size of all monitors plugged into the machine that cl-patterns is running on. If you add or remove displays after loading cl-patterns, you may have to update this variable. To set the correct value, run (setf *screen-size* (screen-size)).

See also: ‘*display-server*’, ‘screen-size’, ‘mouse-location’, ‘pmouse’

Package

cl-patterns.

Source

patterns.lisp.

Special Variable: eop

End Of Pattern; the symbol yielded by patterns after their last output.

Package

cl-patterns.

Source

utility.lisp.


6.1.2 Macros

Macro: cycles (spec map &rest list)

Convenience macro to specify a rhythm or melody using symbols. Outputs a list of events with :type, :dur, and another parameter which is specifiable. Usually used to :embed into a pattern.

SPEC is a symbol representing the type of output you’re going to send. It can be midinote, freq, note, instrument, or buffer/bufnum. It can also be a list, which provides the spec as the first element, and keywords (such as :dur for the total dur) for the rest.

MAP is a plist specifying the mapping from symbols to SPEC’s parameter. It can be blank if you’re just making a melody. By default, the map includes keys that map - and _ to rests.

LIST is the actual pattern to generate.

Package

cl-patterns.

Source

cycles.lisp.

Macro: defpattern (name superclasses slots &key documentation defun)

Define a pattern. This macro automatically generates the pattern’s class, its pstream class, and the function to create an instance of the pattern, and makes them external in the cl-patterns package.

NAME is the name of the pattern. Typically a word or two that describes its function, prefixed with p.

SUPERCLASSES is a list of superclasses of the pattern. Most patterns just subclass the ’pattern’ class.

SLOTS is a list of slots that the pattern and pstreams derived from it have. Each slot can either be just a symbol, or a slot definition a la ‘defclass’. You can provide a default for the slot with the :initform key as usual, and you can set a slot as a state slot (which only appears in the pattern’s pstream class) by setting the :state key to t.

DOCUMENTATION is a docstring describing the pattern. We recommend providing at least one example, and a "See also" section to refer to similar pattern classes.

DEFUN can either be a full defun form for the pattern, or an expression which will be inserted into the pattern creation function prior to initialization of the instance. Typically you’d use this for inserting ‘assert’ statements, for example.

See also: ‘pattern’, ‘pdef’, ‘all-patterns’

Package

cl-patterns.

Source

patterns.lisp.

Macro: pb (name &body pairs)

pb is a convenience macro, wrapping the functionality of ‘pbind’ and ‘pdef’ while also providing additional syntax sugar. NAME is the name of the pattern (same as pbind’s :pdef key or ‘pdef’ itself), and PAIRS is the same as in regular pbind. If PAIRS is only one element, pb operates like ‘pdef’, otherwise it operates like ‘pbind’.

The expressions in PAIRS are also automatically translated to equivalent patterns if applicable; for example:

;; (pb :foo :bar (+ (pseries) (pseq (list -1 0 1))))

...is the same as:

;; (pb :foo :bar (p+ (pseries) (pseq (list -1 0 1))))

See also: ‘pbind’, ‘pdef’

Package

cl-patterns.

Source

patterns.lisp.

Macro: pf (&body body)

Convenience macro for ‘pfunc’ that automatically wraps BODY in a lambda.

Package

cl-patterns.

Source

patterns.lisp.

Macro: ppc (&body pairs)

Syntax sugar for ‘pparchain’ that automatically splits PAIRS by :- symbols.

Example:

;; (ppc :foo (pseq (list 1 2 3) 1)
;; :-
;; :bar (p+ (pk :foo) 2))
;; ;=> (((EVENT :FOO 1) (EVENT :FOO 1 :BAR 3))
;; ((EVENT :FOO 2) (EVENT :FOO 2 :BAR 4))
;; ((EVENT :FOO 3) (EVENT :FOO 3 :BAR 5)))

See also: ‘pparchain’

Package

cl-patterns.

Source

patterns.lisp.

Macro: pt (header &rest rows)

Syntax sugar for ‘ptrack’. Avoids the need to quote or use ‘list’.

Example:

;; (pt (:foo 1 :bar (pseries) :dur 1/4)
;; (2) ; (:foo 2 :bar 0 :dur 1/4)
;; () ; (:foo 1 :bar 1 :dur 1/4)
;; (9 :bar 90) ; (:foo 9 :bar 90 :dur 1/2)
;; (-) ; extends the previous note by 1/4 beat
;; :r ; (:foo 1 :bar 4 :dur 1/4 :type :rest)
;; )

See also: ‘ptrack’

Package

cl-patterns.

Source

track.lisp.


6.1.3 Compiler macros

Compiler Macro: events-lists-differing-keys (&rest args)
Package

cl-patterns.

Source

event.lisp.


6.1.4 Ordinary functions

Function: all-backend-types ()

Get a list of names of all defined backend types. A backend type is any class that inherits from ‘backend’.

See also: ‘all-backends’, ‘enabled-backends’

Package

cl-patterns.

Source

backend.lisp.

Function: all-backends (&key enabled-p started-p)

Get a list of all backends made with ‘make-backend’ or ‘backend-start’. ENABLED-P and STARTED-P can be used to limit the results only to backends with matching status.

See also: ‘all-backend-types’, ‘enabled-backends’

Package

cl-patterns.

Source

backend.lisp.

Function: all-chords ()

Get a list of all defined chords.

Package

cl-patterns.

Source

scales.lisp.

Function: all-instruments (&optional backend)

Get a list of the names of all instruments defined for BACKEND, or all enabled backends if none specified.

See also: ‘playing-nodes’, ‘all-patterns’, ‘all-pdefs’, ‘enabled-backends’

Package

cl-patterns.

Source

utility.lisp.

Function: all-patterns ()

Get a list of the names of all defined pattern classes.

See also: ‘all-pdefs’

Package

cl-patterns.

Source

patterns.lisp.

Function: all-pdef-names (&key include-aliases package dictionary)

Get a list of the names of all defined pdef objects.

See also: ‘all-pdefs’, ‘pdef-names’

Package

cl-patterns.

Source

pdef.lisp.

Function: all-pdefs (&key package dictionary)

Get a list of all defined pdef objects in DICTIONARY. With PACKAGE, get only pdefs whose name is a symbol in that package.

See also: ‘all-pdef-names’, ‘pdef-names’, ‘find-pdef’

Package

cl-patterns.

Source

pdef.lisp.

Function: all-scales ()

Get a list of all defined scales.

Package

cl-patterns.

Source

scales.lisp.

Function: all-tunings ()

Get a list of all defined tunings.

Package

cl-patterns.

Source

scales.lisp.

Function: amp-db (amp)

Convert amplitude to decibels.

Package

cl-patterns.

Source

conversions.lisp.

Function: backend-p (object)

Test whether OBJECT is a ‘backend’.

See also: ‘find-backend’, ‘all-backends’

Package

cl-patterns.

Source

backend.lisp.

Function: bipolar-1-to-midi (number)

Convert the range -1..1 to 0..127.

Package

cl-patterns.

Source

conversions.lisp.

Function: bipolar-unipolar (number)

Convert a bipolar number (-1 to 1) to a unipolar number (0 to 1).

See also: ‘unipolar-bipolar’

Package

cl-patterns.

Source

conversions.lisp.

Function: bjorklund (pulses &optional steps offset)

Generate a list representing a Euclidean rhythm using the Bjorklund algorithm. PULSES is the number of "hits" in the sequence, STEPS is number of divisions of the sequence, and OFFSET is the number to rotate the sequence by. This function returns a list, where 1 represents a note and 0 represents a rest. If you want to use bjorklund in a pattern, you may be more interested in ‘pbjorklund’ instead, which returns events with the correct duration and type.

Example: (bjorklund 3 7) ;=> (1 0 1 0 1 0 0)

See also: ‘pbjorklund’

Package

cl-patterns.

Source

bjorklund.lisp.

Function: chord-midinotes (chord &optional root octave)

Get a list of the midi note numbers in the specified chord.

Package

cl-patterns.

Source

scales.lisp.

Function: chord-notes (chord)

Return a list consisting of the note numbers for CHORD.

Package

cl-patterns.

Source

scales.lisp.

Function: chromatic-index-degree (chromatic-index &rest args &key root scale)

Get the degree of CHROMATIC-INDEX.

Package

cl-patterns.

Source

conversions.lisp.

Function: chromatic-index-freq (chromatic-index &optional octave)

Get the frequency of CHROMATIC-INDEX.

Package

cl-patterns.

Source

conversions.lisp.

Function: chromatic-index-midinote (chromatic-index &optional octave)

Get the midinote of CHROMATIC-INDEX.

Package

cl-patterns.

Source

conversions.lisp.

Function: chromatic-index-note (chromatic-index)

Get the note of CHROMATIC-INDEX.

Note that this function is not aware of context and thus always returns the first known name of each note, not necessarily the one that is "correct".

Package

cl-patterns.

Source

conversions.lisp.

Function: clock-caught-conditions (&optional clock)

A list of conditions caught by the clock while processing tasks when its condition-handler is non-nil. Each entry in the list is a plist containing the the condition and the stack trace.

See also: ‘clock-condition-handler’

Package

cl-patterns.

Source

clock.lisp.

Function: (setf clock-caught-conditions) (&optional clock)
Package

cl-patterns.

Source

clock.lisp.

Function: clock-condition-handler (&optional clock)

The restart to invoke when a condition occurs during task processing. If nil, the clock will not attempt to handle any conditions. If non-nil, all conditions signaled within a task will be caught and the specified restart will be invoked automatically to prevent the clock from pausing. Caught conditions will be printed as a warning and recorded with their stack trace in the clock’s caught-conditions slot.

See also: ‘clock-caught-conditions’

Package

cl-patterns.

Source

clock.lisp.

Function: (setf clock-condition-handler) (&optional clock)
Package

cl-patterns.

Source

clock.lisp.

Function: clock-latency (&optional clock)

The default latency for events played on the clock; the number of seconds added onto the event’s scheduled time, in order to allow the backend to process it without being "late".

Package

cl-patterns.

Source

clock.lisp.

Function: (setf clock-latency) (&optional clock)
Package

cl-patterns.

Source

clock.lisp.

Function: clock-loop (clock &key granularity)

Convenience method for processing a clock’s tasks in a loop.

To run the clock in a new thread, you can call ‘start-clock-loop’.

See also: ‘start-clock-loop’, ‘clock-process’

Package

cl-patterns.

Source

clock.lisp.

Function: clock-process (clock beats)

Process tasks on CLOCK for the next BEATS beats.

See also: ‘clock-loop’, ‘clock-tasks’, ‘make-clock’

Package

cl-patterns.

Source

clock.lisp.

Function: clock-tasks (&optional clock)

Get a list of all tasks running on CLOCK.

See also: ‘pattern-tasks’

Package

cl-patterns.

Source

clock.lisp.

Function: (setf clock-tasks) (&optional clock)
Package

cl-patterns.

Source

clock.lisp.

Function: combine-events (&rest events)

Get a new event that inserts all the items in each event of EVENTS. Keys from the events listed first will be overwritten by later events.

See also: ‘copy-event’, ‘split-event-by-lists’, ‘combine-events-via-lists’

Package

cl-patterns.

Source

event.lisp.

Function: combine-events-via-lists (&rest events)

Combine EVENTS together to produce one event. Any keys that differ between the events will have be set to lists containing all the values from each event (unless the value is null). This is the opposite of ‘split-event-by-lists’.

Example:

;; (combine-events-via-lists (event :foo 1 :bar 2 :qux 4) (event :foo 1 :bar 3 :baz 5))
;; => (EVENT :FOO 1 :BAR (2 3) :QUX 4 :BAZ 5)

See also: ‘split-event-by-lists’, ‘combine-events’

Package

cl-patterns.

Source

event.lisp.

Function: copy-event (event)

Get a new event that is a copy of EVENT.

See also: ‘combine-events’

Package

cl-patterns.

Source

event.lisp.

Function: db-amp (db)

Convert decibels to amplitude.

Package

cl-patterns.

Source

conversions.lisp.

Function: define-chord (name indexes scale &optional aliases)

Define a musical chord.

See also: ‘scale’, ‘define-tuning’, ‘define-scale’

Package

cl-patterns.

Source

scales.lisp.

Function: define-scale (name notes &optional tuning aliases)

Define a musical scale.

See also: ‘scale’, ‘define-tuning’, ‘define-chord’

Package

cl-patterns.

Source

scales.lisp.

Function: define-tuning (name pitches octave-ratio &optional aliases)

Define a musical tuning.

See also: ‘tuning’, ‘define-scale’, ‘define-chord’

Package

cl-patterns.

Source

scales.lisp.

Function: degree-chromatic-index (degree &rest args &key scale steps-per-octave mtranspose)

Get the chromatic index of DEGREE.

Package

cl-patterns.

Source

conversions.lisp.

Function: degree-freq (degree &rest args &key root octave scale)

Get the frequency of DEGREE, based on the ROOT, OCTAVE, and SCALE, if provided.

Package

cl-patterns.

Source

conversions.lisp.

Function: degree-key (degree &key scale steps-per-octave accidental)

Get the note in SCALE at the index DEGREE, possibly overriding STEPS-PER-OCTAVE.

Package

cl-patterns.

Source

conversions.lisp.

Function: degree-midinote (degree &key root octave scale)

Get the midi note number of DEGREE, taking into account the ROOT, OCTAVE, and SCALE, if provided.

Package

cl-patterns.

Source

conversions.lisp.

Function: degree-note (degree &key scale steps-per-octave mtranspose)

Get the note number of DEGREE in SCALE.

Package

cl-patterns.

Source

conversions.lisp.

Function: degree-octave (degree)

Get the octave of DEGREE.

Package

cl-patterns.

Source

conversions.lisp.

Function: dur-freq (dur &optional tempo)

Convert DUR in beats to frequency in Hz according to TEMPO in beats per second.

Package

cl-patterns.

Source

conversions.lisp.

Function: dur-time (dur &optional tempo)

Convert DUR in beats to time in seconds according to TEMPO in beats per second.

Package

cl-patterns.

Source

conversions.lisp.

Function: e (key)

Syntax sugar; like ‘event-value’, but always gets the value from ‘*event*’.

See also: ‘event-value’, ‘event’, ‘*event*’

Package

cl-patterns.

Source

event.lisp.

Function: (setf e) (key)
Package

cl-patterns.

Source

event.lisp.

Function: enabled-backends ()

Get a list of all enabled backends.

See also: ‘all-backends’, ‘backend-enabled-p’

Package

cl-patterns.

Source

backend.lisp.

Function: eseq (&optional events &key source metadata)

Create an eseq containing the specified events and metadata.

Package

cl-patterns.

Source

eseq.lisp.

Function: eseq-length (eseq)

Get the number of events in ESEQ.

Package

cl-patterns.

Source

eseq.lisp.

Function: eseq-p (object)

True if OBJECT is an eseq.

See also: ‘eseq’

Package

cl-patterns.

Source

eseq.lisp.

Function: event (&rest params)

Create an event, using the PARAMS as its keys/values.

See also: ‘event-value’, ‘event-p’, ‘e’, ‘*event*’

Package

cl-patterns.

Source

event.lisp.

Function: event-equal (event-1 event-2)

Test if EVENT-1 and EVENT-2 are equivalent.

See also: ‘every-event-equal’

Package

cl-patterns.

Source

event.lisp.

Function: event-p (object)

True if OBJECT is an event.

See also: ‘event’, ‘event-value’

Package

cl-patterns.

Source

event.lisp.

Function: event-value (event key)

Get the value of KEY in EVENT, running any necessary conversion functions.

Returns 2 values: the value of the key, and the name of the key the value was derived from (or t if the default value of the key was used, or nil if no value or default was provided).

See also: ‘event’, ‘e’, ‘raw-event-value’

Package

cl-patterns.

Source

event.lisp.

Function: (setf event-value) (event key)

Set the value of KEY to VALUE in EVENT, running any conversion functions that exist.

Package

cl-patterns.

Source

event.lisp.

Function: events-differing-keys (&rest events)

Get a list of keys that differ between EVENTS.

See also: ‘every-event-equal’

Package

cl-patterns.

Source

event.lisp.

Function: events-lists-differing-keys (&rest lists)

Get a list of the keys that differ between respective event in LISTS.

Example:

;; (events-lists-differing-keys (list (event :foo 1 :bar 2) (event :bar 3) (event :foo 1 :bar 3)) ;; (list (event :foo 1 :bar 2) (event :foo 1 :bar 3) (event :foo 2 :bar 3))) ;; => (NIL (:FOO) (:FOO))

See also: ‘every-event-equal’

Package

cl-patterns.

Source

event.lisp.

Function: every-event-equal (&rest lists)

Test if all the events in LISTS are equivalent. Like (every #’event-equal LIST-1 LIST-2 ...) but returns false if the lists are not the same length.

See also: ‘event-equal’, ‘events-differing-keys’

Package

cl-patterns.

Source

event.lisp.

Function: find-backend (backend &key enabled-p)

Find a registered backend whose name or type matches BACKEND. With ENABLED-P, only search through currently enabled backends.

See also: ‘all-backends’, ‘enabled-backends’

Package

cl-patterns.

Source

backend.lisp.

Function: find-pdef (name &key errorp dictionary)

Get the object named NAME in the pdef dictionary. If ERRORP is true, signals an error when NAME isn’t found in the dictionary. Returns t or nil as a second value showing whether the symbol was found.

See also: ‘pdef-p’, ‘all-pdefs’, ‘all-pdef-names’

Package

cl-patterns.

Source

pdef.lisp.

Function: (setf find-pdef) (name &key errorp dictionary)
Package

cl-patterns.

Source

pdef.lisp.

Function: freq-chromatic-index (freq)

Get the chromatic index of FREQ.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-degree (freq &key root octave scale)

Convert a frequency to a scale degree.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-dur (freq &optional tempo)

Convert FREQ in Hz to duration in beats according to TEMPO in beats per second.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-midinote (freq)

Convert a frequency to a midi note number.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-note (freq)

Get the note for the frequency provided.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-octave (freq)

Get the octave number that the frequency FREQ occurs in.

Package

cl-patterns.

Source

conversions.lisp.

Function: freq-rate (freq &optional base-freq)

Convert the frequency FREQ to a playback rate, based on BASE-FREQ. Useful to convert musical pitch information to a number usable for sample playback synths.

Package

cl-patterns.

Source

conversions.lisp.

Function: frequency-to-midi (frequency)

Convert FREQUENCY to a MIDI note number (rounding to ensure it’s an integer).

Note that this function is meant for use with the MIDI backend; for frequency-to-midinote conversion without rounding, see ‘freq-midinote’ instead.

Package

cl-patterns.

Source

conversions.lisp.

Function: instrument-mapping (instrument)

Get a mapping from INSTRUMENT (an instrument name as a string or symbol) to a plist of parameters which should be set in the event by ‘remap-instrument-to-parameters’.

See also: ‘remap-instrument-to-parameters’, ‘*instrument-map*’

Package

cl-patterns.

Source

patterns.lisp.

Function: (setf instrument-mapping) (instrument)

Set a mapping from INSTRUMENT (an instrument name as a string or symbol) to a plist of parameters which will be set in the event by ‘remap-instrument-to-parameters’. Setting an instrument to nil with this function removes it from the map.

See also: ‘instrument-mapping’, ‘remap-instrument-to-parameters’, ‘*instrument-map*’

Package

cl-patterns.

Source

patterns.lisp.

Function: ipstream (&optional patterns end-when-empty granularity)

Insertable pstream; a pstream that can be changed while it’s running by inserting new patterns at a specified beat.

Package

cl-patterns.

Source

patterns.lisp.

Function: load-scala-scale (file &optional aliases)

Load a Scala (.scl) scale file and define a tuning and scale from it.

Note that Scala refers to these as "scales" but in cl-patterns they are known as tunings.

Package

cl-patterns.

Source

scales.lisp.

Function: make-clock (&optional tempo &key latency play-expired-events condition-handler)

Create a clock with a tempo of TEMPO in beats per second (Hz).

To start the clock so that it begins processing its tasks in a new thread, you can use ‘start-clock-loop’. Alternatively, you can call ‘clock-loop’ yourself to start the loop in the current thread. The clock can also be advanced manually an arbitrary number of beats at a time with the ‘clock-process’ function.

See also: ‘clock-process’, ‘clock-loop’, ‘start-clock-loop’

Package

cl-patterns.

Source

clock.lisp.

Function: midi-ratio (midi)

Convert a MIDI note number difference to a frequency ratio.

Package

cl-patterns.

Source

conversions.lisp.

Function: midi-truncate-clamp (number &optional max)

Truncate NUMBER and clamp it to the range 0..MAX (default 127).

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-chromatic-index (midinote)

Get the chromatic index of MIDINOTE.

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-degree (midinote &key root scale)

Get the degree of MIDINOTE, taking into account the ROOT, OCTAVE, and SCALE, if provided.

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-freq (midinote)

Convert a midi note number to a frequency.

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-note (midinote)

Get the note name of MIDINOTE.

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-octave (midinote)

Get the octave number that MIDINOTE occurs in.

Package

cl-patterns.

Source

conversions.lisp.

Function: midinote-rate (midinote &optional base-note)

Convert a midinote to a playback rate.

Package

cl-patterns.

Source

conversions.lisp.

Function: mouse-location (&optional display-server)

Get a plist of the mouse location, total display size, and other information gleaned about DISPLAY-SERVER. DISPLAY-SERVER can be :x, :wayland, etc, but should default to the correct display server detected when cl-patterns is loaded. Will signal an error if the information cannot be determined (i.e. when the display server is not detected or not supported).

NOTE: This is currently only implemented on X-based systems, so will not work on Windows, MacOS, and Wayland.

Package

cl-patterns.

Source

patterns.lisp.

Function: multi-channel-funcall (function &rest args)

Call FUNCTION on the provided arguments. If one or more of the arguments is a list, funcall for each element of the list(s). The length of the resulting list will be the same as the longest input list.

Example:

;; (multi-channel-funcall #’+ 1 (list 1 2 3))
;; => (2 3 4)

See also: ‘mapcar-longest’, ‘split-event-by-lists’

Package

cl-patterns.

Source

utility.lisp.

Function: next-beat-for-quant (&optional quant beat direction)

Get the next valid beat for QUANT after BEAT. If DIRECTION is negative, finds the previous valid beat for QUANT.

See also: ‘quant’

Package

cl-patterns.

Source

utility.lisp.

Function: next-n (pstream &optional n)

Get the next N outputs of a pstream, function, or other object, advancing the pstream forward N times in the process.

See also: ‘next’, ‘next-upto-n’, ‘peek’, ‘peek-n’

Package

cl-patterns.

Source

patterns.lisp.

Function: next-upto-n (pstream &optional n)

Get a list of up to N results from PSTREAM, not including the end of pattern.

See also: ‘next’, ‘next-n’, ‘peek’, ‘peek-upto-n’

Package

cl-patterns.

Source

patterns.lisp.

Function: note-chromatic-index (note)

Get the chromatic index of NOTE.

Package

cl-patterns.

Source

conversions.lisp.

Function: note-degree (note &key root scale)

Get the degree of a note in the provided scale. If the note is not in the provided scale, truncate to the nearest note that is.

Package

cl-patterns.

Source

conversions.lisp.

Function: note-freq (note &rest args &key root octave steps-per-octave gtranspose octave-ratio)

Given a note, return its frequency in hertz, taking into account the ROOT and OCTAVE if provided.

See also: ‘note-midinote’

Package

cl-patterns.

Source

conversions.lisp.

Function: note-midinote (note &key root octave steps-per-octave gtranspose octave-ratio)

Given a note, return its midi note number, taking into account the OCTAVE if provided.

See also: ‘note-freq’

Package

cl-patterns.

Source

conversions.lisp.

Function: note-name-and-octave (note)

Given a note name, return a list consisting of its note number and its octave (defaulting to 4 if it’s not specified).

Examples:

;; (note-name-and-octave :c4) ;=> (:C 4)
;; (note-name-and-octave :a#7) ;=> (:A# 7)
;; (note-name-and-octave :c-1) ;=> (:C -1)
;; (note-name-and-octave :d) ;=> (:D 4)

See also: ‘note-midinote’, ‘chromatic-index-note’

Package

cl-patterns.

Source

utility.lisp.

Function: note-octave (note)

Get the octave of NOTE.

Package

cl-patterns.

Source

conversions.lisp.

Function: octave-degree (octave)

Get the degree of OCTAVE.

Package

cl-patterns.

Source

conversions.lisp.

Function: octave-freq (octave)

Get the base frequency of OCTAVE.

Package

cl-patterns.

Source

conversions.lisp.

Function: octave-midinote (octave)

Get the base (lowest) midi note number for OCTAVE.

Package

cl-patterns.

Source

conversions.lisp.

Function: octave-note (octave)

Get the note of OCTAVE.

Package

cl-patterns.

Source

conversions.lisp.

Function: p* (&rest numbers)

Syntax sugar for (pnary #’* ...).

See also: ‘pnary’, ‘common-lisp:*’

Package

cl-patterns.

Source

patterns.lisp.

Function: p+ (&rest numbers)

Syntax sugar for (pnary #’+ ...).

See also: ‘pnary’, ‘common-lisp:+’

Package

cl-patterns.

Source

patterns.lisp.

Function: p- (number &rest more-numbers)

Syntax sugar for (pnary #’- ...).

See also: ‘pnary’, ‘common-lisp:-’

Package

cl-patterns.

Source

patterns.lisp.

Function: p/ (number &rest more-numbers)

Syntax sugar for (pnary #’/ ...).

See also: ‘pnary’, ‘common-lisp:/’

Package

cl-patterns.

Source

patterns.lisp.

Function: p/= (number &rest more-numbers)

Syntax sugar for (pnary #’/= ...).

See also: ‘pnary’, ‘common-lisp:/=’

Package

cl-patterns.

Source

patterns.lisp.

Function: p< (number &rest more-numbers)

Syntax sugar for (pnary #’< ...).

See also: ‘pnary’, ‘common-lisp:<’

Package

cl-patterns.

Source

patterns.lisp.

Function: p<= (number &rest more-numbers)

Syntax sugar for (pnary #’<= ...).

See also: ‘pnary’, ‘common-lisp:<=’

Package

cl-patterns.

Source

patterns.lisp.

Function: p= (number &rest more-numbers)

Syntax sugar for (pnary #’= ...).

See also: ‘pnary’, ‘common-lisp:=’

Package

cl-patterns.

Source

patterns.lisp.

Function: p> (number &rest more-numbers)

Syntax sugar for (pnary #’> ...).

See also: ‘pnary’, ‘common-lisp:>’

Package

cl-patterns.

Source

patterns.lisp.

Function: p>= (number &rest more-numbers)

Syntax sugar for (pnary #’>= ...).

See also: ‘pnary’, ‘common-lisp:>=’

Package

cl-patterns.

Source

patterns.lisp.

Function: paccum (&optional operator start step length &key lo hi bound-by)

Numeric accumulator. Each output and STEP is used as the input for OPERATOR to generate the next output. When LO, HI, and BOUND-BY are provided, outputs that fall outside the range LO..HI are wrapped back inside with the BOUND-BY function; the value is provided as its first argument, and LO and HI are provided as its second and third.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-upto-n (paccum #’+ 0 1) 5) ; same as (pseries 0 1)
;; ;=> (0 1 2 3 4)

;; (next-upto-n (paccum #’+ 0 1 :inf :lo 0 :hi 3 :bound-by #’wrap) 9) ; same as above, wrapping between 0 and 3.
;; ;=> (0 1 2 0 1 2 0 1 2)

See also: ‘pseries’, ‘pgeom’, ‘pwalk’

Package

cl-patterns.

Source

patterns.lisp.

Function: paclump (pattern)

Automatically group outputs of the source pattern into lists of up to N items each. Unlike ‘pclump’, clump size is automatically set to the length of the longest list in the values of ‘*event*’, or 1 if there are no lists.

Example:

;; (next-upto-n (pbind :foo (pseq ’((1) (1 2) (1 2 3)) 1) :bar (paclump (pseries))))
;; ;=> ((EVENT :FOO (1) :BAR (0)) (EVENT :FOO (1 2) :BAR (1 2)) (EVENT :FOO (1 2 3) :BAR (3 4 5)))

See also: ‘pclump’

Package

cl-patterns.

Source

patterns.lisp.

Function: parp (pattern arpeggiator)

Arpeggiator pattern; each event yielded by PATTERN is bound to ‘*event*’ and then the entirety of the ARPEGGIATOR pattern is yielded.

Example:

;; (next-upto-n (parp (pbind :foo (pseq ’(1 2 3) 1))
;; (pbind :bar (pseq ’(4 5 6) 1))))
;; ;=> ((EVENT :FOO 1 :BAR 4) (EVENT :FOO 1 :BAR 5) (EVENT :FOO 1 :BAR 6)
;; (EVENT :FOO 2 :BAR 4) (EVENT :FOO 2 :BAR 5) (EVENT :FOO 2 :BAR 6)
;; (EVENT :FOO 3 :BAR 4) (EVENT :FOO 3 :BAR 5) (EVENT :FOO 3 :BAR 6))

See also: ‘psym’, ‘pmeta’, ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Function: pattern-as-pstream (thing)

Like ‘as-pstream’, but only converts THING to a pstream if it is a pattern.

Package

cl-patterns.

Source

patterns.lisp.

Function: pattern-children (pattern &key num accumulate class)

Get a list of all the direct child patterns of PATTERN, including any in slots or lists.

See also: ‘pattern-parent’

Package

cl-patterns.

Source

patterns.lisp.

Function: (setf pattern-metadata) (pattern key)
Package

cl-patterns.

Source

patterns.lisp.

Function: pattern-p (object)

True if OBJECT is a pattern.

See also: ‘pattern’, ‘defpattern’

Package

cl-patterns.

Source

patterns.lisp.

Function: pattern-parent (pattern &key num accumulate class)

Get the NUM-th containing pattern of PATTERN, or nil if there isn’t one. If CLASS is specified, only consider patterns of that class.

See also: ‘pattern-children’

Package

cl-patterns.

Source

patterns.lisp.

Function: pattern-tasks (pattern &optional clock)

Attempt to get the tasks on CLOCK that are playing PATTERN.

See also: ‘task-pattern’, ‘clock-tasks’

Package

cl-patterns.

Source

clock.lisp.

Function: pbeat ()

Yield the number of beats elapsed since the pbeat was embedded in the pstream.

Example:

;; (next-n (pbind :dur (pseq ’(1 2 3)) :foo (pbeat)) 3)
;; ;=> ((EVENT :DUR 1 :FOO 0) (EVENT :DUR 2 :FOO 1) (EVENT :DUR 3 :FOO 3))

See also: ‘pbeat*’, ‘beat’, ‘prun’

Package

cl-patterns.

Source

patterns.lisp.

Function: pbeat* ()

Yield the number of beats on the ‘*clock*’ of the current pattern. In other words, pbeat* is clock-synced, unlike ‘pbeat’, which is pattern-synced.

Example:

;; (next-n (pbind :dur (pseq ’(1 2 3)) :foo (pbeat*)) 3)
;; ;=> ((EVENT :DUR 1 :FOO 200) (EVENT :DUR 2 :FOO 201) (EVENT :DUR 3 :FOO 203))

See also: ‘pbeat’, ‘beat’, ‘prun’

Package

cl-patterns.

Source

patterns.lisp.

Function: pbind (&rest pairs)

pbind yields events determined by its PAIRS, which are a list of keys and values. Each key corresponds to a key in the resulting events, and each value is treated as a pattern that is evaluated for each step of the pattern to generate the value for its key.

Example:

;; (next-n (pbind :foo (pseq ’(1 2 3)) :bar :hello) 4)
;;
;; ;=> ((EVENT :FOO 1 :BAR :HELLO) (EVENT :FOO 2 :BAR :HELLO) (EVENT :FOO 3 :BAR :HELLO) EOP)

See also: ‘pmono’, ‘pb’

Package

cl-patterns.

Source

patterns.lisp.

Function: pbjorklund (pulses steps &key offset dur repeats)

pbjorklund generates Euclidean rhythms using the Bjorklund algorithm. PULSES is the number of notes in the sequence, and STEPS is number of steps in the sequence. Additionally, OFFSET is the number to rotate the sequence by, DUR is the total duration one repeat of the sequence should be, and REPEATS is the number of repeats that should be yielded. This pattern outputs events which can be embedded into another pattern. Each pulse is a note, and each subdivision of the sequence that is not a pulse is a rest. If you just want the raw output from the Bjorklund algorithm (not in pattern form), use ‘bjorklund’ instead.

Example:

;; (next-upto-n (pbjorklund 3 7))
;; => ((EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7))

See also: ‘bjorklund’

Package

cl-patterns.

Source

bjorklund.lisp.

Function: pbrown (&optional lo hi step length)

Brownian motion within a range; each output randomly a maximum of STEP away from the previous. LO and HI define the lower and upper bounds of the range. STEP defaults to 1 if LO and HI are integers.

Example:

;; (next-upto-n (pbrown 0 10 1 10))
;; ;=> (2 3 3 3 4 3 4 5 6 5)

See also: ‘pwhite’, ‘pexprand’, ‘pgauss’

Package

cl-patterns.

Source

patterns.lisp.

Function: pchain (&rest patterns)

Combine multiple patterns into one event stream.

Example:

;; (next-n (pchain (pbind :foo (pseq ’(1 2 3))) (pbind :bar (pseq ’(7 8 9) 1))) 4) ;;
;; ;=> ((EVENT :FOO 1 :BAR 7) (EVENT :FOO 2 :BAR 8) (EVENT :FOO 3 :BAR 9) NIL)

See also: ‘pbind”s :embed key

Package

cl-patterns.

Source

patterns.lisp.

Function: pclump (pattern &optional n)

Group outputs of the source pattern into lists of up to N items each.

Example:

;; (next-upto-n (pclump (pseries 0 1 5) 2))
;; ;=> ((0 1) (2 3) (4))

See also: ‘paclump’

Package

cl-patterns.

Source

patterns.lisp.

Function: pcycles (list &key map key dur repeats)

pcycles yields values from LIST as events whose dur is (/ 1 list-length) and whose value is the original value in the list. This process recurses into sublists, subdividing their durs equally among the sublist’s contents to be a fraction of what their dur originally would be. The total dur yielded by pcycles is always equal to 1. pcycles repeats the whole LIST once.

Package

cl-patterns.

Source

cycles.lisp.

Function: pdef (name &optional pattern)

Define a named pattern, with NAME being the name of the pattern and PATTERN the pattern itself. Named patterns are stored in a global dictionary and can be referred back to by calling ‘pdef’ without supplying PATTERN. The global dictionary also keeps track of the pdef’s pstream when ‘play’ is called on it. If a pdef is redefined while it is being played, the changes won’t be audible until either PATTERN ends, or the pdef’s ‘end-quant’ time is reached (if non-nil). Note that, unlike bare patterns, pdefs loop by default when played (‘loop-p’).

Example:

;; (pdef :foo (pbind :degree (pseries 0 1 4)))
;;
;; (play (pdef :foo))
;; ;; redefine the pdef’s pattern... note that the redefinition doesn’t become audible until the current loop finishes playing:
;; (pdef :foo (pbind :degree (pseries 4 -1 4)))

See also: ‘find-pdef’, ‘all-pdefs’, ‘pb’, ‘pmeta’, ‘ps’

Package

cl-patterns.

Source

pdef.lisp.

Function: pdef-p (object)

Test whether OBJECT is a pdef.

See also: ‘find-pdef’

Package

cl-patterns.

Source

pdef.lisp.

Function: pdelta (pattern &optional cycle)

Output the difference between successive outputs of PATTERN, assuming PATTERN restarts every CYCLE outputs.

Unlike ‘pdiff’, pdelta is written with its use as input for ‘pbind”s :delta key in mind. If PATTERN’s successive values would result in a negative difference, pdelta instead wraps the delta around to the next multiple of CYCLE. This would allow you to, for example, supply the number of the beat that each event occurs on, rather than specifying the delta between each event. This is of course achievable using pbind’s :beat key as well, however that method requires the pbind to peek at future values, which is not always desirable.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-n (pdelta (pseq ’(0 1 2 3)) 4) 8)
;;
;; ;=> (1 1 1 1 1 1 1 1)
;;
;; (next-n (pdelta (pseq ’(0 1 2 5)) 4) 8)
;;
;; ;=> (1 1 3 3 1 1 3 3)

See also: ‘pdiff’, ‘pbind”s :beat key

Package

cl-patterns.

Source

patterns.lisp.

Function: pdiff (pattern)

Output the difference between successive outputs of PATTERN.

Example:

;; (next-n (pdiff (pseq ’(3 1 4 3) 1)) 4)
;;
;; ;=> (-2 3 -1 NIL)

See also: ‘pdelta’

Package

cl-patterns.

Source

patterns.lisp.

Function: pdrop (pattern &optional n)

Drop the first N outputs from PATTERN and yield the rest. If N is negative, drop the last N outputs from PATTERN instead.

Example:

;; (next-n (pdrop (pseq ’(1 2 3 4) 1) 2) 4)
;;
;; ;=> (3 4 NIL NIL)

See also: ‘protate’

Package

cl-patterns.

Source

patterns.lisp.

Function: pdurstutter (pattern n)

Yield each output from PATTERN N times, dividing it by N. If the output from PATTERN is an event, its dur is divided; if it’s a number, the number itself is divided instead of being yielded directly.

Example:

;; (next-n (pdurstutter (pseq ’(1 2 3 4 5)) (pseq ’(3 2 1 0 2))) 9)
;; ;=> (1/3 1/3 1/3 1 1 3 5/2 5/2 NIL)
;;
;; (next-n (pdurstutter (pbind :dur (pseq ’(1 2 3 4 5)))
;; (pseq ’(3 2 1 0 2)))
;; 9)
;; ;=> ((EVENT :DUR 1/3) (EVENT :DUR 1/3) (EVENT :DUR 1/3) (EVENT :DUR 1) (EVENT :DUR 1) (EVENT :DUR 3) (EVENT :DUR 5/2) (EVENT :DUR 5/2) NIL)

See also: ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Function: peek-n (pstream &optional n)

Peek at the next N results of a pstream, without advancing it forward in the process.

See also: ‘peek’, ‘peek-upto-n’, ‘next’, ‘next-n’

Package

cl-patterns.

Source

patterns.lisp.

Function: peek-upto-n (pstream &optional n)

Peek at up to the next N results of a pstream, without advancing it forward in the process.

See also: ‘peek’, ‘peek-n’, ‘next’, ‘next-upto-n’

Package

cl-patterns.

Source

patterns.lisp.

Function: peql (x y)

Syntax sugar for (pnary #’eql ...).

See also: ‘pnary’, ‘common-lisp:eql’

Package

cl-patterns.

Source

patterns.lisp.

Function: pexprand (&optional lo hi length)

Exponentially-distributed random numbers between LO and HI. Note that LO and HI cannot be 0, and that LO and HI must have the same sign or else complex numbers will be output.

Example:

;; (next-upto-n (pexprand 1.0 8.0 4))
;; ;=> (1.0420843091865208d0 1.9340168112124456d0 2.173209129035095d0 4.501371557329618d0)

See also: ‘pwhite’, ‘pbrown’, ‘pgauss’, ‘prand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pfilter (pattern &optional predicate)

Skip elements of a source pattern that PREDICATE returns false for. If PREDICATE is not a function, skip items that are ‘eql’ to it.

Example:

;; (next-n (pfilter (pseq (list 1 2 3))
;; 2)
;; 6)
;; ;=> (1 3 1 3 1 3)

;; (next-n (pfilter (pseries 0 1) ’evenp)
;; 6)
;; ;=> (1 3 5 7 9 11)

See also: ‘pfilter-out’, ‘pr’, ‘pdurstutter’

Package

cl-patterns.

Source

patterns.lisp.

Function: pfilter-out (pattern predicate)

Skip elements of a source pattern that PREDICATE returns true for. If PREDICATE is not a function, skip items that are ‘eql’ to it.

See also: ‘pfilter’

Package

cl-patterns.

Source

patterns.lisp.

Function: pfin (pattern count)

Yield up to COUNT outputs from PATTERN.

Example:

;; (next-n (pfin (pseq ’(1 2 3) :inf) 3) 5) ;; ;=> (1 2 3 NIL NIL)

See also: ‘pfindur’

Package

cl-patterns.

Source

patterns.lisp.

Function: pfindur (pattern dur &optional tolerance)

Yield events from PATTERN until their total duration is within TOLERANCE of DUR, or greater than DUR. Any events that would end beyond DUR are cut short. If PATTERN outputs numbers, their total sum is limited instead.

Example:

;; (next-n (pfindur (pbind :dur 1 :foo (pseries)) 2) 3)
;; ;=> ((EVENT :DUR 1 :FOO 0) (EVENT :DUR 1 :FOO 1) EOP)
;;
;; (next-upto-n (pfindur (pwhite 0 4) 16))
;; ;=> (1 3 0 1 2 2 1 3 0 1 2)
;; (reduce #’+ *)
;; ;=> 16

See also: ‘pfin’, ‘psync’

Package

cl-patterns.

Source

patterns.lisp.

Function: pfunc (func &optional length)

Yield the result of evaluating FUNC. Note that the current event of the parent pattern is still accessible via the ‘*event*’ special variable.

Example:

;; (next-upto-n (pfunc (lambda () (random 10)) 4))
;; ;=> ((5 2 8 9))
;;
;; (next-upto-n (pbind :foo (pwhite 0 10 4)
;; :bar (pfunc (lambda ()
;; (if (> (event-value *event* :foo) 5) :greater :lesser)))))
;; ;=> ((EVENT :FOO 0 :BAR :LESSER) (EVENT :FOO 6 :BAR :GREATER)
;; (EVENT :FOO 7 :BAR :GREATER) (EVENT :FOO 8 :BAR :GREATER))

See also: ‘pf’, ‘pnary’, ‘plazy’, ‘pif’

Package

cl-patterns.

Source

patterns.lisp.

Function: pgauss (&optional mean deviation length)

Random numbers distributed along a normal (gaussian) curve. MEAN is the "center" of the distribution, DEVIATION is the standard deviation (i.e. the higher the value, the further the outputs are spread from MEAN).

Example:

;; (next-n (pgauss) 4)
;; ;=> (0.08918811646370092d0 0.1745957067161632d0 0.7954678768273173d0 -1.2215823449671597d0)

See also: ‘pwhite’, ‘pexprand’, ‘pbrown’

Package

cl-patterns.

Source

patterns.lisp.

Function: pgeom (&optional start grow length)

Yield START, then generate subsequent outputs by multiplying by GROW, for a total of LENGTH outputs.

Example:

;; (next-upto-n (pgeom 1 2 4))
;; ;=> (1 2 4 8)

See also: ‘pseries’, ‘paccum’

Package

cl-patterns.

Source

patterns.lisp.

Function: pgeom* (&optional start end length)

Syntax sugar to generate a ‘pgeom’ whose values go from START to END exponentially over LENGTH steps. LENGTH cannot be infinite since delta calculation requires dividing by it.

Based on the Pgeom extension from the ddwPatterns SuperCollider library.

Example:

;; (pgeom* 1 100 8)
;; ;=> (pgeom 1 1.9306977 8)
;;
;; (next-upto-n *)
;; ;=> (1 1.9306977 3.7275934 7.196856 13.894953 26.826954 51.79474 99.999985)
;; ;; Note that due to floating point rounding errors the last output may not always be exactly END.

See also: ‘pgeom’, ‘pseries’, ‘pseries*’

Package

cl-patterns.

Source

patterns.lisp.

Function: phistory (pattern step-pattern)

Refer back to PATTERN’s history, yielding the output at the index provided by STEP-PATTERN.

Note that PATTERN is still advanced once per event, and if STEP-PATTERN yields a number pointing to an event in PATTERN that hasn’t been yielded yet (i.e. if PATTERN has only advanced once but STEP-PATTERN yields 3 for its output), phistory yields nil.

Example:

;; (next-n (phistory (pseries) (pseq ’(0 2 1))) 3)
;; ;=> (0 NIL 1)

See also: ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Function: pif (test true &optional false)

"If" expression for patterns. TEST is evaluated for each step, and if it’s non-nil, the value of TRUE will be yielded, otherwise the value of FALSE will be. Note that TRUE and FALSE can be patterns, and if they are, they are only advanced in their respective cases, not for every step.

Example:

;; (next-n (pif (pseq ’(t t nil nil nil)) (pseq ’(1 2 3)) (pseq ’(9 8 7))) 8)
;; ;=> (1 2 9 8 7 3 1 9)

See also: ‘plazy’, ‘pfunc’

Package

cl-patterns.

Source

patterns.lisp.

Function: pindex (list-pat index-pat &optional wrap-p)

Use INDEX-PAT to index into the list returned by LIST-PAT. WRAP-P is whether indexes that are out of range will be wrapped (if t) or will simply return nil.

Example:

;; (next-n (pindex (list 99 98 97) (pseq (list 0 1 2 3))) 4)
;;
;; ;=> (99 98 97 NIL)
;;
;; (next-upto-n (pindex (list 99 98 97) (pseries 0 1 6) t))
;;
;; ;=> (99 98 97 99 98 97)

See also: ‘pwalk’

Package

cl-patterns.

Source

patterns.lisp.

Function: pk (key &optional default)

Yield the value of KEY in the current ‘*event*’ context, returning DEFAULT if that value is nil.

Example:

;; (next-upto-n (pbind :foo (pseq ’(1 2 3) 1) :bar (pk :foo)))
;; ;=> ((EVENT :FOO 1 :BAR 1) (EVENT :FOO 2 :BAR 2) (EVENT :FOO 3 :BAR 3))

See also: ‘pbind’, ‘event-value’, ‘*event*’

Package

cl-patterns.

Source

patterns.lisp.

Function: place (list &optional repeats)

Yield each value from LIST in sequence. If the value is a list, the first element of that list is yielded. The second time that sub-list is encountered, its second element will be yielded; the third time, the third element, and so on. REPEATS controls the number of times LIST is repeated.

Example:

;; (next-upto-n (place (list 1 2 (list 3 4 5)) 3))
;; ;=> (1 2 3 1 2 4 1 2 5)

See also: ‘ppatlace’

Package

cl-patterns.

Source

patterns.lisp.

Function: play-or-end (object)

‘play’ an object, or ‘end’ it if it’s already playing. Returns the task if the object will start playing, or NIL if it will end.

Package

cl-patterns.

Source

utility.lisp.

Function: play-or-stop (object)

‘play’ an object, or ‘stop’ it if it is already playing. Returns the task if the object will start playing, or NIL if it will stop.

Package

cl-patterns.

Source

utility.lisp.

Function: play-solo (object &key stop-type clock)

End or stop all tasks on CLOCK and play OBJECT (or simply let it continue playing if it’s already playing).

See also: ‘play’, ‘end’, ‘stop’, ‘play-swap’

Package

cl-patterns.

Source

utility.lisp.

Function: play-swap (play end &key stop-type clock)

Play PLAY, and end (or stop) END.

See also: ‘play’, ‘end’, ‘stop’, ‘play-solo’

Package

cl-patterns.

Source

utility.lisp.

Function: playing-nodes (&optional backend)

Get a list of all nodes on BACKEND that are currently playing. Without BACKEND, get all playing nodes on all backends.

See also: ‘all-instruments’, ‘playing-pdefs’, ‘playing-p’

Package

cl-patterns.

Source

utility.lisp.

Function: playing-pdef-names (&optional clock)

Get a list of the names of all pdefs playing on CLOCK.

See also: ‘playing-pdefs’, ‘all-pdefs’, ‘playing-nodes’, ‘playing-p’

Package

cl-patterns.

Source

pdef.lisp.

Function: playing-pdefs (&optional clock)

Get a list of the names of all pdefs playing on CLOCK.

See also: ‘playing-pdef-names’, ‘all-pdefs’, ‘playing-nodes’, ‘playing-p’

Package

cl-patterns.

Source

pdef.lisp.

Function: plazy (func &optional repeats)

Evaluates FUNC to generate a pattern, which is then yielded from until its end, at which point FUNC is evaluated again to generate the next pattern. The pattern is generated a total of REPEATS times.

Example:

;; (next-n (plazy (lambda () (if (= 0 (random 2)) (pseq ’(1 2 3) 1) (pseq ’(9 8 7) 1)))) 6)
;; ;=> (9 8 7 1 2 3)

See also: ‘pfunc’

Package

cl-patterns.

Source

patterns.lisp.

Function: pmeta (&rest pairs)

Meta-control patterns using the events output by PATTERN. In other words, instead of triggering synths directly, the events output by PATTERN are used to embed patterns into the pmeta’s pstream.

The following keys are supported:

- :pattern or :instrument - name of the source pattern for this "step".
- :dur - set the duration of the embedded pattern (defaults to :inf, which causes the pattern to play to its end).
- :findur - limit the duration of the embedded pattern.
- :sync - sync the duration of the embedded pattern to a multiple of the provided value, similar to ‘psync’
- :stretch - multiply the duration of each of the source pattern’s events.
- :ts or :fit - timestretch a pattern so its total duration is the number specified, a la ‘pts’.
- :r or :repeat - repeat each event the number of times returned by the function when the event is applied to it, similar to ‘pr’.
- :inject - inject key/value pairs from the output of this value into the source pattern.
- :step-inject or :sinject - inject one output from this value per step.

The following keys are planned for future implementation:

- :start or :end - adjust the start or end points of the source pattern (i.e. to skip the first half, set :start to 0.5).
- :start-beat or :end-beat - adjust the start or end points of the source pattern in number of beats (i.e. to end the pattern 2 beats early, set :end-beat to -2).
- :start-nth or :end-nth - adjust the start or end points of the source pattern by skipping the first or last N events.
- :filter or :remove-if-not - skip all events from the source pattern that return nil when applied to the specified function or pattern.
- :mapcar or :nary - process each event from the source pattern with a function or another pattern.

See doc/special-keys.org for more information on these keys.

Example:

;; ;; define a few patterns...
;; (pdef :foo (pbind :x (pseq ’(1 2 3) 1) :dur 1))
;; (pdef :bar (pbind :y (pseries) :dur (pwhite 0.1 1.0 3)))
;;
;; ;; use pmeta to play pattern foo and then pattern bar, ensuring each are 2 beats long in total by way of pmeta’s sync key, which works similarly to ‘psync’
;; (next-upto-n (pmeta :pattern (pseq (list :foo :bar) 1) :sync 2))
;; ;=> ((EVENT :X 1 :DUR 1) (EVENT :X 2 :DUR 1) ; from (pdef :foo)
;; (EVENT :Y 0 :DUR 0.76958686) (EVENT :Y 1 :DUR 0.94850993) (EVENT :Y 2 :DUR 0.28190327)) ; from (pdef :bar)

See also: ‘psym’, ‘parp’, ‘pdef’, ‘pbind’

Package

cl-patterns.

Source

pmeta.lisp.

Function: pmono (instrument &rest pairs)

pmono defines a mono instrument event pstream. It’s effectively the same as ‘pbind’ with its :type key set to :mono.

See also: ‘pbind’

Package

cl-patterns.

Source

patterns.lisp.

Function: pmouse (orientation &optional format)

Get the mouse position of the display server (GUI). ORIENTATION can be :x or :y, and FORMAT can be either :relative (in which case the output is a number from 0 to 1 as a fraction of total display size) or :absolute (in which case the output is the actual X or Y position of the mouse).

See also: ‘pmousex’, ‘pmousey’, ‘mouse-location’

Package

cl-patterns.

Source

patterns.lisp.

Function: pmousex (&optional format)

Get the mouse’s x position on screen. FORMAT can be either :relative (in which case the output is a number from 0 to 1 as a fraction of total display size) or :absolute (in which case the output is the actual X or Y position of the mouse).

See also: ‘pmouse’, ‘pmousey’, ‘mouse-location’

Package

cl-patterns.

Source

patterns.lisp.

Function: pmousey (&optional format)

Get the mouse’s y position on screen. FORMAT can be either :relative (in which case the output is a number from 0 to 1 as a fraction of total display size) or :absolute (in which case the output is the actual X or Y position of the mouse).

See also: ‘pmouse’, ‘pmousex’, ‘mouse-location’

Package

cl-patterns.

Source

patterns.lisp.

Function: pn (pattern &optional repeats)

Embed the full PATTERN into the pstream REPEATS times.

Example:

;; (next-upto-n (pn (pwhite 0 5 1) 5))
;; ;=> (2 4 2 1 0)

See also: ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Function: pnary (operator &rest patterns)

Yield the result of applying OPERATOR to each value yielded by each pattern in PATTERNS.

Example:

;; (next-upto-n (pnary (pseq (list ’+ ’- ’* ’/) 2) 2 2))
;; ;=> (4 0 4 1)

See also: ‘pfunc’, ‘p+’, ‘p-’, ‘p*’, ‘p/’

Package

cl-patterns.

Source

patterns.lisp.

Function: ppar (patterns)

Combine multiple event patterns into one pstream with all events in temporal order. PATTERNS is the list of patterns, or a pattern yielding lists of patterns. The ppar ends when all of the patterns in PATTERNS end.

Example:

;; (next-upto-n (ppar (list (pbind :dur (pn 1/2 4))
;; (pbind :dur (pn 2/3 4)))))
;;
;; ;=> ((EVENT :DUR 1/2 :DELTA 0) (EVENT :DUR 2/3 :DELTA 1/2)
;; (EVENT :DUR 1/2 :DELTA 1/6) (EVENT :DUR 2/3 :DELTA 1/3)
;; (EVENT :DUR 1/2 :DELTA 1/3) (EVENT :DUR 2/3 :DELTA 1/6)
;; (EVENT :DUR 1/2 :DELTA 1/2) (EVENT :DUR 2/3 :DELTA 2/3))

See also: ‘psym’

Package

cl-patterns.

Source

patterns.lisp.

Function: pparchain (&rest patterns)

Combine multiple patterns into several event streams. The event yielded by the first pattern will be used as the input event to the second pattern, and so on. The events yielded by each pattern will be collected into a list and yielded by the pparchain. This pattern is effectively ‘ppar’ and ‘pchain’ combined.

Example:

;; (next-upto-n (pparchain (pbind :foo (pseries 0 1 3)) (pbind :baz (p+ (pk :foo) 1) :foo (p+ (pk :foo) 3))))
;; ;=> (((EVENT :FOO 0) (EVENT :FOO 3 :BAZ 1))
;; ((EVENT :FOO 1) (EVENT :FOO 4 :BAZ 2))
;; ((EVENT :FOO 2) (EVENT :FOO 5 :BAZ 3)))

See also: ‘ppc’, ‘ppar’, ‘pchain’, ‘pbind”s :embed key

Package

cl-patterns.

Source

patterns.lisp.

Function: ppatlace (list &optional repeats)

Yield each value from LIST in sequence, or one output from each pattern in LIST per cycle of the list. If one of the patterns embedded in LIST ends sooner than the others, it is simply removed and the ppatlace continues to yield from the rest of the LIST. The entire LIST is yielded through a total of REPEATS times.

Example:

;; (next-upto-n (ppatlace (list (pseq (list 1 2 3) 1)
;; (pseq (list 4 5 6) 2))))
;; ;=> (1 4 2 5 3 6 4 5 6)

See also: ‘place’

Package

cl-patterns.

Source

patterns.lisp.

Function: pr (pattern &optional repeats)

Repeat each value from PATTERN REPEATS times. If REPEATS is 0, the value is skipped.

Example:

;; (next-upto-n (pr (pseries) (pseq ’(1 3 0 2) 1)))
;; ;=> (0 1 1 1 3 3)

See also: ‘pdurstutter’, ‘pn’, ‘pdrop’, ‘parp’

Package

cl-patterns.

Source

patterns.lisp.

Function: prand (list &optional length)

Yield random values from LIST.

Example:

;; (next-n (prand ’(1 2 3) 5) 6)
;; ;=> (3 2 2 1 1 EOP)

See also: ‘pxrand’, ‘pwrand’, ‘pwxrand’

Package

cl-patterns.

Source

patterns.lisp.

Function: prerange (input from-range to-range)

Remap INPUT from one range, specified by FROM-RANGE, to another range, specified by TO-RANGE.

Note that this is effectively a convenience wrapper over ‘pnary’ and ‘rerange’; thus you should see ‘rerange’ for more information.

See also: ‘rerange’, ‘pnary’

Package

cl-patterns.

Source

patterns.lisp.

Function: prest (&optional value)

Make a prest object, which, when used in a ‘pbind’ or similar event pattern, turns the current event into a rest and yields VALUE for the key’s value.

Note that this is not a pattern; it is just a regular function that returns a prest object.

Example:

;; (next-upto-n (pbind :degree (pseq (list 0 1 (prest 2) 3) 1)))
;; ;=> ((EVENT :DEGREE 0) (EVENT :DEGREE 1) (EVENT :TYPE :REST :DEGREE 2) (EVENT :DEGREE 3))

See also: ‘pbind’, ‘pbind”s :type key

Package

cl-patterns.

Source

patterns.lisp.

Function: protate (pattern &optional shift)

Rotate PATTERN N outputs forward or backward, wrapping the shifted items to the other side, a la ‘alexandria:rotate’.

Example:

;; (next-upto-n (protate (pseq ’(1 2 3 4 5) 1) 2))
;; ;=> (4 5 1 2 3)

See also: ‘pdrop’, ‘phistory’, ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Function: prs (pattern &optional repeats)

Syntax sugar for (pr (ps PATTERN) REPEATS). Useful, for example, to ensure that each loop of a pattern only gets one value from the ‘ps’.

See also: ‘pr’, ‘ps’

Package

cl-patterns.

Source

patterns.lisp.

Function: prun (pattern &optional dur)

Run PATTERN "independently" of its parent, holding each value for DUR beats. Each of PATTERN’s outputs is treated as if it lasted DUR beats, being continuously yielded during that time before moving on to the next output.

Example:

;; (next-upto-n (pbind :foo (pseq ’(1 2 3 4 5))
;; :bar (prun (pseq ’(4 5 6 7 8))
;; (pseq ’(1 2 0.5 0.5 1)))))
;; ;=> ((EVENT :FOO 1 :BAR 4)
;; (EVENT :FOO 2 :BAR 5)
;; (EVENT :FOO 3 :BAR 5)
;; (EVENT :FOO 4 :BAR 6)
;; (EVENT :FOO 5 :BAR 8))

See also: ‘beat’, ‘pbeat’

Package

cl-patterns.

Source

patterns.lisp.

Function: ps (pattern)

Preserve pstream state across subsequent calls to ‘as-pstream’. To reset the pstream, simply re-evaluate the ps definition.

Based on the pattern originally from the miSCellaneous SuperCollider library.

Example:

;; (defparameter *pst* (ps (pseries)))
;;
;; (next-upto-n *pst* 4)
;; ;=> (0 1 2 3)
;;
;; (next-upto-n *pst* 4)
;; ;=> (4 5 6 7)
;;
;; (defparameter *pst* (ps (pseries)))
;;
;; (next-upto-n *pst* 4)
;; ;=> (0 1 2 3)

See also: ‘prs’, ‘pdef’

Package

cl-patterns.

Source

patterns.lisp.

Function: pscratch (pattern step-pattern)

"Scratches" across the values yielded by a pstream, similar in concept to how a DJ might scratch a record, altering the normal flow of playback. PATTERN is the source pattern, and STEP-PATTERN determines the increment of the index into the pstream history.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-upto-n (pscratch (pseries) (pseq ’(0 1 1 -1 2) 2)))
;; ;=> (0 0 1 2 1 3 3 4 5 4)

See also: ‘phistory’

Package

cl-patterns.

Source

patterns.lisp.

Function: pseq (list &optional repeats offset)

Sequentially yield items from LIST, repeating the whole list REPEATS times. OFFSET is the offset to index into the list.

Example:

;; (next-n (pseq ’(5 6 7) 2) 7)
;; ;=> (5 6 7 5 6 7 EOP)
;;
;; (next-upto-n (pseq ’(5 6 7) 2 1))
;; ;=> (6 7 5 6 7 5)

See also: ‘pser’, ‘eseq’

Package

cl-patterns.

Source

patterns.lisp.

Function: pser (list &optional length offset)

Sequentially yield values from LIST, yielding a total of LENGTH values.

Example:

;; (next-n (pser ’(5 6 7) 2) 3)
;;
;; ;=> (5 6 EOP)

See also: ‘pseq’

Package

cl-patterns.

Source

patterns.lisp.

Function: pseries (&optional start step length)

Yield START, then generate subsequent outputs by adding STEP, for a total of LENGTH outputs.

Example:

;; (next-upto-n (pseries 1 2 4))
;; ;=> (1 3 5 7)

See also: ‘pseries*’, ‘pgeom’, ‘paccum’

Package

cl-patterns.

Source

patterns.lisp.

Function: pseries* (&optional start end length)

Syntax sugar to generate a ‘pseries’ whose values go from START to END linearly over LENGTH steps. If LENGTH is not provided, it is calculated such that the step will be 1. Note that LENGTH cannot be infinite since delta calculation requires dividing by it.

Based on the Pseries extension from the ddwPatterns SuperCollider library.

Example:

;; (pseries* 0 10 16)
;; ;=> (pseries 0 2/3 16)
;;
;; (next-upto-n *)
;; ;=> (0 2/3 4/3 2 8/3 10/3 4 14/3 16/3 6 20/3 22/3 8 26/3 28/3 10)

See also: ‘pseries’, ‘pgeom’, ‘pgeom*’

Package

cl-patterns.

Source

patterns.lisp.

Function: pshuf (list &optional repeats)

Shuffle LIST, then yield each item from the shuffled list, repeating it REPEATS times.

Example:

;; (next-upto-n (pshuf ’(1 2 3) 2))
;;
;; ;=> (3 1 2 3 1 2)

See also: ‘prand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pslide (list &optional repeats len step start wrap-at-end)

"Slide" across sections of LIST. REPEATS is the total number of sections to output, LEN the length of the section. STEP is the number to increment the start index by after each section, and START is the initial index into LIST that the first section starts from. WRAP-AT-END, when true, means that an index outside of the list will wrap around. When false, indexes outside of the list result in nil.

Example:

;; (next-upto-n (pslide (list 0 1 2 3 4 5 6) 3 3 2 1 t))
;; ;=> (1 2 3 3 4 5 5 6 0)

See also: ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Function: pstream-elt (pstream n)

Get the Nth item in PSTREAM’s history. For negative N, get the -Nth most recent item.

Example:

;; (let ((pstream (as-pstream (pseq ’(1 2 3)))))
;; (next pstream) ;=> 1
;; (pstream-elt pstream 0) ;=> 1 ; first item in the pstream’s history
;; (next pstream) ;=> 2
;; (pstream-elt pstream 1) ;=> 2 ; second item in the pstream’s history
;; (pstream-elt pstream -1)) ;=> 2 ; most recent item in the pstream’s history

See also: ‘pstream-elt-future’, ‘phistory’

Package

cl-patterns.

Source

patterns.lisp.

Function: pstream-elt-future (pstream n)

Get the element N away from the most recent in PSTREAM’s history. Unlike ‘pstream-elt’, this function will automatically peek into the future for any positive N.

Example:

;; (let ((pstream (as-pstream (pseq ’(1 2 3)))))
;; (pstream-elt-future pstream 0) ;=> 1
;; (next pstream) ;=> 1
;; (pstream-elt-future pstream 1) ;=> 2
;; (next pstream)) ;=> 2

See also: ‘pstream-elt’, ‘phistory’

Package

cl-patterns.

Source

patterns.lisp.

Function: pstream-p (object)

True if OBJECT is a pstream.

See also: ‘pstream’, ‘as-pstream’

Package

cl-patterns.

Source

patterns.lisp.

Function: psym (pattern)

Use a pattern of symbols to embed ‘pdef’s. PATTERN is the source pattern that yields symbols naming the pdef to embed.

Example:

;; (pdef :foo (pseq ’(1 2 3) 1))
;;
;; (pdef :bar (pseq ’(4 5 6) 1))
;;
;; (next-upto-n (psym (pseq ’(:foo :bar) 1)))
;;
;; ;=> (1 2 3 4 5 6)

See also: ‘pdef’, ‘ppar’, ‘pmeta’

Package

cl-patterns.

Source

patterns.lisp.

Function: psync (pattern sync-quant &optional maxdur tolerance)

Yield events from PATTERN until their total duration is within TOLERANCE of MAXDUR, cutting off any events that would extend past MAXDUR. If PATTERN ends before MAXDUR, a rest is added to the pstream to round its duration up to the nearest multiple of SYNC-QUANT.

Example:

;; (next-upto-n (psync (pbind :dur (pseq ’(5) 1)) 4 16))
;;
;; ;=> ((EVENT :DUR 5) (EVENT :TYPE :REST :DUR 3))
;;
;; (next-upto-n (psync (pbind :dur (pseq ’(5) 5)) 4 16))
;;
;; ;=> ((EVENT :DUR 5) (EVENT :DUR 5) (EVENT :DUR 5) (EVENT :DUR 5 :DELTA 1))

See also: ‘pfindur’

Package

cl-patterns.

Source

patterns.lisp.

Function: ptime ()

Yield the number of seconds elapsed since ptime was embedded in the pstream.

Note: May give inaccurate results if the clock’s tempo changes occur more frequently than events in the parent pbind.

Example:

;; (setf (tempo *clock*) 1) ; 60 BPM
;; (next-n (pbind :dur 1 :time (ptime)) 2)
;; ;=> ((EVENT :DUR 1 :TIME 0) (EVENT :DUR 1 :TIME 1.0))

See also: ‘pbeat’, ‘prun’, ‘beat’

Package

cl-patterns.

Source

patterns.lisp.

Function: ptrace (&optional trace prefix stream)

Print the PREFIX and each output of TRACE to STREAM. If TRACE is t, print ‘*event*’. If TRACE is a different symbol, print the value of that symbol in ‘*event*’. If TRACE is a pattern, ptrace yields its output unaffected. Otherwise, it yields t.

See also: ‘debug-backend’, ‘debug-backend-recent-events’

Package

cl-patterns.

Source

patterns.lisp.

Function: ptrack (header rows &key repeats)

Defines an event pattern via a tracker-inspired notation. HEADER is a plist mapping the pattern’s "columns" (keys) to their default values or to patterns that are used to generate the key’s values for each output. ROWS is a list of lists, each sublist specifying the values for a step. Values can be specified on their own (in which case they’re matched in order to the columns specified in the header) or by using Lisp’s traditional key/value notation.

By default, the pattern repeats infinitely, however it can be limited by providing a :repeats argument in the header specifying the number of repeats.

Example:

;; (ptrack (list :freq 440 :dur 1/4)
;; ’((100) ; play a note with a frequency of 100
;; :r ; rest for 1/4 beat
;; (:midinote 70 :dur 1/2) ; play a note at midinote 70 for 1/2 beat
;; (-) ; continue previous note for an additional 1/4 beat
;; (600 3/4) ; play a note with a frequency of 600 for 3/4 beat
;; :r ; rest for 1/4 beat
;; (750 :foo 3) ; play a note at frequency 750, dur 1/4, and additional :foo key with value 3
;; ))

See also: ‘pt’, ‘pcycles’, ‘pbind’

Package

cl-patterns.

Source

track.lisp.

Function: pts (pattern &optional dur)

Timestretch PATTERN so its total duration is DUR. Note that only the first ‘*max-pattern-yield-length*’ events from PATTERN are considered, and that they are calculated immediately at pstream creation time rather than lazily as the pstream yields.

Example:

;; (next-upto-n (pts (pbind :dur (pn 1 4)) 5))
;;
;; ;=> ((EVENT :DUR 5/4) (EVENT :DUR 5/4) (EVENT :DUR 5/4) (EVENT :DUR 5/4))

See also: ‘pfindur’, ‘psync’

Package

cl-patterns.

Source

patterns.lisp.

Function: pwalk (list step-pattern &optional direction-pattern start-pos)

"Walk" over the values in LIST by using the accumulated value of the outputs of STEP-PATTERN as the index. At the beginning of the pwalk and each time the start or end of the list is passed, the output of DIRECTION-PATTERN is taken and used as the multiplier for values from STEP-PATTERN. START-POS is the index in LIST for pwalk to take its first output from.

Example:

;; ;; using (pseq (list 1 -1)) as the DIRECTION-PATTERN causes the pwalk’s output to "ping-pong":
;; (next-n (pwalk (list 0 1 2 3) (pseq (list 1)) (pseq (list 1 -1))) 10)
;;
;; ;=> (0 1 2 3 2 1 0 1 2 3)

See also: ‘pindex’, ‘pbrown’, ‘paccum’

Package

cl-patterns.

Source

patterns.lisp.

Function: pwhite (&optional lo hi length)

Linearly-distributed random numbers between LO and HI, inclusive.

Example:

;; (next-upto-n (pwhite 0 10 16))
;; ;=> (7 2 4 5 7 10 4 8 10 2 3 5 9 2 5 4)

See also: ‘pexprand’, ‘pbrown’, ‘pgauss’, ‘prand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pwrand (list &optional weights length)

Yield random elements from LIST weighted by respective values from WEIGHTS.

Example:

;; (next-upto-n (pwrand ’(1 2 3) ’(7 5 3) 10))
;; ;=> (1 1 2 2 2 1 2 1 1 3)

See also: ‘prand’, ‘pxrand’, ‘pwxrand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pwrap (number &optional bottom top)

Syntax sugar for (pnary #’wrap ...).

See also: ‘pnary’, ‘mutility:wrap’

Package

cl-patterns.

Source

patterns.lisp.

Function: pwxrand (list &optional weights length)

Yield random elements from LIST weighted by respective values from WEIGHTS, never repeating equivalent values twice in a row. This is effectively ‘pxrand’ and ‘pwrand’ combined.

Example:

;; (next-upto-n (pwxrand ’(1 2 3) ’(7 5 3) 10))
;; ;=> (1 2 1 2 1 3 1 2 1 2)

See also: ‘prand’, ‘pxrand’, ‘pwrand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pxrand (list &optional length)

Yield random values from LIST, never repeating equal values twice in a row.

Example:

;; (next-upto-n (pxrand ’(1 2 3) 4))
;; ;=> (3 1 2 1)

See also: ‘prand’, ‘pwrand’, ‘pwxrand’

Package

cl-patterns.

Source

patterns.lisp.

Function: pyramid (sequence &optional pattern-type)

Return a new list whose elements have been reordered via one of 10 "counting" algorithms. This is based on and tested against SuperCollider’s Array.pyramid method.

Package

cl-patterns.

Source

utility.lisp.

Function: rate-freq (rate &optional base-freq)

Convert a playback rate RATE to a frequency, based on BASE-FREQ.

Package

cl-patterns.

Source

conversions.lisp.

Function: rate-midinote (rate &optional base-note)

Convert a playback rate to a midinote.

Package

cl-patterns.

Source

conversions.lisp.

Function: ratio-midi (ratio)

Convert a frequency ratio to a difference in MIDI note numbers.

Package

cl-patterns.

Source

conversions.lisp.

Function: remove-event-value (event key)

Removes KEY from EVENT.

Package

cl-patterns.

Source

event.lisp.

Function: rerange (input from-range to-range)

Remap INPUT from one range, specified by FROM-RANGE, to another range, specified by TO-RANGE.

Example:

;; (rerange 64 (list 0 127) (list 0 1)) ; map from [0..127] to [0..1]
;; => 0.503937

See also: ‘to-range’, ‘from-range’, ‘prerange’

Package

cl-patterns.

Source

utility.lisp.

Function: scale-midinotes (scale &key root octave)

Given a scale, return its midi note numbers. OCTAVE can be a number, a 2-element list denoting an octave range, or :all, for the full octave range (0-9).

Package

cl-patterns.

Source

scales.lisp.

Function: screen-size (&optional display-server)

Get the total dimensions of all monitors known by DISPLAY-SERVER.

Package

cl-patterns.

Source

patterns.lisp.

Function: split-event-by-lists (event)

Split an event up by any lists in its values. Also known as multichannel expansion.

Example:

;; (split-event-by-lists (event :foo 1 :bar (list 1 2) :baz (list 3 4 5)))
;;
;; => ((EVENT :FOO 1 :BAR 1 :BAZ 3)
;; (EVENT :FOO 1 :BAR 2 :BAZ 4)
;; (EVENT :FOO 1 :BAR 1 :BAZ 5))

See also: ‘multi-channel-funcall’, ‘combine-events-via-lists’, ‘combine-events’

Package

cl-patterns.

Source

event.lisp.

Function: start-clock-loop (&rest clock-initargs &key tempo force &allow-other-keys)

Convenience method to make a clock and start its loop in a new thread if one isn’t already started.

With FORCE, make a new clock and thread even if one already appears to be running.

See also: ‘clock-loop’, ‘*clock*’

Package

cl-patterns.

Source

clock.lisp.

Function: t-pstream (value &optional length)

Make a t-pstream object with the value VALUE.

Package

cl-patterns.

Source

patterns.lisp.

Function: t-pstream-p (object)

True if OBJECT is a ‘t-pstream’.

See also: ‘t-pstream’, ‘as-pstream’

Package

cl-patterns.

Source

patterns.lisp.

Function: task-pattern (task)

Attempt to get the pattern that TASK is playing. Returns nil if the pattern couldn’t be found.

See also: ‘pattern-tasks’, ‘clock-tasks’

Package

cl-patterns.

Source

clock.lisp.

Function: time-dur (time &optional tempo)

Convert TIME in seconds to duration in beats according to TEMPO in beats per second.

Package

cl-patterns.

Source

conversions.lisp.

Function: tone-matrix (tones &optional transformation)

Generate a tone matrix from TONES. Supports symbols t and e for 10 and 11, respectively, but only returns numbers. TRANSFORMATION can be :inversion, :retrograde, or :retrograde-inversion (or a 3-letter abbreviation of any of the above).

Package

cl-patterns.

Source

scales.lisp.

Function: transpose (freq &optional semitones octaves)

Transpose FREQ the specified number of SEMITONES and OCTAVES.

Package

cl-patterns.

Source

utility.lisp.

Function: unipolar-1-to-midi (number)

Convert the range 0..1 to 0..127.

Package

cl-patterns.

Source

conversions.lisp.

Function: unipolar-bipolar (number)

Convert a bipolar number (-1 to 1) to a unipolar number (0 to 1).

See also: ‘bipolar-unipolar’

Package

cl-patterns.

Source

conversions.lisp.


6.1.5 Generic functions

Generic Function: amp (object)

Volume in amplitude, from 0 to 1.

Package

cl-patterns.

Source

event.lisp.

Methods
Method: amp ((event event))
Generic Function: (setf amp) (event)
Package

cl-patterns.

Methods
Method: (setf amp) ((event event))
Source

event.lisp.

Generic Function: as-eseq (object)

Convert OBJECT to an ‘eseq’.

See also: ‘as-pstream’

Package

cl-patterns.

Source

eseq.lisp.

Methods
Method: as-eseq ((pattern pattern))
Method: as-eseq ((pstream pstream))
Method: as-eseq ((event event))
Method: as-eseq ((list list))
Method: as-eseq ((symbol symbol))
Generic Function: as-pstream (thing)

Return THING as a pstream object.

See also: ‘pattern-as-pstream’

Package

cl-patterns.

Source

patterns.lisp.

Methods
Method: as-pstream ((eseq eseq))
Source

eseq.lisp.

Method: as-pstream ((ptrack ptrack))
Source

track.lisp.

Method: as-pstream ((pcycles pcycles))
Source

cycles.lisp.

Method: as-pstream ((pbjorklund pbjorklund))
Source

bjorklund.lisp.

Method: as-pstream ((pmeta pmeta))
Source

pmeta.lisp.

Method: as-pstream ((pdef pdef))
Source

pdef.lisp.

Method: as-pstream ((ipstream ipstream))
Method: as-pstream ((ps ps))
Method: as-pstream ((pparchain pparchain))
Method: as-pstream ((pwalk pwalk))
Method: as-pstream ((pts pts))
Method: as-pstream ((pdrop pdrop))
Method: as-pstream ((pdelta pdelta))
Method: as-pstream ((pchain pchain))
Method: as-pstream ((psym psym))
Method: as-pstream ((prun prun))
Method: as-pstream ((pindex pindex))
Method: as-pstream ((pdurstutter pdurstutter))
Method: as-pstream ((psync psync))
Method: as-pstream ((pfindur pfindur))
Method: as-pstream ((pfin pfin))
Method: as-pstream ((parp parp))
Method: as-pstream ((pscratch pscratch))
Method: as-pstream ((phistory phistory))
Method: as-pstream ((pslide pslide))
Method: as-pstream ((prerange prerange))
Method: as-pstream ((pnary pnary))
Method: as-pstream ((ppatlace ppatlace))
Method: as-pstream ((ptrace ptrace))
Method: as-pstream ((pshuf pshuf))
Method: as-pstream ((pn pn))
Method: as-pstream ((protate protate))
Method: as-pstream ((plazy plazy))
Method: as-pstream ((pr pr))
Method: as-pstream ((pfunc pfunc))
Method: as-pstream ((pk pk))
Method: as-pstream ((pbind pbind-pstream))
Method: as-pstream ((pbind pbind))
Method: as-pstream ((pstream pstream))
Method: as-pstream :around (object)
Method: as-pstream ((pattern pattern))
Method: as-pstream (value)
Generic Function: backend-start (backend &rest args &key &allow-other-keys)

Start BACKEND’s server so it is ready to receive events. If BACKEND is the name of a backend rather than a ‘backend’ instance, first make an instance of the backend as if ‘make-backend’ was called, then call ‘backend-start’ on that.

See also: ‘backend-stop’, ‘backend-enabled-p’, ‘make-backend’

Package

cl-patterns.

Source

backend.lisp.

Methods
Method: backend-start :after ((backend backend) &key &allow-other-keys)
Method: backend-start ((backend backend) &key &allow-other-keys)
Method: backend-start ((name symbol) &rest args &key &allow-other-keys)
Generic Function: backend-stop (backend)

Stop BACKEND’s server if it is running.

See also: ‘backend-start’, ‘backend-enabled-p’

Package

cl-patterns.

Source

backend.lisp.

Methods
Method: backend-stop :after ((backend backend))
Method: backend-stop ((backend symbol))
Generic Function: beat (object)

Get the beat that OBJECT occurs on, relative to its context’s start. For example, for an ‘event’, the beat is relative to the start of its source pattern, while for a ‘pstream’ or clock object, the beat is the number of beats that have passed since its start.

See also: ‘tempo’

Package

cl-patterns.

Source

utility.lisp.

Methods
Reader Method: beat ((clock clock))

The number of beats that have elapsed since the creation of the clock.

Source

clock.lisp.

Target Slot

beat.

Method: beat ((task task))
Source

clock.lisp.

Reader Method: beat ((pstream pstream))

The number of beats that have elapsed since the start of the pstream.

Source

patterns.lisp.

Target Slot

beat.

Method: beat ((event event))
Source

event.lisp.

Method: beat ((eop (eql cl-patterns:eop)))
Method: beat ((null null))
Generic Function: (setf beat) (event)
Package

cl-patterns.

Methods
Writer Method: (setf beat) ((clock clock))

The number of beats that have elapsed since the creation of the clock.

Source

clock.lisp.

Target Slot

beat.

Method: (setf beat) ((event event))
Source

event.lisp.

Generic Function: bsubseq (object start-beat &optional end-beat)

"Beat subseq" - get a list of all events from OBJECT whose ‘beat’ is START-BEAT or above, and below END-BEAT.

See also: ‘events-in-range’

Package

cl-patterns.

Source

patterns.lisp.

Methods
Method: bsubseq ((eseq eseq) start-beat &optional end-beat)
Source

eseq.lisp.

Method: bsubseq ((list list) start-beat &optional end-beat)
Source

eseq.lisp.

Generic Function: chord (object)

Get a chord by name.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: chord ((chord chord))
Method: chord ((string string))
Method: chord ((symbol symbol))
Method: chord ((list list))
Generic Function: chord-indexes (chord)

The indexes of the notes from the scale that the chord is made up of.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: chord-indexes ((symbol symbol))
Reader Method: chord-indexes ((chord chord))

The indexes of the notes from the scale that the chord is made up of.

Target Slot

indexes.

Generic Writer: (setf chord-indexes) (object)
Package

cl-patterns.

Methods
Writer Method: (setf chord-indexes) ((chord chord))

The indexes of the notes from the scale that the chord is made up of.

Source

scales.lisp.

Target Slot

indexes.

Generic Function: chord-name (chord)

The octave ratio of the chord (i.e. what to multiply a pitch by to increase its octave by 1).

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: chord-name ((symbol symbol))
Reader Method: chord-name ((chord chord))

The full name of the chord.

Target Slot

name.

Generic Writer: (setf chord-name) (object)
Package

cl-patterns.

Methods
Writer Method: (setf chord-name) ((chord chord))

The full name of the chord.

Source

scales.lisp.

Target Slot

name.

Generic Function: chord-scale (chord)

The scale that the chord is derived from.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: chord-scale ((symbol symbol))
Reader Method: chord-scale ((chord chord))

The scale that the chord is derived from.

Target Slot

scale.

Generic Writer: (setf chord-scale) (object)
Package

cl-patterns.

Methods
Writer Method: (setf chord-scale) ((chord chord))

The scale that the chord is derived from.

Source

scales.lisp.

Target Slot

scale.

Generic Function: db (object)

Volume in decibels (dB).

Package

cl-patterns.

Source

event.lisp.

Methods
Method: db ((event event))
Generic Function: (setf db) (event)
Package

cl-patterns.

Methods
Method: (setf db) ((event event))
Source

event.lisp.

Generic Function: delta (object)

The number of beats between the start of this event and the start of the next one.

See also: ‘dur’, ‘sustain’

Package

cl-patterns.

Source

event.lisp.

Methods
Method: delta ((event event))
Generic Function: (setf delta) (event)
Package

cl-patterns.

Methods
Method: (setf delta) ((event event))
Source

event.lisp.

Generic Function: dur (object)

The total duration of the note, in beats.

See also: ‘delta’, ‘legato’

Package

cl-patterns.

Source

event.lisp.

Methods
Method: dur ((eseq eseq))
Source

eseq.lisp.

Method: dur ((pattern pattern))
Source

patterns.lisp.

Method: dur ((event event))
Generic Function: (setf dur) (event)
Package

cl-patterns.

Methods
Method: (setf dur) ((event event))
Source

event.lisp.

Generic Function: end (object)

End a task; it will stop when its current loop completes.

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: end ((item task))
Source

clock.lisp.

Method: end ((pdef pdef))
Source

pdef.lisp.

Method: end ((list list))
Method: end ((symbol symbol))
Method: end (object)
Generic Function: end-quant (object)

The end-quant of OBJECT; a list representing when OBJECT is allowed to end playing or when a ‘pdef’ is allowed to swap to a new definition if it has been redefined. Note that if ‘end-quant’ is not set (the default), the pattern can only end or swap when the pattern itself ends (i.e. when it yields ‘eop’).

See ‘quant’ for more information on quants and a description of acceptable values.

See also: ‘quant’, ‘play-quant’, ‘next-beat-for-quant’, ‘beat’, ‘end’, ‘pdef’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: end-quant ((eseq eseq))
Source

eseq.lisp.

Method: end-quant ((pdef pdef))
Source

pdef.lisp.

Reader Method: end-quant ((pattern pattern))
Source

patterns.lisp.

Target Slot

end-quant.

Generic Function: (setf end-quant) (object)
Package

cl-patterns.

Methods
Method: (setf end-quant) ((eseq eseq))
Source

eseq.lisp.

Writer Method: (setf end-quant) ((pattern pattern))
Source

patterns.lisp.

Target Slot

end-quant.

Generic Function: ended-p (pstream)

Returns t if PSTREAM has no more outputs, or nil if outputs remain to be yielded.

Example:

;; (defparameter *pstr* (as-pstream (pseq ’(1 2) 1)))
;; (next *pstr*) ;=> 1
;; (ended-p *pstr*) ;=> NIL
;; (next *pstr*) ;=> 2
;; (ended-p *pstr*) ;=> NIL
;; (next *pstr*) ;=> NIL
;; (ended-p *pstr*) ;=> T

See also: ‘eop-p’, ‘last-output’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: ended-p ((pstream pstream))
Source

patterns.lisp.

Generic Function: eop-p (object)

True if OBJECT indicates the end of a pstream’s outputs.

See also: ‘ended-p’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: eop-p ((event event))
Source

event.lisp.

Method: eop-p ((symbol symbol))
Method: eop-p (object)
Generic Function: eseq-add (eseq event)

Add EVENT to ESEQ. If EVENT doesn’t have a ‘beat’, it is placed after the last event in ESEQ.

See also: ‘eseq-remove’

Package

cl-patterns.

Source

eseq.lisp.

Methods
Method: eseq-add ((eseq eseq) (events list))
Method: eseq-add ((eseq eseq) (event event))
Generic Reader: eseq-events (object)

The list of events in the ‘eseq’.

Note that eseq’s events slot should not be modified directly as it expects its events to be kept in order. Instead, use ‘eseq-add’, ‘eseq-remove’, or setf ‘eseq-events’.

Package

cl-patterns.

Source

eseq.lisp.

Methods
Reader Method: eseq-events ((eseq eseq))

automatically generated reader method

Target Slot

events.

Generic Function: (setf eseq-events) (eseq)
Package

cl-patterns.

Methods
Method: (setf eseq-events) ((eseq eseq))
Source

eseq.lisp.

Generic Function: eseq-remove (eseq event)

Remove EVENT from ESEQ.

See also: ‘eseq-add’

Package

cl-patterns.

Source

eseq.lisp.

Methods
Method: eseq-remove ((eseq eseq) (events list))
Method: eseq-remove ((eseq eseq) (index integer))
Method: eseq-remove ((eseq eseq) (event event))
Generic Reader: event-plist (event)

The raw plist containing the key/value pairs of the event.

Package

cl-patterns.

Source

event.lisp.

Methods
Reader Method: event-plist ((event event))

The plist containing all of the event’s keys and values.

Target Slot

event-plist.

Generic Function: freq (object)

Frequency of the note, in Hz.

See also: ‘rate’, ‘midinote’, ‘degree’

Package

cl-patterns.

Source

event.lisp.

Methods
Method: freq ((event event))
Generic Function: (setf freq) (event)
Package

cl-patterns.

Methods
Method: (setf freq) ((event event))
Source

event.lisp.

Generic Function: instrument (object)

The instrument or synth to trigger.

Package

cl-patterns.

Source

event.lisp.

Methods
Method: instrument ((event event))
Generic Function: (setf instrument) (event)
Package

cl-patterns.

Methods
Method: (setf instrument) ((event event))
Source

event.lisp.

Generic Function: ipstream-insert (ipstream pattern &optional start-beat)

Insert PATTERN into IPSTREAM at START-BEAT. START-BEAT defaults to the ipstream’s current beat.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Method: ipstream-insert ((ipstream ipstream-pstream) pattern &optional start-beat)
Generic Function: launch (object)

Play a new copy of OBJECT on the clock. Unlike ‘play’, calling this method on a ‘pdef’ will always start a new copy of its pattern instead of the pdef itself.

See also: ‘play’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: launch ((pdef pdef))
Source

pdef.lisp.

Method: launch ((pattern pattern))
Source

patterns.lisp.

Method: launch ((list list))
Method: launch ((symbol symbol))
Method: launch (object)
Generic Function: legato (object)

How long the note should be held, in beats, as a factor of its total duration (‘dur’).

See also: ‘sustain’, ‘dur’

Package

cl-patterns.

Source

event.lisp.

Methods
Method: legato ((event event))
Generic Function: (setf legato) (event)
Package

cl-patterns.

Methods
Method: (setf legato) ((event event))
Source

event.lisp.

Generic Function: loop-p (object)

Whether or not OBJECT should play again after it ends.

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: loop-p ((task task))
Source

clock.lisp.

Method: loop-p ((eseq eseq))
Source

eseq.lisp.

Method: loop-p ((pdef pdef))
Source

pdef.lisp.

Method: loop-p ((pstream pstream))
Source

patterns.lisp.

Method: loop-p ((pattern pattern))
Source

patterns.lisp.

Method: loop-p ((event event))
Source

event.lisp.

Generic Function: (setf loop-p) (event)
Package

cl-patterns.

Methods
Method: (setf loop-p) ((eseq eseq))
Source

eseq.lisp.

Method: (setf loop-p) ((pattern pattern))
Source

patterns.lisp.

Method: (setf loop-p) ((event event))
Source

event.lisp.

Generic Function: make-backend (backend &rest rest &key &allow-other-keys)

Make a backend of the specified type.

See also: ‘backend-start’

Package

cl-patterns.

Source

backend.lisp.

Methods
Method: make-backend (backend &rest rest &key &allow-other-keys)
Generic Function: midinote (object)

MIDI note number of the note (0-127).

Package

cl-patterns.

Source

event.lisp.

Methods
Method: midinote ((event event))
Generic Function: (setf midinote) (event)
Package

cl-patterns.

Methods
Method: (setf midinote) ((event event))
Source

event.lisp.

Generic Function: next (pattern)

Get the next value of a pstream, function, or other object, advancing the pstream forward in the process.

See also: ‘next-n’, ‘next-upto-n’, ‘peek’

Package

cl-patterns.

Source

patterns.lisp.

Method Combination

pattern.

Methods
Method: next ((eseq eseq-pstream))
Source

eseq.lisp.

Method: next ((ptrack ptrack-pstream))
Source

track.lisp.

Method: next ((pcycles pcycles-pstream))
Source

cycles.lisp.

Method: next ((pattern pbjorklund-pstream))
Source

bjorklund.lisp.

Method: next ((pmeta pmeta-pstream))
Source

pmeta.lisp.

Method: next ((pdef pdef-pstream))
Source

pdef.lisp.

Method: next ((pmouse pmouse-pstream))
Method: next ((pfilter pfilter-pstream))
Method: next ((ipstream ipstream-pstream))
Method: next ((ps-pstream ps-pstream))
Method: next ((paccum paccum-pstream))
Method: next ((paclump paclump-pstream))
Method: next ((pclump pclump-pstream))
Method: next ((pparchain pparchain-pstream))
Method: next ((pwalk pwalk-pstream))
Method: next ((pts pts-pstream))
Method: next ((ppar ppar-pstream))
Method: next ((pdrop pdrop-pstream))
Method: next ((pdelta pdelta-pstream))
Method: next ((pdiff pdiff-pstream))
Method: next ((pchain pchain-pstream))
Method: next ((psym psym-pstream))
Method: next ((prun prun-pstream))
Method: next ((pindex pindex-pstream))
Method: next ((ptime ptime-pstream))
Method: next ((pbeat* pbeat*-pstream))
Method: next ((pbeat pbeat-pstream))
Method: next ((pdurstutter pdurstutter-pstream))
Method: next ((psync psync-pstream))
Method: next ((pfindur pfindur-pstream))
Method: next ((pfin pfin-pstream))
Method: next ((parp parp-pstream))
Method: next ((pif pif-pstream))
Method: next ((pscratch pscratch-pstream))
Method: next ((phistory phistory-pstream))
Method: next ((pslide pslide-pstream))
Method: next ((prerange prerange-pstream))
Method: next ((pnary pnary-pstream))
Method: next ((ppatlace ppatlace-pstream))
Method: next ((place place-pstream))
Method: next ((ptrace ptrace-pstream))
Method: next ((pgeom pgeom-pstream))
Method: next ((pseries pseries-pstream))
Method: next ((pgauss pgauss-pstream))
Method: next ((pexprand pexprand-pstream))
Method: next ((pbrown pbrown-pstream))
Method: next ((pwhite pwhite-pstream))
Method: next ((pshuf pshuf-pstream))
Method: next ((pn pn-pstream))
Method: next ((protate protate-pstream))
Method: next ((plazy plazy-pstream))
Method: next ((pr pr-pstream))
Method: next ((pfunc pfunc-pstream))
Method: next ((pwxrand pwxrand-pstream))
Method: next ((pwrand pwrand-pstream))
Method: next ((pxrand pxrand-pstream))
Method: next ((prand prand-pstream))
Method: next ((pk pk-pstream))
Method: next ((pser pser-pstream))
Method: next ((pseq pseq-pstream))
Method: next ((pbind pbind-pstream))
Method: next ((t-pstream t-pstream))
Method: next :around ((pstream pstream))
Method: next ((pstream pstream))
Method: next ((function function))
Method: next ((pattern pattern))
Method: next (object)
Generic Function: pan (object)

Stereo panning, where -1 is fully left, 1 is fully right, and 0 is center.

Package

cl-patterns.

Source

event.lisp.

Methods
Method: pan ((event event))
Generic Function: (setf pan) (event)
Package

cl-patterns.

Methods
Method: (setf pan) ((event event))
Source

event.lisp.

Generic Function: pattern-metadata (pattern &optional key)

Get the value of PATTERN’s metadata for KEY. Returns true as a second value if the metadata had an entry for KEY, or nil if it did not.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Method: pattern-metadata ((eseq eseq) &optional key)
Source

eseq.lisp.

Method: pattern-metadata ((pattern pattern) &optional key)
Generic Reader: pattern-source (pattern)

The source object that this object was created from. For example, for a ‘pstream’, this would be the pattern that ‘as-pstream’ was called on.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Reader Method: pattern-source ((pattern pattern))

The source object that this object was created from. For example, for a ‘pstream’, this would be the pattern that ‘as-pstream’ was called on.

Target Slot

source.

Generic Writer: (setf pattern-source) (object)
Package

cl-patterns.

Methods
Writer Method: (setf pattern-source) ((pattern pattern))

The source object that this object was created from. For example, for a ‘pstream’, this would be the pattern that ‘as-pstream’ was called on.

Source

patterns.lisp.

Target Slot

source.

Generic Function: pdef-name (pdef)

The name ("key") of PDEF.

Package

cl-patterns.

Source

pdef.lisp.

Methods
Method: pdef-name ((pbind pbind))
Method: pdef-name ((null null))
Method: pdef-name ((symbol symbol))
Reader Method: pdef-name ((pdef pdef))

automatically generated reader method

Target Slot

name.

Generic Function: (setf pdef-name) (pdef)
Package

cl-patterns.

Methods
Method: (setf pdef-name) ((symbol symbol))
Source

pdef.lisp.

Method: (setf pdef-name) ((pdef pdef))
Source

pdef.lisp.

Generic Function: pdef-pattern (pdef)

The pattern that PDEF points to.

Package

cl-patterns.

Source

pdef.lisp.

Methods
Method: pdef-pattern ((null null))
Method: pdef-pattern ((symbol symbol))
Reader Method: pdef-pattern ((pdef pdef))

automatically generated reader method

Target Slot

pattern.

Generic Writer: (setf pdef-pattern) (object)
Package

cl-patterns.

Methods
Writer Method: (setf pdef-pattern) ((pdef pdef))

automatically generated writer method

Source

pdef.lisp.

Target Slot

pattern.

Generic Function: pdef-pstream (pdef)

The currently-playing pstream of PDEF’s pattern.

Package

cl-patterns.

Source

pdef.lisp.

Methods
Method: pdef-pstream ((null null))
Method: pdef-pstream ((symbol symbol))
Reader Method: pdef-pstream ((pdef pdef))

automatically generated reader method

Target Slot

pstream.

Generic Function: (setf pdef-pstream) (object)
Package

cl-patterns.

Methods
Method: (setf pdef-pstream) ((symbol symbol))
Source

pdef.lisp.

Writer Method: (setf pdef-pstream) ((pdef pdef))

automatically generated writer method

Source

pdef.lisp.

Target Slot

pstream.

Generic Function: pdef-task (pdef)

The task that PDEF was last being played in.

Package

cl-patterns.

Source

pdef.lisp.

Methods
Method: pdef-task ((null null))
Method: pdef-task ((symbol symbol))
Reader Method: pdef-task ((pdef pdef))

automatically generated reader method

Target Slot

task.

Generic Writer: (setf pdef-task) (object)
Package

cl-patterns.

Methods
Writer Method: (setf pdef-task) ((pdef pdef))

automatically generated writer method

Source

pdef.lisp.

Target Slot

task.

Generic Function: peek (pattern)

"Peek" at the next value of a pstream, without advancing its current position.

See also: ‘next’, ‘peek-n’, ‘peek-upto-n’

Package

cl-patterns.

Source

patterns.lisp.

Methods
Method: peek ((pattern pattern))
Method: peek ((pstream pstream))
Generic Function: play (object)

Play an object (typically an event or pattern).

See also: ‘launch’, ‘stop’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: play ((pdef pdef))
Source

pdef.lisp.

Method: play ((pattern pattern))
Source

patterns.lisp.

Method: play ((event event))
Source

event.lisp.

Method: play ((list list))
Method: play ((symbol symbol))
Generic Function: play-quant (object)

The play-quant of OBJECT; a list representing when OBJECT is allowed to begin playing. Defaults to (1).

See ‘quant’ for more information on quants and a description of acceptable values.

See also: ‘quant’, ‘end-quant’, ‘next-beat-for-quant’, ‘beat’, ‘play’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: play-quant ((eseq eseq))
Source

eseq.lisp.

Method: play-quant ((pdef pdef))
Source

pdef.lisp.

Method: play-quant ((pattern pattern))
Source

patterns.lisp.

Method: play-quant ((event event))
Source

event.lisp.

Generic Function: (setf play-quant) (event)
Package

cl-patterns.

Methods
Method: (setf play-quant) ((eseq eseq))
Source

eseq.lisp.

Method: (setf play-quant) ((pattern pattern))
Source

patterns.lisp.

Method: (setf play-quant) ((event event))
Source

event.lisp.

Generic Function: playing-p (object &optional clock)

Whether OBJECT is playing.

See also: ‘play-or-stop’, ‘play-or-end’, ‘playing-pdefs’, ‘playing-nodes’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: playing-p ((task task) &optional clock)
Source

clock.lisp.

Method: playing-p ((pdef pdef) &optional clock)
Source

pdef.lisp.

Method: playing-p ((pattern pattern) &optional clock)
Source

patterns.lisp.

Method: playing-p ((list list) &optional clock)
Method: playing-p ((symbol symbol) &optional clock)
Generic Reader: pstream-count (pattern)

The number of pstreams that have been made of this pattern.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Reader Method: pstream-count ((pstream pstream))

How many times a pstream was made of this pstream’s source prior to this pstream. For example, if it was the first time ‘as-pstream’ was called on the pattern, this will be 0.

Target Slot

pstream-count.

Reader Method: pstream-count ((pattern pattern))

The number of pstreams that have been made of this pattern.

Target Slot

pstream-count.

Generic Writer: (setf pstream-count) (object)
Package

cl-patterns.

Methods
Writer Method: (setf pstream-count) ((pstream pstream))

How many times a pstream was made of this pstream’s source prior to this pstream. For example, if it was the first time ‘as-pstream’ was called on the pattern, this will be 0.

Source

patterns.lisp.

Target Slot

pstream-count.

Writer Method: (setf pstream-count) ((pattern pattern))

The number of pstreams that have been made of this pattern.

Source

patterns.lisp.

Target Slot

pstream-count.

Generic Function: ptrack-cell (ptrack row key &key if-does-not-exist)

Get the value of a cell from ptrack (i.e. the value at that location if specified, or the generated value if not specified). Can also be used on a ptrack-pstream to get the generated values from it. Returns three values:

- the value of the cell
- the name of the key that the specified KEY was derived from, or nil if it was not found
- t if the output was taken from the row itself, or nil if it was derived from the header

See also: ‘ptrack’, ‘ptrack-row’

Package

cl-patterns.

Source

track.lisp.

Methods
Method: ptrack-cell ((ptrack ptrack-pstream) row key &key if-does-not-exist)
Method: ptrack-cell ((ptrack ptrack) row key &key if-does-not-exist)
Generic Function: (setf ptrack-cell) (ptrack row key &key)
Package

cl-patterns.

Source

track.lisp.

Methods
Method: (setf ptrack-cell) (ptrack row key &key)
Generic Function: ptrack-row (ptrack row &key if-does-not-exist)

Get the plist for ROW from PTRACK.

Package

cl-patterns.

Source

track.lisp.

Methods
Method: ptrack-row ((ptrack ptrack) row &key if-does-not-exist)
Generic Function: (setf ptrack-row) (ptrack row &key)
Package

cl-patterns.

Methods
Method: (setf ptrack-row) ((ptrack ptrack) row &key)
Source

track.lisp.

Generic Function: ptrack-rows (ptrack)

Get the list of rows from PTRACK.

Package

cl-patterns.

Source

track.lisp.

Methods
Method: ptrack-rows (ptrack)
Generic Function: quant (object)

The quant of OBJECT; a list representing when OBJECT is allowed to begin playing (‘play-quant’), end playing (‘end-quant’), or when a ‘pdef’ is allowed to swap to its new definition (‘end-quant’). ‘quant’ will return the value of ‘play-quant’ as its first value and ‘end-quant’ as its second, and sets both ‘play-quant’ and ‘end-quant’ when it is setf.

A quant value takes the form (divisor phase offset) where all provided elements are numbers. Only the first element is required.

- "divisor" is the divisor to quantize the clock to. The next time (mod (beat *clock*) divisor) is 0 is when OBJECT will start playing.
- "phase" is the number of beats to add on to the position determined by "divisor".
- "offset" is the number of seconds to add on to the position determined by "divisor" and "phase".

For example, a quant of (4) means it can start on any clock beat that is divisible by 4 (0, 4, 8, etc). A quant of (4 2) means the pstream can start 2 beats after any beat divisible by 4 (2, 6, 10, etc). And a quant of (4 0 1) means that the pstream can start 1 second after any beat that is divisible by 4.

See also: ‘play-quant’, ‘end-quant’, ‘next-beat-for-quant’, ‘beat’, ‘play’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: quant ((event event))
Source

event.lisp.

Method: quant (object)
Generic Function: (setf quant) (object)
Package

cl-patterns.

Methods
Method: (setf quant) ((event event))
Source

event.lisp.

Method: (setf quant) (object)
Source

utility.lisp.

Generic Function: rate (object)

Playback rate, i.e. for playing back sound buffers. 1 is normal speed, 2 is twice as fast, 0.5 half as fast, etc.

Package

cl-patterns.

Source

event.lisp.

Methods
Method: rate ((event event))
Generic Function: (setf rate) (event)
Package

cl-patterns.

Methods
Method: (setf rate) ((event event))
Source

event.lisp.

Generic Function: render (object output &key backend tempo max-length max-pattern-yield-length duration max-duration max-output-duration &allow-other-keys)

Render a pattern or other object as audio or other format. OUTPUT is what the pattern should be rendered as. It can be one of the following values:

- A string or pathname - Output file name (file format is determined by the file extension).
- :file - Render to a file in the ‘*cl-patterns-temporary-directory*’.
- :buffer - Render to a buffer in memory.
- :bdef - Render to a ‘bdef:bdef’ buffer object in memory. This output type is only available if the bdef library is loaded, and falls back to :buffer if it is not.
- :score - Render as a "score" in memory, i.e. the sequence type supported by the backend.
- :eseq - Make an ‘eseq’ from the pattern. Effectively defers to ‘as-eseq’.
- :pstream - Make a ‘pstream’ from the pattern. Effectively defers to ‘as-pstream’.
- :list - Get a list of up to the first MAX-LENGTH outputs from this object using ‘next-upto-n’.

The following additional keyword arguments are also supported, depending on the output type:

- BACKEND - The backend to render with. Defaults to the first applicable backend, based on (in descending order of priority): the first event’s :backend key, the first event’s :instrument, or the first enabled backend that supports the specified output type. - OUTPUT-FILENAME - The filename to write the rendered file to (when rendering to a file).
- TEMPO - The tempo of the result in beats per second. Defaults to ‘*clock*”s current tempo.
- MAX-LENGTH - Maximum number of outputs to grab from the source pattern. Must be an integer (cannot be :inf). Defaults to ‘*max-pattern-yield-length*’.
- DURATION - The total duration of the output in seconds.
- MAX-DURATION - The maximum duration of the output in seconds. Defaults to infinite, in which case the pattern is limited by MAX-PATTERN-YIELD-LENGTH.

See also: ‘as-eseq’

Package

cl-patterns.

Source

render.lisp.

Methods
Method: render ((event event) output &rest args &key &allow-other-keys)
Method: render (object (output-filename pathname) &rest args &key &allow-other-keys)
Method: render (object (output-filename string) &rest args &key &allow-other-keys)
Method: render (object (output (eql :score)) &rest args &key &allow-other-keys)
Method: render (object (output (eql :file)) &rest args &key &allow-other-keys)
Method: render (object (output (eql :buffer)) &rest args &key &allow-other-keys)
Method: render (object (output (eql :list)) &key max-length)
Method: render (object (output (eql :pstream)) &key)
Method: render (object (output (eql :eseq)) &key)
Generic Function: rest-p (object)

Whether or not something is a rest or a rest-representing object (i.e. :rest, :r, or a rest event).

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: rest-p ((prest prest))
Source

patterns.lisp.

Method: rest-p ((event event))
Source

event.lisp.

Method: rest-p (this)
Method: rest-p ((symbol symbol))
Generic Function: (setf rest-p) (event)
Package

cl-patterns.

Methods
Method: (setf rest-p) ((event event))
Source

event.lisp.

Generic Function: scale (object)

Get either a musical scale object by its name, or get the name of the scale of an event.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: scale ((event event))
Source

event.lisp.

Method: scale ((scale scale))
Method: scale ((string string))
Method: scale ((symbol symbol))
Generic Function: (setf scale) (event)
Package

cl-patterns.

Methods
Method: (setf scale) ((event event))
Source

event.lisp.

Generic Function: scale-name (scale)

The full name of the scale.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: scale-name ((symbol symbol))
Reader Method: scale-name ((scale scale))

The full name of the scale.

Target Slot

name.

Generic Writer: (setf scale-name) (object)
Package

cl-patterns.

Methods
Writer Method: (setf scale-name) ((scale scale))

The full name of the scale.

Source

scales.lisp.

Target Slot

name.

Generic Function: scale-notes (scale)

The degrees of the scale.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: scale-notes ((symbol symbol))
Reader Method: scale-notes ((scale scale))

The notes of the scale.

Target Slot

notes.

Generic Writer: (setf scale-notes) (object)
Package

cl-patterns.

Methods
Writer Method: (setf scale-notes) ((scale scale))

The notes of the scale.

Source

scales.lisp.

Target Slot

notes.

Generic Function: scale-steps-per-octave (scale)

The number of pitches per octave in the scale’s ‘tuning’.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: scale-steps-per-octave ((symbol symbol))
Method: scale-steps-per-octave ((scale scale))
Generic Function: scale-tuning (scale)

The scale’s ‘tuning’.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: scale-tuning ((symbol symbol))
Method: scale-tuning ((scale scale))
Generic Writer: (setf scale-tuning) (object)
Package

cl-patterns.

Methods
Writer Method: (setf scale-tuning) ((scale scale))

The scale’s ‘tuning’.

Source

scales.lisp.

Target Slot

tuning.

Generic Function: stop (object)

Immediately stop a playing object (typically a pattern, pdef, task, or node). If OBJECT is T, stop all playing patterns and nodes.

See also: ‘end’, ‘play’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: stop ((task task))
Source

clock.lisp.

Method: stop ((pdef pdef))
Source

pdef.lisp.

Method: stop ((null null))
Method: stop ((list list))
Method: stop ((symbol symbol))
Method: stop ((object (eql t)))
Generic Function: sustain (object)

How long the note should be held, in beats.

See also: ‘legato’, ‘delta’

Package

cl-patterns.

Source

event.lisp.

Methods
Method: sustain ((event event))
Generic Function: (setf sustain) (event)
Package

cl-patterns.

Methods
Method: (setf sustain) ((event event))
Source

event.lisp.

Generic Reader: t-pstream-length (object)

The number of times to yield the value.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Reader Method: t-pstream-length ((t-pstream t-pstream))

The number of times to yield the value.

Target Slot

length.

Generic Writer: (setf t-pstream-length) (object)
Package

cl-patterns.

Methods
Writer Method: (setf t-pstream-length) ((t-pstream t-pstream))

The number of times to yield the value.

Source

patterns.lisp.

Target Slot

length.

Generic Reader: t-pstream-value (object)

The value that is yielded by the t-pstream.

Package

cl-patterns.

Source

patterns.lisp.

Methods
Reader Method: t-pstream-value ((t-pstream t-pstream))

The value that is yielded by the t-pstream.

Target Slot

value.

Generic Writer: (setf t-pstream-value) (object)
Package

cl-patterns.

Methods
Writer Method: (setf t-pstream-value) ((t-pstream t-pstream))

The value that is yielded by the t-pstream.

Source

patterns.lisp.

Target Slot

value.

Generic Function: tempo (object)

Get the tempo of OBJECT in beats per second. If OBJECT is a number, set the tempo of ‘*clock*’ to that number.

See also: ‘beat’

Package

cl-patterns.

Source

utility.lisp.

Methods
Method: tempo ((number number))
Source

clock.lisp.

Reader Method: tempo ((clock clock))

The tempo of the clock, in beats per second.

Source

clock.lisp.

Target Slot

tempo.

Method: tempo ((event event))
Source

event.lisp.

Method: tempo ((symbol symbol))
Generic Function: (setf tempo) (event)
Package

cl-patterns.

Methods
Method: (setf tempo) ((clock clock))
Source

clock.lisp.

Method: (setf tempo) ((event event))
Source

event.lisp.

Generic Function: tuning (object)

Get a tuning by name.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: tuning ((tuning tuning))
Method: tuning ((string string))
Method: tuning ((symbol symbol))
Generic Function: tuning-name (tuning)

The full name of the tuning.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: tuning-name ((symbol symbol))
Reader Method: tuning-name ((tuning tuning))

The full name of the tuning.

Target Slot

name.

Generic Writer: (setf tuning-name) (object)
Package

cl-patterns.

Methods
Writer Method: (setf tuning-name) ((tuning tuning))

The full name of the tuning.

Source

scales.lisp.

Target Slot

name.

Generic Function: tuning-octave-ratio (tuning)

The octave ratio of the tuning (i.e. what to multiply a pitch by to increase its octave by 1).

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: tuning-octave-ratio ((symbol symbol))
Reader Method: tuning-octave-ratio ((tuning tuning))

The octave ratio of the tuning (i.e. what to multiply a pitch by to increase its octave by 1).

Target Slot

octave-ratio.

Generic Writer: (setf tuning-octave-ratio) (object)
Package

cl-patterns.

Methods
Writer Method: (setf tuning-octave-ratio) ((tuning tuning))

The octave ratio of the tuning (i.e. what to multiply a pitch by to increase its octave by 1).

Source

scales.lisp.

Target Slot

octave-ratio.

Generic Function: tuning-pitches (tuning)

The actual semitone values of the tuning.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: tuning-pitches ((symbol symbol))
Reader Method: tuning-pitches ((tuning tuning))

The actual semitone values of the tuning.

Target Slot

pitches.

Generic Writer: (setf tuning-pitches) (object)
Package

cl-patterns.

Methods
Writer Method: (setf tuning-pitches) ((tuning tuning))

The actual semitone values of the tuning.

Source

scales.lisp.

Target Slot

pitches.

Generic Function: tuning-steps-per-octave (tuning)

The number of pitches per octave in the tuning.

Package

cl-patterns.

Source

scales.lisp.

Methods
Method: tuning-steps-per-octave ((symbol symbol))
Method: tuning-steps-per-octave ((tuning tuning))

6.1.6 Standalone methods

Method: adjust-sequence ((this pstream) length &key initial-element initial-contents)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: describe-object ((chord chord) stream)
Source

scales.lisp.

Method: elt ((this scale) index)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: elt ((this tuning) index)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: elt ((this chord) index)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: (setf elt) ((this pstream) index)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: elt ((this pstream) index)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: emptyp ((this scale))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: emptyp ((this tuning))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: emptyp ((this chord))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: emptyp ((this pstream))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: initialize-instance :after ((backend backend) &key &allow-other-keys)
Source

backend.lisp.

Method: initialize-instance :after ((pwxrand pwxrand) &key)
Source

patterns.lisp.

Method: initialize-instance :after ((pxrand pxrand) &key)
Source

patterns.lisp.

Method: initialize-instance :after ((pattern pattern) &key)
Source

patterns.lisp.

Method: initialize-instance :after ((pfunc pfunc) &key)
Source

patterns.lisp.

Method: initialize-instance :after ((pstream pstream) &key)
Source

patterns.lisp.

Method: initialize-instance :before ((pstream pstream) &key)
Source

patterns.lisp.

Method: keys ((pbind pbind))
Package

mutility.

Source

patterns.lisp.

Method: keys ((pdef pdef))
Package

mutility.

Source

pdef.lisp.

Method: keys ((event event))
Package

mutility.

Source

event.lisp.

Method: length ((this scale))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: length ((this tuning))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: length ((this chord))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: length ((this pstream))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: length ((eseq eseq))
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: make-sequence-like ((this pstream) length &key initial-element initial-contents)
Package

sb-sequence.

Source

extensions/sequence.lisp.

Method: print-object ((ptime ptime) stream)
Source

patterns.lisp.

Method: print-object ((ppatlace ppatlace) stream)
Source

patterns.lisp.

Method: print-object ((place place) stream)
Source

patterns.lisp.

Method: print-object ((ptrack ptrack) stream)
Source

track.lisp.

Method: print-object ((ipstream ipstream) stream)
Source

patterns.lisp.

Method: print-object ((pclump pclump) stream)
Source

patterns.lisp.

Method: print-object ((pindex pindex) stream)
Source

patterns.lisp.

Method: print-object ((pser pser) stream)
Source

patterns.lisp.

Method: print-object ((pdurstutter pdurstutter) stream)
Source

patterns.lisp.

Method: print-object ((pwxrand pwxrand) stream)
Source

patterns.lisp.

Method: print-object ((prand prand) stream)
Source

patterns.lisp.

Method: print-object ((plazy plazy) stream)
Source

patterns.lisp.

Method: print-object ((pgauss pgauss) stream)
Source

patterns.lisp.

Method: print-object ((pdef pdef-pstream) stream)
Source

pdef.lisp.

Method: print-object ((pbind pbind) stream)
Source

patterns.lisp.

Method: print-object ((paclump paclump) stream)
Source

patterns.lisp.

Method: print-object ((pr pr) stream)
Source

patterns.lisp.

Method: print-object ((protate protate) stream)
Source

patterns.lisp.

Method: print-object ((pmouse pmouse) stream)
Source

patterns.lisp.

Method: print-object ((parp parp) stream)
Source

patterns.lisp.

Method: print-object ((pxrand pxrand) stream)
Source

patterns.lisp.

Method: print-object ((pdef pdef) stream)
Source

pdef.lisp.

Method: print-object ((pslide pslide) stream)
Source

patterns.lisp.

Method: print-object ((paccum paccum) stream)
Source

patterns.lisp.

Method: print-object ((pgeom pgeom) stream)
Source

patterns.lisp.

Method: print-object ((pn pn) stream)
Source

patterns.lisp.

Method: print-object ((ppar ppar) stream)
Source

patterns.lisp.

Method: print-object ((pshuf pshuf) stream)
Source

patterns.lisp.

Method: print-object ((pmeta pmeta) stream)
Source

pmeta.lisp.

Method: print-object ((pfunc pfunc) stream)
Source

patterns.lisp.

Method: print-object ((psync psync) stream)
Source

patterns.lisp.

Method: print-object ((scale scale) stream)
Source

scales.lisp.

Method: print-object ((phistory phistory) stream)
Source

patterns.lisp.

Method: print-object ((pseq pseq) stream)
Source

patterns.lisp.

Method: print-object ((pdrop pdrop) stream)
Source

patterns.lisp.

Method: print-object ((pbind pbind-pstream) stream)
Source

patterns.lisp.

Method: print-object ((pwalk pwalk) stream)
Source

patterns.lisp.

Method: print-object ((pcycles pcycles) stream)
Source

cycles.lisp.

Method: print-object ((pparchain pparchain) stream)
Source

patterns.lisp.

Method: print-object ((pwhite pwhite) stream)
Source

patterns.lisp.

Method: print-object ((pbeat* pbeat*) stream)
Source

patterns.lisp.

Method: print-object ((prerange prerange) stream)
Source

patterns.lisp.

Method: print-object ((pfindur pfindur) stream)
Source

patterns.lisp.

Method: print-object ((prest prest) stream)
Source

patterns.lisp.

Method: print-object ((pseries pseries) stream)
Source

patterns.lisp.

Method: print-object ((tuning tuning) stream)
Source

scales.lisp.

Method: print-object ((pbrown pbrown) stream)
Source

patterns.lisp.

Method: print-object ((pwrand pwrand) stream)
Source

patterns.lisp.

Method: print-object ((item event) stream)
Source

event.lisp.

Method: print-object ((psym psym) stream)
Source

patterns.lisp.

Method: print-object ((pk pk) stream)
Source

patterns.lisp.

Method: print-object ((pfin pfin) stream)
Source

patterns.lisp.

Method: print-object ((pexprand pexprand) stream)
Source

patterns.lisp.

Method: print-object ((pbeat pbeat) stream)
Source

patterns.lisp.

Method: print-object ((pscratch pscratch) stream)
Source

patterns.lisp.

Method: print-object ((t-pstream t-pstream) stream)
Source

patterns.lisp.

Method: print-object ((pbjorklund pbjorklund) stream)
Source

bjorklund.lisp.

Method: print-object ((pdiff pdiff) stream)
Source

patterns.lisp.

Method: print-object ((chord chord) stream)
Source

scales.lisp.

Method: print-object ((pstream pstream) stream)
Source

patterns.lisp.

Method: print-object ((ps ps) stream)
Source

patterns.lisp.

Method: print-object ((eseq eseq) stream)
Source

eseq.lisp.

Method: print-object ((pfilter pfilter) stream)
Source

patterns.lisp.

Method: print-object ((ptrace ptrace) stream)
Source

patterns.lisp.

Method: print-object ((pnary pnary) stream)
Source

patterns.lisp.

Method: print-object ((pdelta pdelta) stream)
Source

patterns.lisp.

Method: print-object ((pif pif) stream)
Source

patterns.lisp.

Method: print-object ((pchain pchain) stream)
Source

patterns.lisp.

Method: print-object ((pts pts) stream)
Source

patterns.lisp.

Method: print-object ((prun prun) stream)
Source

patterns.lisp.

Method: print-object ((task task) stream)
Source

clock.lisp.

Method: print-object ((clock clock) stream)
Source

clock.lisp.


6.1.7 Method combinations

Method Combination: pattern ()

Method combination type for patterns; specifically, the ‘next’ function. Similar to the standard CLOS method combination, except that :around methods are called in reverse order, from the least specific to the most specific.

Package

cl-patterns.

Source

utility.lisp.

Client Functions

next.


6.1.8 Classes

Class: backend

Abstract superclass for backends.

Package

cl-patterns.

Source

backend.lisp.

Direct methods
Direct slots
Slot: name

The name of the backend instance.

Type

alexandria:string-designator

Initargs

:name

Readers

backend-name.

Writers

(setf backend-name).

Slot: enabled-p

Whether this backend instance is currently enabled. Events being played will only be sent to enabled and running backends.

Type

boolean

Initform

t

Initargs

:enabled-p

Readers

backend-enabled-p.

Writers

(setf backend-enabled-p).

Slot: started-p

Whether the backend is current enabled and running.

Type

boolean

Initargs

:started-p

Readers

backend-started-p.

Writers

(setf backend-started-p).

Slot: input-processors

List of functions that process incoming events. Similar to ‘*post-pattern-output-processors*’ but per-backend.

Type

list

Initargs

:input-processors

Readers

backend-input-processors.

Writers

(setf backend-input-processors).

Slot: metadata

Additional metadata associated with the backend instance.

Type

list

Initargs

:metadata

Readers

backend-metadata.

Writers

(setf backend-metadata).

Class: chord

Chord definition.

Package

cl-patterns.

Source

scales.lisp.

Direct superclasses

sequence.

Direct methods
Direct slots
Slot: name

The full name of the chord.

Initargs

:name

Readers

chord-name.

Writers

(setf chord-name).

Slot: indexes

The indexes of the notes from the scale that the chord is made up of.

Initargs

:indexes

Readers

chord-indexes.

Writers

(setf chord-indexes).

Slot: scale

The scale that the chord is derived from.

Initargs

:scale

Readers

chord-scale.

Writers

(setf chord-scale).

Class: eseq
Package

cl-patterns.

Source

eseq.lisp.

Direct superclasses
Direct subclasses

eseq-pstream.

Direct methods
Direct slots
Slot: events
Type

list

Initform

(list)

Initargs

:events

Readers

eseq-events.

Writers

This slot is read-only.

Slot: dur

The duration of the eseq. If the slot is nil, it defaults to ‘last-dur’ rounded up to the next multiple of the eseq’s ‘play-quant’.

Type

(or null number)

Initargs

:dur

Class: eseq-pstream

pstream for ‘eseq’.

Package

cl-patterns.

Source

eseq.lisp.

Direct superclasses
Direct methods
Direct slots
Slot: events-remaining

The list of events left to be played in the pstream.

Initargs

:events-remaining

Slot: direct-p

Whether changes to the source eseq should affect this pstream immediately.

Initargs

:direct-p

Class: event

Class representing a musical event.

Package

cl-patterns.

Source

event.lisp.

Direct methods
Direct slots
Slot: event-plist

The plist containing all of the event’s keys and values.

Type

list

Initargs

:event-plist

Readers

event-plist.

Writers

This slot is read-only.

Slot: %beat

The time in beats when this event occurred in the pstream. Generally you should use ‘beat’ instead.

Type

(or null number)

Readers

%beat.

Writers

This slot is read-only.

Class: ipstream

Insertable pstream; a pstream that can be changed while it’s running by inserting new patterns at a specified beat.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

ipstream-pstream.

Direct methods
Direct slots
Slot: patterns
Initargs

:patterns

Slot: end-when-empty
Initargs

:end-when-empty

Slot: granularity
Initform

1/5

Initargs

:granularity

Class: ipstream-pstream

pstream for ‘ipstream’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods
Direct slots
Slot: lock
Initform

(bordeaux-threads:make-recursive-lock "ipstream patterns slot lock")

Initargs

:lock

Class: paccum

Numeric accumulator. Each output and STEP is used as the input for OPERATOR to generate the next output. When LO, HI, and BOUND-BY are provided, outputs that fall outside the range LO..HI are wrapped back inside with the BOUND-BY function; the value is provided as its first argument, and LO and HI are provided as its second and third.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-upto-n (paccum #’+ 0 1) 5) ; same as (pseries 0 1)
;; ;=> (0 1 2 3 4)

;; (next-upto-n (paccum #’+ 0 1 :inf :lo 0 :hi 3 :bound-by #’wrap) 9) ; same as above, wrapping between 0 and 3.
;; ;=> (0 1 2 0 1 2 0 1 2)

See also: ‘pseries’, ‘pgeom’, ‘pwalk’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

paccum-pstream.

Direct methods

print-object.

Direct slots
Slot: operator
Initform

(function +)

Initargs

:operator

Slot: start
Initform

0

Initargs

:start

Slot: step
Package

common-lisp.

Initform

1

Initargs

:step

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Slot: lo
Initargs

:lo

Slot: hi
Initargs

:hi

Slot: bound-by
Initargs

:bound-by

Class: paccum-pstream

pstream for ‘paccum’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-value
Initargs

:current-value

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: paclump

Automatically group outputs of the source pattern into lists of up to N items each. Unlike ‘pclump’, clump size is automatically set to the length of the longest list in the values of ‘*event*’, or 1 if there are no lists.

Example:

;; (next-upto-n (pbind :foo (pseq ’((1) (1 2) (1 2 3)) 1) :bar (paclump (pseries))))
;; ;=> ((EVENT :FOO (1) :BAR (0)) (EVENT :FOO (1 2) :BAR (1 2)) (EVENT :FOO (1 2 3) :BAR (3 4 5)))

See also: ‘pclump’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

paclump-pstream.

Direct methods

print-object.

Direct slots
Slot: pattern
Initargs

:pattern

Class: paclump-pstream

pstream for ‘paclump’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: parp

Arpeggiator pattern; each event yielded by PATTERN is bound to ‘*event*’ and then the entirety of the ARPEGGIATOR pattern is yielded.

Example:

;; (next-upto-n (parp (pbind :foo (pseq ’(1 2 3) 1))
;; (pbind :bar (pseq ’(4 5 6) 1))))
;; ;=> ((EVENT :FOO 1 :BAR 4) (EVENT :FOO 1 :BAR 5) (EVENT :FOO 1 :BAR 6)
;; (EVENT :FOO 2 :BAR 4) (EVENT :FOO 2 :BAR 5) (EVENT :FOO 2 :BAR 6)
;; (EVENT :FOO 3 :BAR 4) (EVENT :FOO 3 :BAR 5) (EVENT :FOO 3 :BAR 6))

See also: ‘psym’, ‘pmeta’, ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

parp-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: arpeggiator
Initargs

:arpeggiator

Class: parp-pstream

pstream for ‘parp’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-pattern-event
Initargs

:current-pattern-event

Slot: current-arpeggiator-stream
Initargs

:current-arpeggiator-stream

Class: pattern

Abstract pattern superclass.

Package

cl-patterns.

Source

patterns.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: play-quant

A list of numbers representing when the pattern’s pstream can start playing. See ‘play-quant’ and ‘quant’.

Initargs

:play-quant

Slot: end-quant

A list of numbers representing when a pattern can end playing and when a ‘pdef’ can be swapped out for a new definition. See ‘end-quant’ and ‘quant’.

Type

list

Initargs

:end-quant

Readers

end-quant.

Writers

(setf end-quant).

Slot: end-condition

Nil or a function that is called by the clock with the pattern as its argument to determine whether the pattern should end or swap to a new definition.

Type

(or null function)

Initargs

:end-condition

Readers

end-condition.

Writers

(setf end-condition).

Slot: source

The source object that this object was created from. For example, for a ‘pstream’, this would be the pattern that ‘as-pstream’ was called on.

Initargs

:source

Readers

pattern-source.

Writers

(setf pattern-source).

Slot: parent

When a pattern is embedded in another pattern, the embedded pattern’s parent slot points to the pattern it is embedded in.

Initargs

:parent

Slot: loop-p

Whether or not the pattern should loop when played.

Initargs

:loop-p

Slot: cleanup

A list of functions that are run when the pattern ends or is stopped.

Initargs

:cleanup

Slot: pstream-count

The number of pstreams that have been made of this pattern.

Initform

0

Readers

pstream-count.

Writers

(setf pstream-count).

Slot: metadata

Hash table of additional data associated with the pattern, accessible with the ‘pattern-metadata’ function.

Type

hash-table

Initform

(make-hash-table)

Initargs

:metadata

Class: pbeat

Yield the number of beats elapsed since the pbeat was embedded in the pstream.

Example:

;; (next-n (pbind :dur (pseq ’(1 2 3)) :foo (pbeat)) 3)
;; ;=> ((EVENT :DUR 1 :FOO 0) (EVENT :DUR 2 :FOO 1) (EVENT :DUR 3 :FOO 3))

See also: ‘pbeat*’, ‘beat’, ‘prun’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pbeat-pstream.

Direct methods

print-object.

Class: pbeat*

Yield the number of beats on the ‘*clock*’ of the current pattern. In other words, pbeat* is clock-synced, unlike ‘pbeat’, which is pattern-synced.

Example:

;; (next-n (pbind :dur (pseq ’(1 2 3)) :foo (pbeat*)) 3)
;; ;=> ((EVENT :DUR 1 :FOO 200) (EVENT :DUR 2 :FOO 201) (EVENT :DUR 3 :FOO 203))

See also: ‘pbeat’, ‘beat’, ‘prun’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pbeat*-pstream.

Direct methods

print-object.

Class: pbeat*-pstream

pstream for ‘pbeat*’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: task
Initargs

:task

Class: pbeat-pstream

pstream for ‘pbeat’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pbind

pbind yields events determined by its PAIRS, which are a list of keys and values. Each key corresponds to a key in the resulting events, and each value is treated as a pattern that is evaluated for each step of the pattern to generate the value for its key.

Example:

;; (next-n (pbind :foo (pseq ’(1 2 3)) :bar :hello) 4)
;;
;; ;=> ((EVENT :FOO 1 :BAR :HELLO) (EVENT :FOO 2 :BAR :HELLO) (EVENT :FOO 3 :BAR :HELLO) EOP)

See also: ‘pmono’, ‘pb’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pbind-pstream.

Direct methods
Direct slots
Slot: pairs

The pattern pairs of the pbind; a plist mapping its keys to their values.

Initargs

:pairs

Readers

pbind-pairs.

Writers

(setf pbind-pairs).

Class: pbind-pstream

pstream for ‘pbind’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods
Class: pbjorklund

pbjorklund generates Euclidean rhythms using the Bjorklund algorithm. PULSES is the number of notes in the sequence, and STEPS is number of steps in the sequence. Additionally, OFFSET is the number to rotate the sequence by, DUR is the total duration one repeat of the sequence should be, and REPEATS is the number of repeats that should be yielded. This pattern outputs events which can be embedded into another pattern. Each pulse is a note, and each subdivision of the sequence that is not a pulse is a rest. If you just want the raw output from the Bjorklund algorithm (not in pattern form), use ‘bjorklund’ instead.

Example:

;; (next-upto-n (pbjorklund 3 7))
;; => ((EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :NOTE :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7) (EVENT :TYPE :REST :DUR 1/7))

See also: ‘bjorklund’

Package

cl-patterns.

Source

bjorklund.lisp.

Direct superclasses

pattern.

Direct subclasses

pbjorklund-pstream.

Direct methods
Direct slots
Slot: pulses
Initargs

:pulses

Slot: steps
Initargs

:steps

Slot: offset
Initform

0

Initargs

:offset

Slot: dur
Initform

1

Initargs

:dur

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: pbjorklund-pstream

pstream for ‘pbjorklund’.

Package

cl-patterns.

Source

bjorklund.lisp.

Direct superclasses
Direct methods

next.

Class: pbrown

Brownian motion within a range; each output randomly a maximum of STEP away from the previous. LO and HI define the lower and upper bounds of the range. STEP defaults to 1 if LO and HI are integers.

Example:

;; (next-upto-n (pbrown 0 10 1 10))
;; ;=> (2 3 3 3 4 3 4 5 6 5)

See also: ‘pwhite’, ‘pexprand’, ‘pgauss’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pbrown-pstream.

Direct methods

print-object.

Direct slots
Slot: lo
Initform

0.0

Initargs

:lo

Slot: hi
Initform

1.0

Initargs

:hi

Slot: step
Package

common-lisp.

Initform

0.125

Initargs

:step

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pbrown-pstream

pstream for ‘pbrown’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Slot: current-value
Initargs

:current-value

Class: pchain

Combine multiple patterns into one event stream.

Example:

;; (next-n (pchain (pbind :foo (pseq ’(1 2 3))) (pbind :bar (pseq ’(7 8 9) 1))) 4) ;;
;; ;=> ((EVENT :FOO 1 :BAR 7) (EVENT :FOO 2 :BAR 8) (EVENT :FOO 3 :BAR 9) NIL)

See also: ‘pbind”s :embed key

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses
Direct methods
Direct slots
Slot: patterns
Initargs

:patterns

Class: pchain-pstream

pstream for ‘pchain’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct subclasses

pparchain-pstream.

Direct methods

next.

Class: pclump

Group outputs of the source pattern into lists of up to N items each.

Example:

;; (next-upto-n (pclump (pseries 0 1 5) 2))
;; ;=> ((0 1) (2 3) (4))

See also: ‘paclump’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pclump-pstream.

Direct methods

print-object.

Direct slots
Slot: pattern
Initargs

:pattern

Slot: n
Initform

1

Initargs

:n

Class: pclump-pstream

pstream for ‘pclump’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pcycles

pcycles yields values from LIST as events whose dur is (/ 1 list-length) and whose value is the original value in the list. This process recurses into sublists, subdividing their durs equally among the sublist’s contents to be a fraction of what their dur originally would be. The total dur yielded by pcycles is always equal to 1. pcycles repeats the whole LIST once.

Package

cl-patterns.

Source

cycles.lisp.

Direct superclasses

pattern.

Direct subclasses

pcycles-pstream.

Direct methods
Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: map
Package

common-lisp.

Initargs

:map

Slot: key
Initform

:value

Initargs

:key

Slot: dur
Initform

1

Initargs

:dur

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: pcycles-pstream

pstream for ‘pcycles’.

Package

cl-patterns.

Source

cycles.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: parsed-list
Initargs

:parsed-list

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pdef

Define a named pattern, with NAME being the name of the pattern and PATTERN the pattern itself. Named patterns are stored in a global dictionary and can be referred back to by calling ‘pdef’ without supplying PATTERN. The global dictionary also keeps track of the pdef’s pstream when ‘play’ is called on it. If a pdef is redefined while it is being played, the changes won’t be audible until either PATTERN ends, or the pdef’s ‘end-quant’ time is reached (if non-nil). Note that, unlike bare patterns, pdefs loop by default when played (‘loop-p’).

Example:

;; (pdef :foo (pbind :degree (pseries 0 1 4)))
;;
;; (play (pdef :foo))
;; ;; redefine the pdef’s pattern... note that the redefinition doesn’t become audible until the current loop finishes playing:
;; (pdef :foo (pbind :degree (pseries 4 -1 4)))

See also: ‘find-pdef’, ‘all-pdefs’, ‘pb’, ‘pmeta’, ‘ps’

Package

cl-patterns.

Source

pdef.lisp.

Direct superclasses

pattern.

Direct subclasses

pdef-pstream.

Direct methods
Direct slots
Slot: name
Type

alexandria:string-designator

Initargs

:name

Readers

pdef-name.

Writers

This slot is read-only.

Slot: pattern
Initargs

:pattern

Readers

pdef-pattern.

Writers

(setf pdef-pattern).

Slot: pstream
Initargs

:pstream

Readers

pdef-pstream.

Writers

(setf pdef-pstream).

Slot: task
Initargs

:task

Readers

pdef-task.

Writers

(setf pdef-task).

Class: pdef-pstream

pstream for ‘pdef’.

Package

cl-patterns.

Source

pdef.lisp.

Direct superclasses
Direct methods
Direct slots
Slot: current-pstream
Initargs

:current-pstream

Class: pdelta

Output the difference between successive outputs of PATTERN, assuming PATTERN restarts every CYCLE outputs.

Unlike ‘pdiff’, pdelta is written with its use as input for ‘pbind”s :delta key in mind. If PATTERN’s successive values would result in a negative difference, pdelta instead wraps the delta around to the next multiple of CYCLE. This would allow you to, for example, supply the number of the beat that each event occurs on, rather than specifying the delta between each event. This is of course achievable using pbind’s :beat key as well, however that method requires the pbind to peek at future values, which is not always desirable.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-n (pdelta (pseq ’(0 1 2 3)) 4) 8)
;;
;; ;=> (1 1 1 1 1 1 1 1)
;;
;; (next-n (pdelta (pseq ’(0 1 2 5)) 4) 8)
;;
;; ;=> (1 1 3 3 1 1 3 3)

See also: ‘pdiff’, ‘pbind”s :beat key

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pdelta-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: cycle
Initform

4

Initargs

:cycle

Class: pdelta-pstream

pstream for ‘pdelta’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pdiff

Output the difference between successive outputs of PATTERN.

Example:

;; (next-n (pdiff (pseq ’(3 1 4 3) 1)) 4)
;;
;; ;=> (-2 3 -1 NIL)

See also: ‘pdelta’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pdiff-pstream.

Direct methods

print-object.

Direct slots
Slot: pattern
Initargs

:pattern

Class: pdiff-pstream

pstream for ‘pdiff’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pdrop

Drop the first N outputs from PATTERN and yield the rest. If N is negative, drop the last N outputs from PATTERN instead.

Example:

;; (next-n (pdrop (pseq ’(1 2 3 4) 1) 2) 4)
;;
;; ;=> (3 4 NIL NIL)

See also: ‘protate’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pdrop-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: n
Initform

0

Initargs

:n

Class: pdrop-pstream

pstream for ‘pdrop’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pdurstutter

Yield each output from PATTERN N times, dividing it by N. If the output from PATTERN is an event, its dur is divided; if it’s a number, the number itself is divided instead of being yielded directly.

Example:

;; (next-n (pdurstutter (pseq ’(1 2 3 4 5)) (pseq ’(3 2 1 0 2))) 9)
;; ;=> (1/3 1/3 1/3 1 1 3 5/2 5/2 NIL)
;;
;; (next-n (pdurstutter (pbind :dur (pseq ’(1 2 3 4 5)))
;; (pseq ’(3 2 1 0 2)))
;; 9)
;; ;=> ((EVENT :DUR 1/3) (EVENT :DUR 1/3) (EVENT :DUR 1/3) (EVENT :DUR 1) (EVENT :DUR 1) (EVENT :DUR 3) (EVENT :DUR 5/2) (EVENT :DUR 5/2) NIL)

See also: ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pdurstutter-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: n
Initargs

:n

Class: pdurstutter-pstream

pstream for ‘pdurstutter’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-value
Initargs

:current-value

Slot: current-repeats-remaining
Initform

0

Initargs

:current-repeats-remaining

Class: pexprand

Exponentially-distributed random numbers between LO and HI. Note that LO and HI cannot be 0, and that LO and HI must have the same sign or else complex numbers will be output.

Example:

;; (next-upto-n (pexprand 1.0 8.0 4))
;; ;=> (1.0420843091865208d0 1.9340168112124456d0 2.173209129035095d0 4.501371557329618d0)

See also: ‘pwhite’, ‘pbrown’, ‘pgauss’, ‘prand’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pexprand-pstream.

Direct methods

print-object.

Direct slots
Slot: lo
Initform

1.0e-4

Initargs

:lo

Slot: hi
Initform

1.0

Initargs

:hi

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pexprand-pstream

pstream for ‘pexprand’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pfilter

Skip elements of a source pattern that PREDICATE returns false for. If PREDICATE is not a function, skip items that are ‘eql’ to it.

Example:

;; (next-n (pfilter (pseq (list 1 2 3))
;; 2)
;; 6)
;; ;=> (1 3 1 3 1 3)

;; (next-n (pfilter (pseries 0 1) ’evenp)
;; 6)
;; ;=> (1 3 5 7 9 11)

See also: ‘pfilter-out’, ‘pr’, ‘pdurstutter’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pfilter-pstream.

Direct methods

print-object.

Direct slots
Slot: pattern
Initargs

:pattern

Slot: predicate
Initform

(quote identity)

Initargs

:predicate

Class: pfilter-pstream

pstream for ‘pfilter’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pfin

Yield up to COUNT outputs from PATTERN.

Example:

;; (next-n (pfin (pseq ’(1 2 3) :inf) 3) 5) ;; ;=> (1 2 3 NIL NIL)

See also: ‘pfindur’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pfin-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: count
Package

common-lisp.

Initargs

:count

Class: pfin-pstream

pstream for ‘pfin’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pfindur

Yield events from PATTERN until their total duration is within TOLERANCE of DUR, or greater than DUR. Any events that would end beyond DUR are cut short. If PATTERN outputs numbers, their total sum is limited instead.

Example:

;; (next-n (pfindur (pbind :dur 1 :foo (pseries)) 2) 3)
;; ;=> ((EVENT :DUR 1 :FOO 0) (EVENT :DUR 1 :FOO 1) EOP)
;;
;; (next-upto-n (pfindur (pwhite 0 4) 16))
;; ;=> (1 3 0 1 2 2 1 3 0 1 2)
;; (reduce #’+ *)
;; ;=> 16

See also: ‘pfin’, ‘psync’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pfindur-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: dur
Initargs

:dur

Slot: tolerance
Initform

0

Initargs

:tolerance

Class: pfindur-pstream

pstream for ‘pfindur’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-dur
Initargs

:current-dur

Slot: elapsed-dur
Initform

0

Initargs

:elapsed-dur

Class: pfunc

Yield the result of evaluating FUNC. Note that the current event of the parent pattern is still accessible via the ‘*event*’ special variable.

Example:

;; (next-upto-n (pfunc (lambda () (random 10)) 4))
;; ;=> ((5 2 8 9))
;;
;; (next-upto-n (pbind :foo (pwhite 0 10 4)
;; :bar (pfunc (lambda ()
;; (if (> (event-value *event* :foo) 5) :greater :lesser)))))
;; ;=> ((EVENT :FOO 0 :BAR :LESSER) (EVENT :FOO 6 :BAR :GREATER)
;; (EVENT :FOO 7 :BAR :GREATER) (EVENT :FOO 8 :BAR :GREATER))

See also: ‘pf’, ‘pnary’, ‘plazy’, ‘pif’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pfunc-pstream.

Direct methods
Direct slots
Slot: func
Type

(or mutility:function-designator cl-patterns:pattern)

Initargs

:func

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pfunc-pstream

pstream for ‘pfunc’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pgauss

Random numbers distributed along a normal (gaussian) curve. MEAN is the "center" of the distribution, DEVIATION is the standard deviation (i.e. the higher the value, the further the outputs are spread from MEAN).

Example:

;; (next-n (pgauss) 4)
;; ;=> (0.08918811646370092d0 0.1745957067161632d0 0.7954678768273173d0 -1.2215823449671597d0)

See also: ‘pwhite’, ‘pexprand’, ‘pbrown’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pgauss-pstream.

Direct methods

print-object.

Direct slots
Slot: mean
Package

alexandria.

Initform

0.0

Initargs

:mean

Slot: deviation
Initform

1.0

Initargs

:deviation

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pgauss-pstream

pstream for ‘pgauss’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pgeom

Yield START, then generate subsequent outputs by multiplying by GROW, for a total of LENGTH outputs.

Example:

;; (next-upto-n (pgeom 1 2 4))
;; ;=> (1 2 4 8)

See also: ‘pseries’, ‘paccum’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pgeom-pstream.

Direct methods

print-object.

Direct slots
Slot: start
Initform

1

Initargs

:start

Slot: grow
Initform

2

Initargs

:grow

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pgeom-pstream

pstream for ‘pgeom’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Slot: current-value
Initargs

:current-value

Class: phistory

Refer back to PATTERN’s history, yielding the output at the index provided by STEP-PATTERN.

Note that PATTERN is still advanced once per event, and if STEP-PATTERN yields a number pointing to an event in PATTERN that hasn’t been yielded yet (i.e. if PATTERN has only advanced once but STEP-PATTERN yields 3 for its output), phistory yields nil.

Example:

;; (next-n (phistory (pseries) (pseq ’(0 2 1))) 3)
;; ;=> (0 NIL 1)

See also: ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

phistory-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: step-pattern
Initargs

:step-pattern

Class: phistory-pstream

pstream for ‘phistory’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pif

"If" expression for patterns. TEST is evaluated for each step, and if it’s non-nil, the value of TRUE will be yielded, otherwise the value of FALSE will be. Note that TRUE and FALSE can be patterns, and if they are, they are only advanced in their respective cases, not for every step.

Example:

;; (next-n (pif (pseq ’(t t nil nil nil)) (pseq ’(1 2 3)) (pseq ’(9 8 7))) 8)
;; ;=> (1 2 9 8 7 3 1 9)

See also: ‘plazy’, ‘pfunc’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pif-pstream.

Direct methods

print-object.

Direct slots
Slot: test
Initargs

:test

Slot: true
Initargs

:true

Slot: false
Initargs

:false

Class: pif-pstream

pstream for ‘pif’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pindex

Use INDEX-PAT to index into the list returned by LIST-PAT. WRAP-P is whether indexes that are out of range will be wrapped (if t) or will simply return nil.

Example:

;; (next-n (pindex (list 99 98 97) (pseq (list 0 1 2 3))) 4)
;;
;; ;=> (99 98 97 NIL)
;;
;; (next-upto-n (pindex (list 99 98 97) (pseries 0 1 6) t))
;;
;; ;=> (99 98 97 99 98 97)

See also: ‘pwalk’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pindex-pstream.

Direct methods
Direct slots
Slot: list-pat
Initargs

:list-pat

Slot: index-pat
Initargs

:index-pat

Slot: wrap-p
Initargs

:wrap-p

Class: pindex-pstream

pstream for ‘pindex’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pk

Yield the value of KEY in the current ‘*event*’ context, returning DEFAULT if that value is nil.

Example:

;; (next-upto-n (pbind :foo (pseq ’(1 2 3) 1) :bar (pk :foo)))
;; ;=> ((EVENT :FOO 1 :BAR 1) (EVENT :FOO 2 :BAR 2) (EVENT :FOO 3 :BAR 3))

See also: ‘pbind’, ‘event-value’, ‘*event*’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pk-pstream.

Direct methods
Direct slots
Slot: key
Initargs

:key

Slot: default
Initform

1

Initargs

:default

Class: pk-pstream

pstream for ‘pk’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: place

Yield each value from LIST in sequence. If the value is a list, the first element of that list is yielded. The second time that sub-list is encountered, its second element will be yielded; the third time, the third element, and so on. REPEATS controls the number of times LIST is repeated.

Example:

;; (next-upto-n (place (list 1 2 (list 3 4 5)) 3))
;; ;=> (1 2 3 1 2 4 1 2 5)

See also: ‘ppatlace’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

place-pstream.

Direct methods

print-object.

Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: place-pstream

pstream for ‘place’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeat
Initform

0

Initargs

:current-repeat

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: plazy

Evaluates FUNC to generate a pattern, which is then yielded from until its end, at which point FUNC is evaluated again to generate the next pattern. The pattern is generated a total of REPEATS times.

Example:

;; (next-n (plazy (lambda () (if (= 0 (random 2)) (pseq ’(1 2 3) 1) (pseq ’(9 8 7) 1)))) 6)
;; ;=> (9 8 7 1 2 3)

See also: ‘pfunc’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

plazy-pstream.

Direct methods
Direct slots
Slot: func
Initargs

:func

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: plazy-pstream

pstream for ‘plazy’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-pstream
Initargs

:current-pstream

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pmeta

Meta-control patterns using the events output by PATTERN. In other words, instead of triggering synths directly, the events output by PATTERN are used to embed patterns into the pmeta’s pstream.

The following keys are supported:

- :pattern or :instrument - name of the source pattern for this "step".
- :dur - set the duration of the embedded pattern (defaults to :inf, which causes the pattern to play to its end).
- :findur - limit the duration of the embedded pattern.
- :sync - sync the duration of the embedded pattern to a multiple of the provided value, similar to ‘psync’
- :stretch - multiply the duration of each of the source pattern’s events.
- :ts or :fit - timestretch a pattern so its total duration is the number specified, a la ‘pts’.
- :r or :repeat - repeat each event the number of times returned by the function when the event is applied to it, similar to ‘pr’.
- :inject - inject key/value pairs from the output of this value into the source pattern.
- :step-inject or :sinject - inject one output from this value per step.

The following keys are planned for future implementation:

- :start or :end - adjust the start or end points of the source pattern (i.e. to skip the first half, set :start to 0.5).
- :start-beat or :end-beat - adjust the start or end points of the source pattern in number of beats (i.e. to end the pattern 2 beats early, set :end-beat to -2).
- :start-nth or :end-nth - adjust the start or end points of the source pattern by skipping the first or last N events.
- :filter or :remove-if-not - skip all events from the source pattern that return nil when applied to the specified function or pattern.
- :mapcar or :nary - process each event from the source pattern with a function or another pattern.

See doc/special-keys.org for more information on these keys.

Example:

;; ;; define a few patterns...
;; (pdef :foo (pbind :x (pseq ’(1 2 3) 1) :dur 1))
;; (pdef :bar (pbind :y (pseries) :dur (pwhite 0.1 1.0 3)))
;;
;; ;; use pmeta to play pattern foo and then pattern bar, ensuring each are 2 beats long in total by way of pmeta’s sync key, which works similarly to ‘psync’
;; (next-upto-n (pmeta :pattern (pseq (list :foo :bar) 1) :sync 2))
;; ;=> ((EVENT :X 1 :DUR 1) (EVENT :X 2 :DUR 1) ; from (pdef :foo)
;; (EVENT :Y 0 :DUR 0.76958686) (EVENT :Y 1 :DUR 0.94850993) (EVENT :Y 2 :DUR 0.28190327)) ; from (pdef :bar)

See also: ‘psym’, ‘parp’, ‘pdef’, ‘pbind’

Package

cl-patterns.

Source

pmeta.lisp.

Direct superclasses

pattern.

Direct subclasses

pmeta-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Class: pmeta-pstream

pstream for ‘pmeta’.

Package

cl-patterns.

Source

pmeta.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-pstream
Initargs

:current-pstream

Class: pmouse

Get the mouse position of the display server (GUI). ORIENTATION can be :x or :y, and FORMAT can be either :relative (in which case the output is a number from 0 to 1 as a fraction of total display size) or :absolute (in which case the output is the actual X or Y position of the mouse).

See also: ‘pmousex’, ‘pmousey’, ‘mouse-location’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pmouse-pstream.

Direct methods

print-object.

Direct slots
Slot: orientation
Initargs

:orientation

Slot: format
Package

common-lisp.

Initform

:relative

Initargs

:format

Class: pmouse-pstream

pstream for ‘pmouse’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pn

Embed the full PATTERN into the pstream REPEATS times.

Example:

;; (next-upto-n (pn (pwhite 0 5 1) 5))
;; ;=> (2 4 2 1 0)

See also: ‘pr’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pn-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: pn-pstream

pstream for ‘pn’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Slot: current-pstream
Initargs

:current-pstream

Class: pnary

Yield the result of applying OPERATOR to each value yielded by each pattern in PATTERNS.

Example:

;; (next-upto-n (pnary (pseq (list ’+ ’- ’* ’/) 2) 2 2))
;; ;=> (4 0 4 1)

See also: ‘pfunc’, ‘p+’, ‘p-’, ‘p*’, ‘p/’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pnary-pstream.

Direct methods
Direct slots
Slot: operator
Initargs

:operator

Slot: patterns
Initargs

:patterns

Class: pnary-pstream

pstream for ‘pnary’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: ppar

Combine multiple event patterns into one pstream with all events in temporal order. PATTERNS is the list of patterns, or a pattern yielding lists of patterns. The ppar ends when all of the patterns in PATTERNS end.

Example:

;; (next-upto-n (ppar (list (pbind :dur (pn 1/2 4))
;; (pbind :dur (pn 2/3 4)))))
;;
;; ;=> ((EVENT :DUR 1/2 :DELTA 0) (EVENT :DUR 2/3 :DELTA 1/2)
;; (EVENT :DUR 1/2 :DELTA 1/6) (EVENT :DUR 2/3 :DELTA 1/3)
;; (EVENT :DUR 1/2 :DELTA 1/3) (EVENT :DUR 2/3 :DELTA 1/6)
;; (EVENT :DUR 1/2 :DELTA 1/2) (EVENT :DUR 2/3 :DELTA 2/3))

See also: ‘psym’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

ppar-pstream.

Direct methods

print-object.

Direct slots
Slot: patterns
Initargs

:patterns

Class: ppar-pstream

pstream for ‘ppar’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: pstreams
Initargs

:pstreams

Class: pparchain

Combine multiple patterns into several event streams. The event yielded by the first pattern will be used as the input event to the second pattern, and so on. The events yielded by each pattern will be collected into a list and yielded by the pparchain. This pattern is effectively ‘ppar’ and ‘pchain’ combined.

Example:

;; (next-upto-n (pparchain (pbind :foo (pseries 0 1 3)) (pbind :baz (p+ (pk :foo) 1) :foo (p+ (pk :foo) 3))))
;; ;=> (((EVENT :FOO 0) (EVENT :FOO 3 :BAZ 1))
;; ((EVENT :FOO 1) (EVENT :FOO 4 :BAZ 2))
;; ((EVENT :FOO 2) (EVENT :FOO 5 :BAZ 3)))

See also: ‘ppc’, ‘ppar’, ‘pchain’, ‘pbind”s :embed key

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pchain.

Direct subclasses

pparchain-pstream.

Direct methods
Direct slots
Slot: patterns
Initargs

:patterns

Class: pparchain-pstream

pstream for ‘pparchain’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: ppatlace

Yield each value from LIST in sequence, or one output from each pattern in LIST per cycle of the list. If one of the patterns embedded in LIST ends sooner than the others, it is simply removed and the ppatlace continues to yield from the rest of the LIST. The entire LIST is yielded through a total of REPEATS times.

Example:

;; (next-upto-n (ppatlace (list (pseq (list 1 2 3) 1)
;; (pseq (list 4 5 6) 2))))
;; ;=> (1 4 2 5 3 6 4 5 6)

See also: ‘place’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

ppatlace-pstream.

Direct methods
Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: ppatlace-pstream

pstream for ‘ppatlace’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pr

Repeat each value from PATTERN REPEATS times. If REPEATS is 0, the value is skipped.

Example:

;; (next-upto-n (pr (pseries) (pseq ’(1 3 0 2) 1)))
;; ;=> (0 1 1 1 3 3)

See also: ‘pdurstutter’, ‘pn’, ‘pdrop’, ‘parp’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pr-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: pr-pstream

pstream for ‘pr’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-value
Initargs

:current-value

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: prand

Yield random values from LIST.

Example:

;; (next-n (prand ’(1 2 3) 5) 6)
;; ;=> (3 2 2 1 1 EOP)

See also: ‘pxrand’, ‘pwrand’, ‘pwxrand’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

prand-pstream.

Direct methods

print-object.

Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: prand-pstream

pstream for ‘prand’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: prerange

Remap INPUT from one range, specified by FROM-RANGE, to another range, specified by TO-RANGE.

Note that this is effectively a convenience wrapper over ‘pnary’ and ‘rerange’; thus you should see ‘rerange’ for more information.

See also: ‘rerange’, ‘pnary’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

prerange-pstream.

Direct methods
Direct slots
Slot: input
Initargs

:input

Slot: from-range
Initargs

:from-range

Slot: to-range
Initargs

:to-range

Class: prerange-pstream

pstream for ‘prerange’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: prest

An object representing a rest. When set as a value in an event, the event’s :type becomes :rest and the prest’s value slot is used as the actual value for the event key instead.

Package

cl-patterns.

Source

patterns.lisp.

Direct methods
Direct slots
Slot: value
Initform

1

Initargs

:value

Class: protate

Rotate PATTERN N outputs forward or backward, wrapping the shifted items to the other side, a la ‘alexandria:rotate’.

Example:

;; (next-upto-n (protate (pseq ’(1 2 3 4 5) 1) 2))
;; ;=> (4 5 1 2 3)

See also: ‘pdrop’, ‘phistory’, ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

protate-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: shift
Initform

0

Initargs

:shift

Class: protate-pstream

pstream for ‘protate’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: prun

Run PATTERN "independently" of its parent, holding each value for DUR beats. Each of PATTERN’s outputs is treated as if it lasted DUR beats, being continuously yielded during that time before moving on to the next output.

Example:

;; (next-upto-n (pbind :foo (pseq ’(1 2 3 4 5))
;; :bar (prun (pseq ’(4 5 6 7 8))
;; (pseq ’(1 2 0.5 0.5 1)))))
;; ;=> ((EVENT :FOO 1 :BAR 4)
;; (EVENT :FOO 2 :BAR 5)
;; (EVENT :FOO 3 :BAR 5)
;; (EVENT :FOO 4 :BAR 6)
;; (EVENT :FOO 5 :BAR 8))

See also: ‘beat’, ‘pbeat’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

prun-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: dur
Initform

1

Initargs

:dur

Class: prun-pstream

pstream for ‘prun’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-dur
Initform

0

Initargs

:current-dur

Class: ps

Preserve pstream state across subsequent calls to ‘as-pstream’. To reset the pstream, simply re-evaluate the ps definition.

Based on the pattern originally from the miSCellaneous SuperCollider library.

Example:

;; (defparameter *pst* (ps (pseries)))
;;
;; (next-upto-n *pst* 4)
;; ;=> (0 1 2 3)
;;
;; (next-upto-n *pst* 4)
;; ;=> (4 5 6 7)
;;
;; (defparameter *pst* (ps (pseries)))
;;
;; (next-upto-n *pst* 4)
;; ;=> (0 1 2 3)

See also: ‘prs’, ‘pdef’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

ps-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: pstream
Initargs

:pstream

Class: ps-pstream

pstream for ‘ps’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Class: pscratch

"Scratches" across the values yielded by a pstream, similar in concept to how a DJ might scratch a record, altering the normal flow of playback. PATTERN is the source pattern, and STEP-PATTERN determines the increment of the index into the pstream history.

Based on the pattern originally from the ddwPatterns SuperCollider library.

Example:

;; (next-upto-n (pscratch (pseries) (pseq ’(0 1 1 -1 2) 2)))
;; ;=> (0 0 1 2 1 3 3 4 5 4)

See also: ‘phistory’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pscratch-pstream.

Direct methods
Direct slots
Slot: pattern
Initargs

:pattern

Slot: step-pattern
Initargs

:step-pattern

Class: pscratch-pstream

pstream for ‘pscratch’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-index
Initform

0

Initargs

:current-index

Class: pseq

Sequentially yield items from LIST, repeating the whole list REPEATS times. OFFSET is the offset to index into the list.

Example:

;; (next-n (pseq ’(5 6 7) 2) 7)
;; ;=> (5 6 7 5 6 7 EOP)
;;
;; (next-upto-n (pseq ’(5 6 7) 2 1))
;; ;=> (6 7 5 6 7 5)

See also: ‘pser’, ‘eseq’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pseq-pstream.

Direct methods

print-object.

Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Slot: offset
Initform

0

Initargs

:offset

Class: pseq-pstream

pstream for ‘pseq’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pser

Sequentially yield values from LIST, yielding a total of LENGTH values.

Example:

;; (next-n (pser ’(5 6 7) 2) 3)
;;
;; ;=> (5 6 EOP)

See also: ‘pseq’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pser-pstream.

Direct methods

print-object.

Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Slot: offset
Initform

0

Initargs

:offset

Class: pser-pstream

pstream for ‘pser’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Slot: current-index
Initargs

:current-index

Class: pseries

Yield START, then generate subsequent outputs by adding STEP, for a total of LENGTH outputs.

Example:

;; (next-upto-n (pseries 1 2 4))
;; ;=> (1 3 5 7)

See also: ‘pseries*’, ‘pgeom’, ‘paccum’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pseries-pstream.

Direct methods

print-object.

Direct slots
Slot: start
Initform

0

Initargs

:start

Slot: step
Package

common-lisp.

Initform

1

Initargs

:step

Slot: length
Package

common-lisp.

Initform

cl-patterns:*default-pattern-length*

Initargs

:length

Class: pseries-pstream

pstream for ‘pseries’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Slot: current-value
Initargs

:current-value

Class: pshuf

Shuffle LIST, then yield each item from the shuffled list, repeating it REPEATS times.

Example:

;; (next-upto-n (pshuf ’(1 2 3) 2))
;;
;; ;=> (3 1 2 3 1 2)

See also: ‘prand’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pshuf-pstream.

Direct methods
Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: repeats
Initform

cl-patterns:*default-pattern-repeats*

Initargs

:repeats

Class: pshuf-pstream

pstream for ‘pshuf’.

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses
Direct methods

next.

Direct slots
Slot: shuffled-list
Initargs

:shuffled-list

Slot: current-repeats-remaining
Initargs

:current-repeats-remaining

Class: pslide

"Slide" across sections of LIST. REPEATS is the total number of sections to output, LEN the length of the section. STEP is the number to increment the start index by after each section, and START is the initial index into LIST that the first section starts from. WRAP-AT-END, when true, means that an index outside of the list will wrap around. When false, indexes outside of the list result in nil.

Example:

;; (next-upto-n (pslide (list 0 1 2 3 4 5 6) 3 3 2 1 t))
;; ;=> (1 2 3 3 4 5 5 6 0)

See also: ‘pscratch’

Package

cl-patterns.

Source

patterns.lisp.

Direct superclasses

pattern.

Direct subclasses

pslide-pstream.

Direct methods
Direct slots
Slot: list
Package

common-lisp.

Initargs

:list

Slot: repeats