1 title:: Understanding Streams, Patterns and Events - Part 5
2 summary:: Event.default
3 related:: Tutorials/Streams-Patterns-Events1, Tutorials/Streams-Patterns-Events2, Tutorials/Streams-Patterns-Events3, Tutorials/Streams-Patterns-Events4, Tutorials/Streams-Patterns-Events6, Tutorials/Streams-Patterns-Events7
4 categories:: Streams-Patterns-Events>Understanding-Streams-Patterns-and-Events
6 More about the default Event:
10 The protoEvent contains default values for many useful parameters.
12 The default protoEvent is code::Event.default::. It provides default bindings for duration, envelope, instrument, making a very simple Pattern directly playable:
16 // an endless sequence of middle Cs
21 By adding other bindings, you can override the defaults in the protoEvent.
25 // duration 0.25 beats (16th notes)
26 Pbind( \dur, 0.25 ).play
32 // specifying the pitch in terms of midinote
33 // see also The pitch model below
37 \midinote, Pseq(#[60, 62, 64, 65, 67, 69, 71, 72], inf)
44 Event.default contains a function bound to the Symbol code::'finish':: which is called for each new event generated in order to complete any computations that depend on the other values in the event.
46 section::The pitch model
48 Event.default implements a multi level pitch model which allows composition using modal scale degrees, equal division note values, midi note values, or frequencies in Hertz. These different ways of specifying the pitch can all be used interchangably.
50 The way this works is due to the default values bound to the Symbols of the pitch model.
52 The lowest level Symbol in the pitch model is code::'freq'::. The default binding for code::'freq':: is a link::Classes/Function:: which calculates the frequency by getting the value of code::'midinote'::, adding a transpose value and converting it to Hertz using code::midicps::.
56 (~midinote.value + ~ctranspose).midicps;
60 If you compose with code::'freq':: directly then this default function is overridden.
66 \freq, Pseq(#[300, 400, 500, 700, 900], inf)
71 Event.default's code::'finish':: function sends the value message to the current binding of code::'freq':: in order to get the value for the frequency and adds a detune value to it which transposes the frequency in Hertz.
78 \freq, Pseq(#[300, 400, 500, 700, 900], inf)
83 The next level is code::'midinote':: which is by default bound to this function:
87 (~note.value + ~gtranspose + (~octave * divs) + ~root)
88 * 12.0 / ~stepsPerOctave;
92 This function gets the value bound to code::'note':: which is a value expressed in some equal temperament, not necessarily 12. It adds a gamut transpose value code::'gtranspose'::, and scales from the number of notes per octave being used into 12 notes per octave MIDI key values. If you compose with code::'midinote':: directly then that will override this function.
98 \midinote, Pseq([ Pshuf(#[60, 61, 62, 63, 64, 65, 66, 67], 3) ], inf)
103 Another level higher is code::'note':: which is defined by default by this function:
108 divs = ~stepsPerOctave;
109 (~degree + ~mtranspose).degreeToKey(~scale, divs);
113 This function derives the note value from the next higher level variables which specify a pitch from a scale. These variables are defined as follows:
116 ~stepsPerOctave = 12.0;
119 The number of equal divisions of an octave for this tuning. The equal temperament defined by this variable is known as the gamut. If you wanted to work in cents for example you could set this to 1200.0.
125 The current octave. Middle C is the lowest note in octave 5.
131 The root of the scale given in equal divisions defined by code::~stepsPerOctave::.
134 ~scale = #[0, 2, 4, 5, 7, 9, 11]; // diatonic major scale
137 A set of scale pitches given in equal divisions defined by code::~stepsPerOctave::.
143 A scale degree index into the code::~scale::. 0 is the root and the scale wraps in the manner defined by code::degreeToKey::.
149 A modal transposition value that is added to the scale degree.
155 A gamut transposition value that is added to the gamut pitch.
161 A chromatic transposition value expressed in semitones.
163 section::Pitch model Examples
167 // a simple scale degree sequence
169 // -7 is 8ve below, -3 is a 4th below,
170 // 0 is root, 2 is 3rd above, 4 is 5th above, 7 is 8ve above.
171 \degree, Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], inf),
182 \degree, Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], inf)
191 \scale, [0, 2, 3, 5, 7, 8, 10],
192 \degree, Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], inf)
198 // modal transposition
200 notes = Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], 1);
222 // chromatic transposition
224 notes = Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], 1);
246 // frequency detuning
248 notes = Pseq([ Pshuf(#[-7,-3,0,2,4,7], 4), Pseq([0,1,2,3,4,5,6,7]) ], 1);
270 // chords. If an Array of pitches is returned by a Stream for pitch, then a chord
275 Pshuf(#[-7,-3,0,2,4,7], 4)+[0,4],
276 Pseq( [0,1,2,3,4,5,6,7] )+[0,2]
283 // composing in non 12 equal temperaments. 72 tone equal temp.
287 // 1/1, 7/6, 3/2, 7/4, 9/8
288 Pseq([ [0,16,42,58,84], Pseq([ 0, 16, 42, 58, 72, 84 ], 2), [0,16,42,58,84] ], 1),
289 // 1/1, 6/5, 3/2, 9/5, 9/8
290 Pseq([ [0,19,42,61,84], Pseq([ 0, 19, 42, 61, 72, 84 ], 2), [0,19,42,61,84] ], 1),
291 // 1/1, 5/4, 3/2, 15/8, 9/8
292 Pseq([ [0,23,42,65,84], Pseq([ 0, 23, 42, 65, 72, 84 ], 2), [0,23,42,65,84] ], 1),
293 // 1/1, 9/7, 3/2, 27/14, 9/8
294 Pseq([ [0,26,42,68,84], Pseq([ 0, 26, 42, 68, 72, 84 ], 2), [0,26,42,68,84] ], 1)
296 \dur, Pseq([ 1.2, Pseq([0.15], 12), 1.2], inf)
301 section::The duration model
303 Duration is expressed in beats and is bound to the code::'dur':: symbol. The sustain time of a note can be expressed directly in beats or by using a legato value which is multiplied by the note duration to get the sustain time.
309 \dur, Pseq([ Pgeom(0.05, 1.1, 24), Pgeom(0.5, 0.909, 24) ], inf),
310 \midinote, Pseq(#[60, 58], inf)
316 // changing legato value
319 \legato, Pseq([ Pseries(0.05, 0.05, 40), Pseries(2.05, -0.05, 40) ], inf),
320 \midinote, Pseq(#[48, 51, 55, 58, 60, 58, 55, 51], inf)
325 To go to the next file:
326 link::Tutorials/Streams-Patterns-Events6::