defmultiple-item name ({field}+)
({keyword value})*
|
[Macro] |
Defines a class of item with component fields. Multiple items
enumerate their fields in parallel, regardless of what type of pattern
the multiple-item appears in. Fields may contain constant values or
item streams. name is the name for the multiple item. Each
field declares a component of the multiple item. Following the
field specification comes zero or more option lists:
- (:element-period {field | :all {field}* | :any
{field}*})
- sets which field or combination of fields controls the period
length of the multiple item. If the value is a single field then that
field controls the period length. Otherwise the value should be
:all or :any followed by zero or more qualifying
fields. :all means than each qualified field (or all the
fields if none are qualified) must be at end-of-period before the
multiple item is considered to be at end-of-period. :any
specifies that the multiple-item will be at end-of-period when any of
the qualifying fields (or all the fields if none are qualified) are at
end-of-period. If only a single field is tracked, then :all
and :any have the same effect.
- (:element-parser lambda)
- Defines a parser for the multiple item. The parser function is
passed as many parameters as there are fields declared, and it must
return the list of parsed field values. For example, a parser for a
multiple item with two fields, the second of which generates scale
degrees, would look like:
(lambda (x y) (list x (degree y))
- (:element-state field)
- Names the field whose state is returned as the state of the
multiple item.
- (:element-filter lambda-expression)
- Defines an element filter for the multiple item. The filter is
passed the current elements in the multiple item and returns the
actual list of elements to return.
defmultiple-item definitions should be compiled before using.
Example:
? (defmultiple-item gesture (pit rhy)
(:element-period :all)
(:element-parser (lambda (n r) (list (note n) (rhythm r)))))
#<Standard-Class GESTURE 137535711>
? (setf x (items (gesture c4 q)
(gesture (notes c5 c6 in random) w)
(gesture b3 (rhythms s e for 1))
in heap for 10))
#<HEAP-ITEM-STREAM 137443141>
? (read-items x)
((C4 1.0) (C5 4.0) (C5 4.0) (B3 0.25) (B3 0.5) (C6 4.0) (C5 4.0)
(C4 1.0) (C4 1.0) (B3 0.25) (C5 4.0) (C5 4.0) (C4 1.0))
See Also:
Item Streams,
multiple-item-bind
Last Modified: 5-Mar-1998