Other event and pattern shortcuts various shortcut writings for events and patterns


Part of: miSCellaneous


See also: EventShortcuts, PLx and live coding with Strings


Apart from the class EventShortcuts itself, which handles bookkeeping of shortcut dictionaries, miSCellaneous lib includes some additional shortcut methods for generation and playing of events and different types of event patterns from SequenceableCollections. These methods support functional conventions for reference.



1.) Event shortcuts


1a: Event methods 


anEvent.on

Plays an Event. If dur isn't specified it is set to inf.

anEvent.off(releaseTime)

Releases the Event's node. 

releaseTime - SimpleNumber for release time. Defaults to nil (default release time of event mechanism)




Examples

(

s = Server.local;

Server.default = s;

s.boot;

)


// start default synth


x = ().on



// release with 3 seconds releaseTime 


x.off(3)



// with EventShortcuts turned on this gives a quick way to run synths,

// here default synth with replacements 'n' -> 'note' and 'd' -> 'dur'.



EventShortcuts.makeCurrent(\default).on


(n: [0, 4, 7, 12], d: 3).on



// define SynthDef 


SynthDef(\x, { |out = 0, freq = 440, amp = 0.05| Out.ar(0, SinOsc.ar(freq, 0, amp) * EnvGate.new) }).add



// run synth, audible beats with equal temperature, pitches given as notes ('n')


(i: \x, n: [0, 4, 7], d: 3).on



// not with just intonation, pitches given as frequencies ('f')


(i: \x, f: (4..6) * 100, d: 3).on





1b: Event-related methods defined for SequenceableCollections


aSequenceableCollection.ev

Derives an Event from an array of key/value-pairs. Values might be functions that refer to 

prior keys of the array.

aSequenceableCollection.on

Derives an Event from an array with method ev and plays it using on.




Example 



// define an array as event template

// references to prior keys can be written as environmental variables in Functions

// here: higher midinotes get shorter durations


(

a = [

m: { rrand(60, 100) }, // midinote

d: { ~m.linlin(60, 90, 3, 0.1) } // dur

]

)


// suppose EventShortCuts are turned on

// make an Event and see its data, then play, try several times



x = a.ev


x.on




// same can be done in one, try several times


a.on




2: Event-pattern-related methods defined for SequenceableCollections


aSequenceableCollection.pa

Expects basically an array of key/value-pairs ready for an event pattern. 

Exception: values might be functions that refer to prior keys of the array, thus delivering

an shortcut functionality of the common Pfunc { |e|  ... } construct (and similar to Pkey).

aSequenceableCollection.p

Derives a Pbind from an array involving pa.

aSequenceableCollection.pm(sym)

Derives a Pmono with instrument sym (a Symbol) from an array involving pa.

aSequenceableCollection.pma(sym)

Derives a PmonoArtic with instrument sym (a Symbol) from an array involving pa.


aSequenceableCollection.pbf(sym)

Derives a Pbindef with reference sym (a Symbol) from an array involving pa.




aSequenceableCollection.pp(clock, protoEvent, quant)

Derives and plays a Pbind from an array involving pa. 

Arguments clock, protoEvent and quant are used by Pattern's method play.

aSequenceableCollection.ppm(sym, clock, protoEvent, quant)

Derives and plays a Pmono with instrument sym (a Symbol) from an array involving pa.

Arguments clock, protoEvent and quant are used by Pattern's method play.

aSequenceableCollection.ppma(sym, clock, protoEvent, quant)

Derives and plays a PmonoArtic with instrument sym (a Symbol) from an array involving pa.

Arguments clock, protoEvent and quant are used by Pattern's method play.


aSequenceableCollection.ppbf(sym, clock, protoEvent, quant)

Derives and plays a Pbindef with reference sym (a Symbol) from an array involving pa.

Arguments clock, protoEvent and quant are used by Pattern's method play.




Examples


// use reference convention with Functions

// make an array of patternpairs to be used in different event pattern types


(

a = [

m: Pwhite(60, 80, 30), // midinote

d: { (~m > 70).if { 2 }{ 1 }/8 } // dur

].pa

)


Pbind(*a).play


Pmono(\default, *a).play




// define Pbind and play on different channels


(

p = [

m: Pwhite(60, 80, 100),

d: { (~m > 70).if { 2 }{ 1 }/8 }

].p

)


Pbindf(p, \p, -1).play(quant: 1/4) // \p for pan


Pbindf(p, \p, 1).play(quant: 1/4)




// same with Pmono ...


(

[

m: Pwhite(60, 80, 30),

d: { (~m > 70).if { 2 }{ 1 }/8 }

].pm(\default)

)


Pbindf(p, \p, -1).play(quant: 1/4)


Pbindf(p, \p, 1).play(quant: 1/4)




// ... and PmonoArtic


(

p = [

m: Pwhite(60, 80, 100),

d: { (~m > 70).if { 2 }{ 1 }/8 },

l: Pwhite(0.1, 1.5) // legato

].pma(\default)

)


Pbindf(p, \p, -1).play(quant: 1/4)


Pbindf(p, \p, 1).play(quant: 1/4)




// analogous definition with Pbindef

// example different as Pbindef is pattern and player in one


(

p = [

m: Pwhite(60, 80, 100),

d: { (~m > 70).if { 2 }{ 1 }/8 }

].pbf(\x)

)


Pbindef(\x, \p, -1).play


Pbindef(\x, \p, 1)


Pbindef(\x).clear




// immediately play Pbind

// also play Pmono, PmonoArtic and Pbindef directly with methods ppm, ppma and ppbdf 


(

[

m: Pwhite(60, 80, 30),

d: { (~m > 70).if { 2 }{ 1 }/8 }

].pp

)