Class: MusicMagnitude
Environment: Siren
Instances of the subclasses of MusicMagnitude are used to represent scalar magnitudes in musical objects. The class MusicMagnitude is a place for the music magnitudes to share their state and basic accessing behavior.
MusicMagnitudes generally implement precise mixed-mode arithmetic and comparison methods using a per-species generality table and auto-coercion within a species.
The "type abstraction" classes (Duration, Pitch, Amplitude, etc.) represent "what"; they are never instantiated; their class creation methods answer instances of their species, but they manage coercion within the classes of their species. The "representational abstraction" classes (NominalMagnitude, OrdinalMagnitude, NumericalMagnitude, RatioMagnitude, etc.) represent "how"; they share value model semantics and coercion techniques. Note that the concrete implementation classes therefore answer their species by property model rather than by implementation subclass (i.e., HertzPitch species --> Pitch rather than NumericalMagnitude).
MusicMagnitudes can have dependents (observers), and send themselves the changed: message when their values are changed.
There are many examples in the implementation classes and the Siren outline.
Instance variables:
accessing
value
value
Answer the instance variable 'value'.
value: theValue
Accept the argument, 'theValue', as the new instance variable 'value'
and signal any dependents.
printing
Print the receiver on the argument as a MM declaration.
printOn: aStream parens: useParens
Print the receiver on the argument as a MM declaration.
printString
Answer a String whose characters are a description of the receiver.
printStringParens: bool
Answer a String whose characters are a description of the receiver.
printValue
storeOn: aStream
Store the receiver on the argument as a MM declaration.
units
Answer the units string of the receiver.
private
Answer MusicMagnitude.
converting
If I am involved in arithmetic with a number, convert me to a number.
coerceTo: type
Coerce the receiver to the given class and answer a new object.
ddMsgName
Answer the selector to be used in coercing double-dispatching messages.
msec
Answer a MSecondDuration.
usec
Answer a MSecondDuration.
testing
Answer whether the receiver has an immediate representation.
isMusicMagnitude
Answer true for the receiver and all subsclasses.
arithmetic
Answer the product of the receiver and the argument
+ aValue
Answer the sum of the receiver and the argument, doing generality-based
class coercion within a species using auto-generated coercion messages.
- aValue
Answer the difference of the receiver and the argument
/ aValue
Answer the quotient of the receiver and the argument
comparing
Answer whether the receiver is less than the argument
= aValue
Answer whether the receiver and the argument are equal.
hash
Answer a SmallInteger unique to the receiver.
MetaClass: MusicMagnitude class
instance creation
Answer and instance with the argument as its value.
class constants
Answer the default color to display instances with (hack for making pretty graphs).
propertyName
Answer the receiver class's default property name.
relativeMember
Answer the receiver class's species member used as a relative magnitude.
Class: PField
Instance variables:
Examples:
accessing
Superclass: Siren.MusicMagnitude
Category: Music-Models-Representation
Instance variables: name field
field
name
PField field: 5 value: 0.7 name: #position
PField field: 9 value: 'legato' name: #expression
Answer the instance variable 'field'.
field: theNumber
Accept the argument, 'theNumber', as the new instance nariable 'field'.
name
Answer the instance variable 'name'.
name: theName
Accept the argument, 'theName', as the new instance nariable 'name'.
MetaClass: PField class
instance creation
Answer an initialized instance.
field: aNumber value: aValue name: aName
Answer an initialized instance.
Class: MusicModel
See the class methods for generality.
Class inst Vars:
generality
Superclass: Siren.MusicMagnitude
Category: Music-Models-Representation
Class instance variables: generalityTable
generalityTable
Answer the class inst var for the generality table.
generalize: aMag and: otherMag
Answer an array of the two arguments with the most general first.
examples
Pitch generalize: (#c pitch) and: (21 key)
Class: Positus
Examples:
See also the class example.
instance creation
Superclass: Siren.MusicModel
Category: Music-Models-Representation
Instances of its subclass species are used to model spatial and positional values.
Superclass: Siren.Positus
Category: Music-Models-Representation
This class can be used as a concrete one (adding a few methods to fill it out), or like the other representational classes (making concrete classes of this species).
In the later case, the value instance variable would hold a 1- or 2-dimensional position as a number or point.
Superclass: Siren.MusicModel
Category: Music-Models-Representation
Instances of its subclass species are used to model loudness values.
Superclass: Siren.Positus
Category: Music-Models-Representation
This class can be used as a concrete one (adding a few methods to fill it out), or like the other representational classes (making concrete classes of this species).
In the later case, the value instance variable would hold a record with the geometry or the room, the positions of default sources, and the listener's position and features.
Superclass: Siren.Ergon
Category: Music-Models-Representation
Amplitudes come in several flavors, as in the classes RatioMagnitude, MIDIVelocity and SymbolicLoudness.
The class Amplitude is abstract, its class creation method answers an instance of a concrete Amplitude/Loudness class.
Amplitude value: 0.77 "create a ratio instance - range 0.0 to 1.0 (cmusic)"
Amplitude value: 77 "create an MIDI instance - range 0 to 127"
Amplitude value: #mp "create a symbolic instance - range #ppp to #fff"
Answer a new instance of a member of my species.
class constants
Answer the default color to display instances with.
initialize
Set up the class inst var, a generality table.
initializeGenerality
Set up the class inst var, a generality table.
mostGeneral
Answer the most general-purpose duration--relative
propertyName
Answer the receiver class's default property name.
relativeMember
Answer the receiver class's species member used as a relative magnitude.
species
Answer Amplitude.
examples
Print a simple message to the transcript demonstrating the various types.
Class: Position
Examples:
Note that new pitch representations such as music11-like pch (4.11 = 11th note in oct 4) or oct (4.1100 = oct4 + 1100 cts) notations can be added by overriding the float-to-Hz or float-to-midi conversions.
See also the class example.
instance creation
Superclass: Siren.Positus
Category: Music-Models-Representation
This class can be used as a concrete one (adding a few methods to fill it out), or like the other representational classes (making concrete classes of this species).
In the later case, the value instance variable could hold a number or point.
Superclass: Siren.MusicModel
Category: Music-Models-Representation
Instances of its subclass species are used to model pitches, gamut members, and frequencies.
Superclass: Siren.Chroma
Category: Music-Models-Representation
Pitches come in several flavors, as in the classes HertzPitch, RatioPitch, MIDIPitch and SymbolicPitch.
The class Pitch is abstract, its class creation method answers an instance of a concrete Pitch class.
Pitch value: 440.0 "create an instance with units of Hertz"
Pitch value: 77 "create an instance with units of MIDI key numbers"
Pitch value: #e4 "create a symbolic instance"
Pitch value: 'e4' "same as using a symbol"
Pitch value: 4/3 "create a ratio instance"
Answer a new instance of a member of my species.
class constants
Answer the default color to display instances with.
initialize
Set up the class inst var, a generality table.
initializeGenerality
Set up the class inst var, a generality table.
mostGeneral
Answer the most general-purpose duration--Hertz
propertyName
Answer the receiver class's default property name.
relativeMember
Answer the receiver class's species member used as a relative magnitude.
species
Answer Pitch.
examples
Print a simple message to the transcript demonstrating the various types.
exampleAdC
Pitch exampleAdC
Class: Chronos
Examples:
See also the class example.
instance creation
Superclass: Siren.MusicModel
Category: Music-Models-Representation
Instances of its subclass species are used to model times, durations and metronomes.
Superclass: Siren.Chronos
Category: Music-Models-Representation
Durations come in several flavors, as in the classes RatioDuration, MSecondDuration and ConditionalDuration.
The class Duration is abstract, its class creation method answers an instance of a concrete Duration class.
Duration value: 0.77 "create an instance with seconds as the unit"
Duration value: 770 "create an instance with milliseconds as the unit"
Duration value: 1/4 "create an instance with beats as the unit"
Duration value: [ :x | x > 4] "create an instance for: 'until x > 4'"
Answer a new instance of a member of my species.
class constants
Answer the default color to display instances with.
initialize
Set up the class inst var, a generality table.
initializeGeneralities
Set up the class inst var, a generality table.
mostGeneral
Answer the most general-purpose duration--seconds
propertyName
Answer the receiver class's default property name.
relativeMember
Answer the receiver class's species member used as a relative magnitude.
species
Answer Duration.
examples
Print a simple message to the transcript demonstrating the various types.
Class: Meter
Each subclass may decide whether instances or the class will hold the table of relationships.
See the subclass' class examples.
Instance Variable:
Class Instance Variable:
accessing
Superclass: Siren.Chronos
Category: Music-Models-Representation
This class can be used as a concrete one (adding a few methods to fill it out), or like the other representational classes (making concrete classes of this species).
In the later case, the value instance variable could hold a number, process or block.
Superclass: Siren.Chroma
Category: Music-Models-Representation
This class can be used as a concrete one (adding a few methods to fill it out), or like the other representational classes (making concrete classes of this species).
In the later case, the value instance variable could hold a number or pitch, and the mode or gamut could be shared.Music-Models-Implementation
Superclass: Siren.MusicMagnitude
Category: Music-Models-Implementation
Instance variables: table
Class instance variables: Table
They use the instance or class instance tables for holding comparative relationships among instances (e.g., mag1 might know that it's > mag2).
The relation-setting (i.e., order assignment) messages are: ==, >>, <<, =<, and =>.
The query messages are: =?, > < <=, and >=.
The decision should be made on the basis of the expected number of magnitude instances and the sparseness of their relationships.
table
Table
Answer a SmallInteger unique to the receiver. Essential. See
Object documentation whatIsAPrimitive.
table
Answer the receiver's loop-up table--its or the class'.
value
Signal an error.
value: theValue
Signal an error.
initialize-release
Release the receiver's table.
printing
Print the receiver as an ordinal magnitude.
converting
Answer that it is an error to attempt coercion with ordinal magnitudes.
ordering
Answer whether the receiver is less than the argument.
<< anotherOMag
Specify that the receiver is less than the argument.
<= anotherOMag
Answer whether the receiver is less than or equal to the argument.
=< anotherOMag
Specify that the receiver is less than or equal to the argument.
== anotherOMag
Specify that the receiver is equal to the argument.
=> anotherOMag
Specify that the receiver is greater than or equal to the argument.
=? anotherOMag
Answer whether the receiver is equal to the argument.
> anotherOMag
Answer whether the receiver is greater than the argument.
>= anotherOMag
Answer whether the receiver is greater than or equal to the argument.
>> anotherOMag
Specify that the receiver is greater than the argument.
arithmetic
Answer that it is an error to attempt arithmetic with ordinal magnitudes.
+ aValue
Answer that it is an error to attempt arithmetic with ordinal magnitudes.
- aValue
Answer that it is an error to attempt arithmetic with ordinal magnitudes.
/ aValue
Answer that it is an error to attempt arithmetic with ordinal magnitudes.
= aValue
Answer whether the receiver and the argument are equivalent.
MetaClass: OrdinalMagnitude class
table access
Answer the class' instance look-up table.
values
Answer the sorted values.
instance creation
Answer a new instance and, if it's in use, add it to the table.
value: aValue
Answer an instance
class initialization
Release the shared class table and all instances.
useTable
Set up a shared class table for all instances.
Class: NumericalMagnitude
One may want to add range-checking for these cases.
Note that the class NumericalMagnitude is vacuous at present, and exists solely for representational modeling.
double dispatching
Superclass: Siren.MusicMagnitude
Category: Music-Models-Implementation
When the values are floating-point numbers, the range is often 0.0 to 1.0.
Integer ranges such as 0 to 127 can also be used in subclasses.
adaptToInteger
MetaClass: NumericalMagnitude class
printing
Superclass: Siren.NumericalMagnitude
Category: Music-Models-Implementation
This is the most general Pitch representation.
The value is assumed to be a floating-point number.
Print the receiver as a pitch string in Hertz.
units
Answer the units string of the receiver.
private
Answer Pitch.
converting
Assuming value is a frequency, Answer a fractional key number
asFracSymbol
Assuming value is a frequency, answer a symbolic note name
asHertz
Answer a HertzPitch.
asHz
Answer a HertzPitch.
asMIDI
Assuming value is a frequency, Answer a key number
asSymbol
Assuming value is a frequency, answer a symbolic note name
MetaClass: HertzPitch class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: RatioMagnitude
Instance Variable:
accessing
Superclass: Siren.NumericalMagnitude
Category: Music-Models-Implementation
Instance variables: relative
relative
Answer the receiver's value mapped to the receiver.
value
Answer the receiver's value mapped to the receiver.
converting
Answer self.
map
Apply the receivers reference.
relativeTo: aRelative
Set the receivers reference.
MetaClass: RatioMagnitude class
instance creation
Answer and instance with the argument as its value.
Class: RatioPitch
private
Superclass: Siren.RatioMagnitude
Category: Music-Models-Implementation
They can be transformed into other values (e.g., note names or key numbers), but often at a loss of accuracy if they are not well-tempered.
Answer Pitch.
printing
Print the receiver as a ratio.
converting
return a RatioPitch as a fractional MIDINote.
asFracSymbol
Assuming value is a ratio, answer a symbolic note name
asHertz
Answer a HertzPitch.
asMIDI
return a RatioPitch as a MIDINote (rounded).
asSymbol
Assuming value is a ratio, answer a symbolic note name
mostGeneral
Answer the most numerically meaningful version of the receiver.
MetaClass: RatioPitch class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: RatioLoudness
private
Superclass: Siren.RatioMagnitude
Category: Music-Models-Implementation
Answer Amplitude.
printing
Print the receiver as a ratio.
converting
Answer a dB loudness; ratio 1 = 0dB, ratio 0.5 = -6dB, etc.
asMIDI
Answer a MIDI key velocity (0 to 127)
asSymbol
Answer a symbolic dynamic.
MetaClass: RatioLoudness class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: IntervalMagnitude
accessing
Superclass: Siren.NumericalMagnitude
Category: Music-Models-Implementation
Class instance variables: range
Accept theValue, as the new instance variable 'value' -- perform range-checking
MetaClass: IntervalMagnitude class
class inst var access
Answer the class' range.
range: anInterval
Set the class' range.
Class: ConditionalDuration
See the class examples.
updating
Superclass: Siren.MusicMagnitude
Category: Music-Models-Implementation
The accessing protocol allows them to be spawned as co-processes in schedulers.
The valueAt: and waitUntil: methods allow flexible conditional scheduling.
ConditionalDurations can be made dependents of other objects using the until: instance creation message.
Respond to a change in the receiver's model
accessing
Answer the result of passing the argument to the receiver's block.
wait
Cycle the receiver until the argument fulfills the receiver's block.
waitUntil: anArg
Cycle the receiver until the argument fulfills the receiver's block.
private
Answer Duration.
converting
It is an error to try this here--we implement what's ok for CDs
arithmetic
Answer that it is an error to attempt arithmetic with this magnitude.
+ aDuration
Answer the sum of the receiver and the argument--the composition of two blocks
- aValue
Answer that it is an error to attempt arithmetic with this magnitude.
/ aValue
Answer that it is an error to attempt arithmetic with this magnitude.
MetaClass: ConditionalDuration class
instance creation
Answer a new conditional duration whose value is the given block
randomBetween: lo and: hi
Answer a new conditional duration whose value is between lo and hi (given in seconds)
until: boolBlock
Answer a new conditional duration whose value is the given block
examples
Print a simple message to the transcript demonstrating the various types.
exampleWithRands
Demonstrate the random duration
Class: Length
See the class examples.
private
Superclass: Siren.OrdinalMagnitude
Category: Music-Models-Implementation
The instance variable tables are used for the name -> relation symbol map.
Answer Duration.
MetaClass: Length class
examples
Demonstrate the use of an OrdinalMagnitude with a scale of length.
Class: NominalMagnitude
Class Instance Variable:
class instance variables
Superclass: Siren.MusicMagnitude
Category: Music-Models-Implementation
Class instance variables: NameMap
Examples are pitch (#d4) or dynamic (#mp) names.
NameMap
Answer the class instance variable NameMap.
Class: SymbolicLoudness
The class instance variable NameMap is used for the name <--> MIDI velocity range (0 to 127) mapping dictionary.
printing
Superclass: Siren.NominalMagnitude
Category: Music-Models-Implementation
Print the receiver as a symbolic amplitude.
units
Answer the units string of the receiver.
private
Answer Amplitude.
converting
Answer a dB loudness; ratio 1 = 0dB, ratio 0.5 = -6dB, etc.
asMIDI
Answer a MIDIVelocity.
asRatio
Answer a RatioLoudness.
asSymbol
Answer a SymbolicLoudness.
mostGeneral
Answer the most numerically meaningful version of the receiver.
MetaClass: SymbolicLoudness class
class initialization
Set up the class dynamic mapping dictionary
instance creation
Assuming value is a key velocity, answer a symbolic loudness name
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: Sharpness
See the class examples.
private
Superclass: Siren.OrdinalMagnitude
Category: Music-Models-Implementation
The instance variable tables are used for the name -> relation symbol map.
Answer Pitch.
MetaClass: Sharpness class
examples
Demonstrate the use of an OrdinalMagnitude with a scale of sharpness.
Class: MIDIPitch
The translation key <--> Hz. is done with the logarithm or 27.5 Hz. (very low A = 440/16).
Note that AdC's additions make fractional MIDI pitches possible, whereby the first 2 digits to the right of the decimal point signify pitch cents. There are coercion methods such as asFracMIDI for handling microtonal MIDI pitches.
printing
Superclass: Siren.IntervalMagnitude
Category: Music-Models-Implementation
Answer the units string of the receiver.
private
Answer Pitch.
converting
Answer a fractionalMIDIPitch (or integer if value is no fraction).
asFracSymbol
Assuming value is a key number, answer a symbolic pitch name
asHertz
Assuming value is a key number, answer a frequency
asHz
Assuming value is a key number, answer a frequency
asMIDI
Answer a MIDIPitch.
asSymbol
Assuming value is a key number, answer a symbolic pitch name
mostGeneral
Answer the most numerically meaningful version of the receiver.
MetaClass: MIDIPitch class
class initialization
Initialize the class instance variable.
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: DBLoudness
printing
Superclass: Siren.RatioLoudness
Category: Music-Models-Implementation
Answer the units string of the receiver.
double dispatch
Subtract the argument from the receiver after turning both into db.
differenceFromVelocity: aDyn
Subtract the argument from the receiver after turning both into db.
productFromDynamic: aDyn
Multiply the argument by the receiver after turning both into db.
productFromVelocity: aDyn
Multiply the argument by the receiver after turning both into db.
quotientFromDynamic: aDyn
Divide the argument by the receiver after turning both into db.
quotientFromVelocity: aDyn
Divide the argument by the receiver after turning both into db.
sumFromDynamic: aDyn
Add the argument to the receiver after turning both into db.
private
Answer Amplitude.
converting
Answer a MIDI key velocity (0 to 127)
asRatio
Answer the receiver as a ratio between 0 and 1.
positiveDB
Answer the zero-based positive dB value of the receiver.
MetaClass: DBLoudness class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: RatioDuration
printing
Superclass: Siren.RatioMagnitude
Category: Music-Models-Implementation
They can be expanded into msec. relative to some given event (a whole note), or use the default tempo of 1 sec.
Print the receiver as a fractional duration.
units
Answer the units string of the receiver.
private
Answer Duration.
double dispatching
Answer a MM whose value is the argument over the receiver's value.
converting
Answer a MSecondDuration.
asMsec
Answer a MSecondDuration.
asSec
Answer a SecondDuration.
asUsec
Answer a USecondDuration.
asUseconds
Answer a USecondDuration.
mostGeneral
Answer the most numerically meaningful version of the receiver.
MetaClass: RatioDuration class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: SecondDuration
printing
Superclass: Siren.NumericalMagnitude
Category: Music-Models-Implementation
This is among the most general duration time representations.
Print the receiver on the argument as a MM declaration.
units
Answer the units string of the receiver.
process delay
Delay for a time corresponding to the receiver
private
Answer the receiver in seconds.
species
Answer Duration.
converting
Answer a float of seconds.
asBeat
Answer a RatioDuration.
asMS
Answer a MSecondDuration.
asMsec
Answer a MSecondDuration.
asMseconds
Answer a MSecondDuration.
asRatio
Answer a RatioDuration.
asSec
Answer a float of seconds.
asSeconds
Answer a float of seconds.
asUsec
Answer a USecondDuration.
asUseconds
Answer an int of micro seconds.
MetaClass: SecondDuration class
-- all --
Answer the selector to be used in coercing double-dispatching messages.
Class: MSecondDuration
printing
Superclass: Siren.SecondDuration
Category: Music-Models-Implementation
Answer the units string of the receiver.
converting
Answer a MSecondDuration.
asSeconds
Answer a float of seconds.
asUseconds
Answer a float of micro seconds.
MetaClass: MSecondDuration class
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: USecondDuration
printing
Superclass: Siren.SecondDuration
Category: Music-Models-Implementation
This is the default time representation (most general duration) and is usually used for keys in event lists.
Answer the units string of the receiver.
converting
Answer a MSecondDuration.
asSeconds
Answer a float of seconds.
asUseconds
Answer a float of micro seconds.
MetaClass: USecondDuration class
Instance Variables:
The class instance variable NameMap is used for the name <--> MIDI key number mapping array.
printing
Superclass: Siren.NominalMagnitude
Category: Music-Models-Implementation
Instance variables: fracPitch
The range is c0 to g#9 and the values are symbols.
Note the confusion between the sharp sign (always placed after the note name) and Smalltalk's symbol key #.
One often writes ('c#3' asSymbol) to be safe.
fracPitch
Print the receiver as a symbolic pitch.
units
Answer the units string of the receiver.
arithmetic
Answer the sum of the receiver and the argument-handle adding Integers as a special case.
- aValue
Answer the sum of the receiver and the argument-handle adding Integers as a special case.
transposeBy: aValue
transpose a SymbolicPitch by aValue in fractional halfsteps
private
Answer Pitch.
converting
Assuming value is a symbolic note name, answer a key number.
asHertz
assuming value is a symbolic note name, return a frequency
asHz
assuming value is a symbolic note name, return a frequency
asMIDI
Assuming value is a symbolic note name, answer a key number.
asSymbol
Answer a SymbolicPitch.
mostGeneral
Answer the most numerically meaningful version of the receiver.
accessing
Answer the receiver's accidental, if any.
fracPitch
return microtonal offset as fractions of a halfstep
fracPitch: aValue
set microtonal offset as fractions of a halfstep
MetaClass: SymbolicPitch class
class initialization
Set up the class name mapping array.
instance creation
Assuming value is a key number, answer a symbolic pitch name
fromMIDI: aValue
Assuming value is a key number, answer a symbolic pitch name
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: MIDIVelocity
The SymbolicLoudness class maps symbolic dynamic names onto this range on an approximately logarithmic scale.
accessing
Superclass: Siren.IntervalMagnitude
Category: Music-Models-Implementation
Truncate
printing
Print the receiver as a MIDI velocity.
units
Answer the units string of the receiver.
private
Answer Amplitude.
converting
Answer a dB loudness; ratio 1 = 0dB, ratio 0.5 = -6dB, etc.
asMIDI
Answer a MIDIVelocity.
asRatio
Answer a RatioLoudness.
asSymbol
Answer a symbolic loudness.
mostGeneral
Answer the most numerically meaningful version of the receiver.
MetaClass: MIDIVelocity class
class initialization
Initialize the class instance variable.
coercion
Answer the selector to be used in coercing double-dispatching messages.
Class: MeasureDuration
It is partially implemented and unused.
Instance Variables:
printing
Superclass: Siren.NumericalMagnitude
Category: Music-Models-Implementation
Instance variables: timeSignature
timeSignature
Answer the units string of the receiver.
private
Answer Duration.
MetaClass: MeasureDuration class
Instance variables:
The global dictionary called Events can be used for sharing event instances.
accessing
Music-Events
Superclass: Object
Category: Music-Events
Instance variables: properties
properties
Add the argument as a property of the receiver.
date
Answer the receiver's 'date'.
date: obj
Set the receiver's 'date'.
inspect
Inspect the receiver--Use a special inspector for Event types
name
Answer the receiver's 'name'.
open
Edit, play (if
Answer AEvent--all subclasses look like me
version
Answer the receiver's 'version'.
version: obj
Set the receiver's 'version'.
printing
display: showHide field: filter on: stream
displayField: filter on: stream
printOn: aStream
Format and print the receiver on the argument.
storeOn: aStream
Format and store the source the receiver on the argument.
templateFields
Answer the field names for the instances of the receiver class.
scheduling
Perform or interpret the receiver on the argument; override in subclasses.
properties
Answer a value from the property list dictionary (or an instVar).
at: aProp ifAbsent: otherCase
Answer a value from the property list dictionary or the value of the given block.
at: aProp put: aVal
Set a value in the receiver's property list dictionary (or instVar).
doesNotUnderstand: aMessage
Handle doesNotUnderstand: to try to access the property dictionary.
If this is unsuccessful, announce that the receiver does not understand the argument.
hasProperty: aSymbol
Answer whether or not the receiver's property list dictionary includes the symbol as a key.
properties
Answer the receiver's property list dictionary.
respondsTo: aSymbol
Answer whether the method dictionary of the receiver's class contains
aSymbol as a message selector OR if the selector is unary and is a key
in the receiver's property dictionary.
initialize-release
Set up the default state of the receiver--add props. dict.
release
Flush the receiver.
private
Make sure the receiver has a property list dictionary.
testing
Answer true.
isSound
Answer false.
comparing
Answer whether the receiver and the argument represent the same values.
MetaClass: AbstractEvent class
examples
Demonstrate the creation of an AEvent.
example
Demonstrate the creation of an AEvent.
Class: DurationEvent
Instance variables:
accessing
Superclass: Siren.AbstractEvent
Category: Music-Events
Instance variables: duration index startedAt realTime
duration
Answer the receiver's ampl
dur
Answer the receiver's duration.
dur: newValue
Set the receiver's duration.
duration
Answer the receiver's duration.
duration: newValue
Set the receiver's duration.
index: aNumber
Set the receiver's event index.
order
Answer the receiver's order.
order: anOrder
Set the receiver's order.
pitch
Answer the receiver's pitch
voice
Answer the receiver's voice or some reasonable default.
voice: aValue
Set the receiver's voice to the argument.
printing
Format and print the receiver on the argument.
storeOn: aStream
Format and store the source the receiver on the argument.
scheduling
Answer whether the receiver is in a schedule
nextTime: ignored
Answer whether to reschedule the receiver
play
Play the receiver by scheduling it.
playAt: aTime
Play the receiver on its voice then.
playOn: aVoice at: aTime
This is a no-op in the abstract class
reset
Reset the receiver's index.
scheduleAt: aTime
Play the receiver on its voice then.
comparing
Answer whether the receiver and the argument represent the same values.
initialize-release
Set up the default state of the receiver--add props. dict.
MetaClass: DurationEvent class
examples
Demonstrate the creation of a DEvent.
example
Demonstrate the creation of a DEvent.
instance creation
Answer a DurationEvent instance initialized with the arguments.
Class: MusicEvent
Instance variables:
accessing
Superclass: Siren.DurationEvent
Category: Music-Events
Instance variables: pitch loudness voice
pitch
loudness
voice
Answer the receiver's loudness
ampl: aValue
Set the receiver's loudness to the argument.
amplitude
Answer the receiver's loudness
amplitude: aValue
Set the receiver's loudness to the argument.
loudness
Answer the receiver's loudness
loudness: aValue
Set the receiver's loudness to the argument.
pitch
Answer the receiver's pitch
pitch: aValue
Set the receiver's pitch to the argument.
voice
Answer the receiver's voice
voice: aValue
Set the receiver's voice to the argument.
processing
Add the given step to the receiver's pitch.
printing
Format and print the receiver on the argument.
printTerseOn: aStream
Format and print the receiver on the argument as tersely as possible.
printVerboseOn: aStream
Format and print the receiver on the argument.
readDataFrom: aDataStream size: size
Read a new event from the given stream using the compact format.
storeDataOn: aDataStream
Store myself on a DataStream. Answer self.
storeOn: aStream
Format and store the source the receiver on the argument.
comparing
Answer whether the receiver and the argument represent the same values.
scheduling
Play the receiver on the voice then.
MetaClass: MusicEvent class
instance creation
Answer a MusicEvent instance initialized with the arguments.
dur: aD ampl: anA voice: aVoice
Answer a MusicEvent instance initialized with the arguments.
dur: aD pitch: aP
Answer a MusicEvent instance initialized with the arguments.
dur: aD pitch: aP ampl: anA
Answer a MusicEvent instance initialized with the arguments.
dur: aD pitch: aP ampl: anA voice: aVoice
Answer a MusicEvent instance initialized with the arguments.
dur: aD pitch: aP voice: aVoice
Answer a MusicEvent instance initialized with the arguments.
dur: aD voice: aVoice ampl: anA
Answer a MusicEvent instance initialized with the arguments.
duration: aD pitch: aP
Answer a MusicEvent instance initialized with the arguments.
duration: aD pitch: aP ampl: anA
Answer a MusicEvent instance initialized with the arguments.
pitch: aP
Answer a MusicEvent instance initialized with the argument.
pitch: aP ampl: anA voice: aVoice
Answer a MusicEvent instance initialized with the arguments.
class initialization
Initialize the global dictionary of Events (optional).
initializeEventDictionary
Initialize the global dictionary of Events (optional).
examples
Demonstrate the terse format of event description.
example
Demonstrate the terse format of event description.
Class: EventList
Class EventList implements much collection-style protocol for event processing, as well as having special block application methods. All EventList algorithms are recurrsive in order to handle arbitrarily-deep hierarchical EventLists (possible because EventList is a subclass of DurationEvent). The class also has numerous powerful and flexible instance creation methods.
Instance Variables:
Standard properties are #tempoScale for the tempo scaling factor (used by the CMN editors as the MS/whole note scale), and #code (#duration, #delta, or #startStop) to support different event coding schemes. The class also supports typed links to other event lists, e.g., "eList1 isTonicAnswerOf: eList2" or "eList1 hasPreviousVersion: eList2", which can be very useful properties in editors and browsers.
The global dictionary EventLists holds onto instances that can be referenced with their name symbols; these can have gensym-like names such as #temp.23. Creating a named EventList automatically adds it to the global dictionary. There are tools for browsing and maintaining this dictionary.
accessing
Superclass: Siren.MusicEvent
Category: Music-Events
Instance variables: events
events
the list's events, time/event associations sorted by relative start times
index
startedAt
Add the given event modifier to the receiver's special modifier collection
code
Answer a symbol about the receiver's events' coding, usually #durations or #noteOnOff
code: aSymbol
Set the code about the receiver's events, usually #durations or #noteOnOff
deepCopy
Answer a careful deep copy.
defaultEventClass
Answer the default note event class.
name
Answer the receiver's name.
name: aName
Set the receiver's name.
next
Answer the next event in the list.
removeModifier: aModifier
Remove the given event modifier from the receiver's collection.
shallowCopy
Answer a shallow copy of the receiver's events.
size
Answer the number of events in the receiver.
tempo: someValue
Set the tempo to scale the events by.
voices
Answer the collection of voices used by thereceiver event list.
code conversion
Fill in missing properties with values that are continued from previous ones.
findNoteOff: anAssociation
Locate the noteOff event that corresponds to anAssociation; answer the sum of the delta times between (the duration)
setDurations
Take a delta-time encoded event list and determine the durations.
collecting
Iterate over the receiver's events with the given block
collectAll: aBlock
Iterate over the receiver's events with the given block
do: aBlock
Iterate over the receiver's event associations with the given block
eventsDo: aBlock
Iterate over the receiver's events with the given block
excerptFrom: start to: end
Answer a hierarchical list delineated by the given times.
expanded
Expand all sub-event lists and answer one large flat list.
expandedFrom: start to: end
Expand all sub-event lists and answer one flat list with events between the given times.
group: selection
Group the argument's events as a sub-event list in the receiver's list.
includes: anAss
Answer whether the given association is in the receiver's event list.
keysAndValuesDo: aBlock
remove: anA
Remove the given event from the receiver's collection
select: aBlock
Iterate over the receiver's events with the given block
selectAll: aBlock
Iterate over the receiver's events with the given block
selectKey: aBlock
Iterate over the receiver's events with the given block
selectValue: aBlock
Iterate over the receiver's events with the given block
timesDo: aBlock
Iterate over the receiver's events' relative start times with the given block
printing
asExplorerString: ignored
printOn: aStream
Print out the receiver's events on the argument.
readDataFrom: aDataStream size: size
Read a new event list from the given stream using the compact format.
storeDataOn: aDataStream
Store myself on a DataStream. Answer self.
storeOn: aStream
Store source code for the receiver's events on the argument.
storeOnFile: aName
Store out the receiver's events on the file named by the argument.
templateFields
Answer the field names for the instances of the receiver class.
processing
Add theValue to the aspect refered to by theSelector of all events.
applyBlock: theBlock toProp: theSelector
Apply the given block to the aspect refered to by theSelector of all events.
applyFunction: aFunction to: aSelector
Apply the given function to the range of the given selector
applyFunction: aFunction to: aSelector startingAt: sTime
Apply the given function to the range of the given selector starting at sTime.
chooseRange: theRange toProp: theSelector
Select a value from the given range for the aspect refered to by theSelector of all events.
edit
Open your favorite graphical editor on the receiver (left-shift-sensitive)
scale: theSelector by: theValue
Multiply the aspect refered to by theSelector of all events by theValue.
scaleStartTimesBy: theValue
Multiply the start times all events by theValue.
scaleValue: theValue toProp: theSelector
Multiply the aspect refered to by theSelector of all events by theValue.
setValue: theValue toProp: theSelector
Set the aspect refered to by theSelector of all events to theValue.
spreadValue: theRandomPercent toProp: theSelector
Spread the given property of all events by the given random range (%+-).
testing
Answer whether or not the receiver has items or components (true).
isEmpty
Answer whether the receiver is an event list (true).
isEventList
Answer whether the receiver is an event list (true).
species
Answer EventList.
scheduling
Play the event list by passing it off to the event scheduler.
nextTime: now
Answer the time of the next appointment
nextTimeFor: ass
Answer the time delay between the given event association and the one that follows it.
play
Play the event list by passing it off to the event scheduler.
playOn: aVoice
Play the event list on the voice by expanding its events
playOn: aVoice at: startTime
Play the event list on the voice by expanding its events
scheduleAt: aTime
Expand an eventList for the appointment scheduler.
stop
Play the event list by passing it off to the event scheduler.
initialize-release
Throw away the receiver's events.
initializeAnonymous
Initialize an un-named instance with default state.
initializeNamed: aName
Initialize a named instance with default state.
release
Flush the receiver.
event accessing
Add a new event or association to the receiver.
add: anEorA
Add a new event or association to the receiver.
add: anEvent at: aTime
Add a new event to the receiver at the given relative start time.
addAll: anEventList
Add the given event list's events to the receiver.
eventKeys
Answer the keys (durations) of the receiver's eventDictionary.
eventNear: aPoint
Answer an event within a reasonable distance (100 msec.) of the given point's x.
eventNearestTime: aTime
Answer an event within a reasonable distance (32 msec.) of the given point.
eventNearTime: aTime
Answer an event within a reasonable distance (32 msec.) of the given point.
events
Answer the receiver's eventDictionary.
events: anEL
Set the receiver's eventDictionary.
eventValues
Answer the values (events) of the receiver's eventDictionary.
recomputeDuration
Recompute the total duration of the receiver.
private
Map the receiver's special properties and/or eventModifiers onto the given event.
map: anAssociation at: startTime
Map the receiver's special properties and/or eventModifiers onto the given event.
comparing
Answer whether the receiver and the argument represent the same events.
MetaClass: EventList class
examples
Select the expressions below one-at-a-time and inspect the results.
randomExample
Create an event list with random data.
randomExample: length
Create an event list with random data.
randomExample: length from: data
Create an event list with random data.
randomSWSSExample
Create an event list with random data appropriate for software sound synthesis.
randomSWSSExample2
Create an event list with random data appropriate for software sound synthesis.
scaleExample2
Answer a scale where the event property types are mixed.
scaleFrom: start to: stop in: dur
Answer an event list with a scale.
sentenceExample
Create an event list for a beautiful sentence.
serialExample: length from: data
Create an event list with serial data.
wordExample
Create an event list for a long word.
class initialization
Erase the shared EventList dictionary and try to clean up all events.
initialize
Initialize the shared EventList dictionary.
storeAll
Write out all event lists.
named constants
Answer the named instance from the dictionary or a new EL.
named: aName ifAbsent: theBlock
Answer the named instance from the dictionary or the result of the block.
namedLists
Answer the dictionary of named event lists.
newNamed
Answer the named instance with a temp name.
newNamed: aName
Create and answer a new named (and stored) instance.
nextName
Answer a gensym-type ('te6') event list name for which no EL exists in the dictionary.
instance creation
Create and answer a new default-named instance of me
fromFile: theName
Create and answer a new default un-named (and therefore un-persistent) instance of me
named: myName fromPitches: pitchCollection
Answer an event list made with the given collection of pitches.
named: myName fromSelectors: selArray values: valueArrayArray
Answer an event list made with the given collection of values applied to the given array of selectors.
named: myName fromStartTimes: timeCollection
Answer an event list with the given collection of relative start times.
new
Create and answer a new default-named instance of me
new: ignored
Create and answer a new default-named instance of me
newAnonymous
Create and answer a new default un-named (and therefore un-persistent) instance of me
Class: ActionEvent
Instance variables:
scheduling
Superclass: Siren.DurationEvent
Category: Music-Events
Instance variables: action
Indexed variables: objects
action
Play the receiver by executing its action block.
playAt: aTime
Play the receiver by executing its action block.
accessing
Answer the receiver's 'action'.
action: anObject
Set the receiver's instance variable 'action' to be anObject.
MetaClass: ActionEvent class
examples
Demonstrate the creation of an ActionEvent.
listExample
Demonstrate the creation of an ActionEvent by making a list of events that draw rectangles on the top window.
playExample
Demonstrate the performance of a list of ActionEvents.
instance creation
Answer an ActionEvent instance initialized with the arguments.
dur: aD block: actionBlock
Answer an ActionEvent instance initialized with the arguments.
Class: EventGenerator
playing
Superclass: Siren.EventList
Category: Music-EventGenerators
An EventGenerator can create an EventList using its given parameters and a function (block) to use to create Event sequences. See the subclasses for examples.
edit me
eventList
Answer an eventList for the receiver.
play
Play the receiver's event list.
MetaClass: EventGenerator class
accessing instances
Find the and return instances of me or any subclasses of me.
allPlaying
Find all playing instances of me or my subclasses.
named: aName
Find the named instance of me or a subclass of me.
stopAll
Find all playing instances of me or my subclasses and terminate them.
examples
Play random examples from the set of examples in my subclasses
Class: Cloud
Instance variables:
accessing
Superclass: Siren.EventGenerator
Category: Music-EventGenerators
Instance variables: density
This can be (e.g.,) POD-style specification of ranges for random selection, or selection from a given set of pitches.
See the class examples of my subclasses for description examples.
density
set the density instance variable
playing
Make the cloud's events; assume that the receiver's pitch, loudness and
durations are actually intervals
eventList0
Make the cloud's events; assume that the receiver's pitch, loudness and
durations are actually intervals
MetaClass: Cloud class
examples
Answer an initialized Cloud generated from the given property map dictionary.
example1
Create and edit a low 6 second stochastic cloud with 5 events per second
randomExample
Play a stochastic cloud with random properties.
randomExample2
Play a stochastic cloud with random properties.
instance creation
return an initialized Cloud
dur: aD pitch: aP ampl: anA voice: aVoice
return an initialized Cloud
dur: aD pitch: aP ampl: anA voice: aVoice density: aDe
return an initialized Cloud
dur: aD voice: aVoice density: aDe
return an initialized Cloud
fromDictionary: aDictionary
Answer an initialized Cloud generated from the given property map dictionary.
Class: Peal
Instance variables:
playing
Superclass: SequenceableCollection
Category: Music-EventGenerators
Instance variables: base directions position finished
Indexed variables: objects
This implementation was written by Mark Lentczner in 1986.
base
directions
position
finished
play
playOn0: out durations: dur meter: mtr at: start
Play the receiver
playOn: vox
playOn: out durations: dur meter: mtr at: start
Play the receiver
accessing
Answer the element in the base collection currently mapped into the index position.
at: index put: object
currentChange
Answer the base as mapped by the current change.
finished
Answer is the peal has completed it's last change
setBase: baseSet
Initialize the base set and everything else.
size
Redone here because SequencableCollection overrides it.
private
Produce the next change in the peal by moving the element n within the range. If the element wants to move outside the range, alter it's direction and move the next element (recursively call this).
indexOfElement: n