I


Intro       Symbols A B C D E F G H I J K L M N O P Q R S T U V W X Y Z       Index  
#i[p[d]]({item}+ {option value}*) [Read Macro]

Provides a short hand for item stream definition. Pattern and stream types are specified using two optional characters p and d. P determines the pattern of the stream. If p is omitted, then it defaults to a cyclic item stream. If p is supplied, then d determines the type of the stream. If d is not supplied the stream type defaults to items.

P                       D
c  cycle                n  notes
r  random               r  rhythms
h  heap                 p  pitchs
g  graph                d  degrees
s  sequence             i  intervals
a  accumulation         s  steps
p  palindrome           a  amplitudes
f  function             f  pathnames
o  rotation
w  rewrite

Example:

? #i(a b c)
#<CYCLIC-ITEM-STREAM 131425111>

? #ir(a b c)
#<RANDOM-ITEM-STREAM 131426721>

? #ihn(a3 b c for 10)
#<HEAP-NOTE-STREAM 131460011>

? #irr(q (w weight .2) e for 10)
#<RANDOM-RHYTHM-STREAM 131440761>

See Also:

Item Streams

 


idsel {{id | (id+)} stream}+ [Macro]

Creates an id selection table for implementing higher order Markov processes using the graph pattern. In higher order Markov, the probability of the next choice is based on the current node and zero or more previous choices, represented as zero or more previous node ids. The transition table is specified as a sequence of id stream pairs. id can be a single identifier or a list of previous identifiers. Stream is the probability item stream to use if that id matches the actual previous ids that were chosen. For example, the declaration of a node for some item B in a 2nd order Markov graph might look like:

(B to (idsel a (items a b c in random)
             b (items (a weight 4) b in random)>
             c a)))
which corresponds to the transition table:
Previous       A    B    C
Current        B    B    B
Next
          A  .333  .80  1.0
          B  .333  .20  0.0
          C  .333  .00  0.0
idsel uses pattern matching to find previous ids in the selection table. Previous ids are matched with each candidate id entry in the table according two rules: (1) matching occurs for the length of id, which may be less than the previous number of choices. If every candidate id matches its corresponding id in the previous choices, then that probability stream is selected. This allows multiple entries in a table to be collapsed to a single selection. (2) A * at any position in id matches the corresponding previous choice, no matter what it was. For example, the following two selection tables are equivalent:

(idsel a (items a b c d in random)
       b (items (a weight 4) c d in random)
       c (items a b c d in random)
       d (items a b c d in random))

(idsel b (items (a weight 4) c d in random)
       * (items a b c d in random))

Example:

;; this second order markov graph generates random 
;; rhythms that maintain a quarter note pulse (tobias kunze)

(rhythms (h   to (items e e. q q. q.. h in random))
         (q.. to s)
         (q.  to (items e s in random))
         (q   to (items e e. q q. q.. h in random))
         (e.  to s)
         (e   to (idsel e (items s e e. q q. q.. h in random)
                        * e))
         (s   to (idsel e s q. s q e. h e.
                        * (items e e. q q. q.. h in random)))
         in graph for 20 previous (q)))

See Also:

graph, markov.cm

 


in-scale name [Function]

Sets the musical scale named name as the default scale for resolving scale references in.

See Also:

defscale, *standard-scale*

 


in-syntax name [Function]

Sets the current score syntax to the syntax named name. An in-syntax statment can be placed at the beginning of a .cm archive file to establish the proper syntax when the file is loaded or evaluated.

Example:

? (in-syntax :midi)
#<Syntax: MIDI>

 


in-tempo tempo &optional beat [Function]

Sets the default global tempo to the metronome value tempo. beat is a logical rhythmic value defining the pulse and defaults to q, or quarter note.

Example:

? (in-tempo 120 'q.)
180.0

See Also:

clock-mode, rhythms, tempo, *standard-tempo*

 


interp x env &key :scale :offset :return-type [Function]

Returns the interpolated y value of x in env with optional :scale and :offset values applied: f(x)*scale+offset. The type of the value returned normally depends on the type of the arguments specified to the function. Use :return-type to force the return value to be a specific type, either float, integer or ratio. float may also be specified as a list (float digits) in which case the floating point return value will be rounded to digitnumber of places.

Example:

? (interp 50 '(0 0 100 1) :scale 2 :offset 3)
4.0

See Also:

interpl, interpolation, lookup

 


interpl x &rest coords [Function]

Returns the interpolated y value of x in coords. Coords is a sequence of x y coordinates.

Example:

? (interpl 75 0 0 50 .5 100 0)
.25

See Also:

interp, lookup

 


interpolation &rest coords [Macro]

Creates an interpolation envelope out of coords, a sequence of x y coordinate pairs.

Example:

? (setf x (interpolation 0 0 50 .5 100 0))
(0 0 50 0.5 100 0)

(interp 75 x)
0.25

See Also:

interp, interpl, lookup

 


intervals {interval}+ {option value}* [Macro]

Creates an item stream of intervals, or relative scale positions. Each interval may be an integer or an item stream. The stream may be coerced to return absolute note, degree or pitch references.

intervals implements the following {option value} pairs:

from {note | pitch | degree | stream}
Sets the transposition offset for the stream, which defaults to 0. The offset may be expressed as a note, degree, pitch or item stream and is recalulated once each period. from, on, initially-from andlinked-to are mutually exclusive options.
on {note | pitch | degree | stream}
Similar to from except that a new transposition value is read in parallel with the pattern selection rather than once per period. from, on, initially-from andlinked-to are mutually exclusive options.
initially-from {note | pitch | degree | stream}
Similar to from except that the transposition offset is never reset, so subsequent periods start where the previous one left off. from, on, initially-from andlinked-to are mutually exclusive options.
linked-to {stream}
Sets the transposition value as the current transposition value of some other stream. The name of the stream is not quoted. from, on, initially-from andlinked-to are mutually exclusive options.
returning {note | degree | pitch}
Coerces the stream to return note names, scale positions or floating point frequencies.
of {scale}
Sets the scale of the stream. Defaults to *standard-scale*.
An additional set of basic option valuepairs are available in all item stream macros. Others may be available based on the pattern type specified to the macro.

Example:

? (setf x (intervals 1 2 3 in random from 'c4 returning note))
#<RANDOM-INTERVAL-STREAM 136751211>

? (read-items x 8)
(CS4 D4 DS4 D4 DS4 D4 DS4 D4)

? (setf x (notes (notes c3 c4 for 1 named 'foo)>
                 (intervals 1 2 linked-to #@foo)))
#<CYCLIC-NOTE-STREAM 137175041>

? (read-items x)
(C3 CS3 D3)

? (read-items x)
(C4 CS4 D4)

See Also:

Item Streams

 


invert reference note &optional scale [Function]

Inverts reference around note in scale. Reference may be a note, pitch, degree or list of the same. If reference is a list and note is nil, then the list of refernences is inverted such that it occupies the same range as the original. Scale defaults to *standard-scale*.

Example:

(invert 'ef4 'c4)
A3

See Also:

degree, note, pitch, transpose

   


item stream [Function]
item stream &key :kill :chord :rest [Function]

Returns two values, the next item from the item stream stream and the state of the stream after the item was read. As with all multiple values in Lisp, this second value may be ignored.

Within an algorithm macro, item supports the additional keyword arguments :kill, :chord and :rest which have the following meaning:

:kill {integer | t | nil}
Stops (kills) the algorithm after some number of periods have been read from stream. If nil (the default) the algorithm is not killed. If t the algorithm stops after one period of items has been read, otherwise it stops after integer number of periods have been read.
:chord {t | nil}
Controls whether or not the system checks for chords. Defaults to t.
:rest {t | nil}
Controls whether or not the system checks for rests. Defaults to t.

Example:

? (setf x (items foo bar))
#<CYCLIC-ITEM-STREAM 133134441>

? (item x)
FOO
NIL

? (item x)
BAR
:END-OF-PERIOD

See Also:

doitems, Item Streams, read-items

 


Item Streams

Item Streams are objects that organize typed data into patterns.

  Data Types

Each type of data has its own macro for creating the appropriate class of item stream:

  Pattern Types

Each item stream macro can implement any of the following pattern types:

Once an item stream has been created, successive items can be read from the stream using one of the accessing functions:

A number of macros use item streams to implement specific facilities:

See Also:

Introduction to Item Streams, items.cm

 


items {item}+ {option value}* [Macro]

Creates an item stream of untyped data. Each item may be a Lisp object or an item stream.

  items implements the following option value pairs. These pairs are available in all item stream macros:

in {pattern}
Sets the pattern type of the stream, which defaults to cycle. Other available patterns are: accumulation, function, graph, heap, palindrome, random, rewrite, rotation and sequence.
for {integer | stream}
Sets the period length of the stream, which defaults to a pattern specific length. The value may be any non-negative number, including 0 or an item stream. If a period length is 0, then the stream is be omitted from the superior pattern until it is reselected and sets its period length to a number greater than 0. The period length counts subperiods or values in the pattern's data, depending on the value of the counting option.
counting {periods | values}
Controls whether the period length of the stream counts periods in the pattern or values returned in the pattern. If periods (the default), the number of items returned in the period is the sum of that many period lengths in the data. If values, the number of items returned is the same as the period length.
traversing {depth | breadth}
Controls whether the pattern visits its items in depth-first or breadth-first order. If depth (the default), the pattern increments only when the current item is at end-of-period. If breadth, the pattern increments each enumeration. (Traversing breadth may be implemented by setting the period lengths of all substreams to 1, but this is less efficient).
named {name}
Sets the name of the item stream. A named item stream may be subsequently referenced using find-item-stream, #@ or motive.
Other pairs may be available based on the pattern type specified to the macro.

Example:

? (setf x (items 1 two 3 four in heap))
#<HEAP-ITEM-STREAM 133137601>

? (read-items x)
(3 FOUR 1 TWO)

See Also:

Item Streams