Panola:
Filter:
Classes (extension) | Utils

Panola : Object
ExtensionExtension

PAttern NOtation LAnguage
Source: Panola.sc

Description

Panola implements a subset of the midi specification language mispel in supercollider. Mispel is a domain specific language implemented in python 3 for expressive midi generation See https://github.com/shimpe/expremigen

Mispel elements that are not supported in this supercollider version include: - passing animation options (tweening) for the animated properties - specifying multiple tracks in one string - specifying midi control change messages (e.g. animating pitchbend over time with much finer time resolution than the note events)

A Panola notation string specifies a phrase of notes. Notenames can be a, b, c, d, e, f, g. Optional note modifiers can be # for a sharp, x for a double sharp, - for a flat and -- for a double flat. Notenames also include an optional octave number. The following are all examples of valid notes:

a4, b-3, d, gx2, f#1, d--1

If you do not specify an octave number, the last specified one is reused.

Optionally one can append an underscore with an (inverse) duration value to a note, e.g. a_4 is a quarter note, whereas a_8 is an eighth note. These are not to be confused with a4 and a8 which are a-notes in the fourth and eighth octave respectively.

If you do not specify a duration value, the last specified one is reused.

The duration value can optionally be extended with dots. Each dot adds half the duration to the specified duration. E.g. a_4 lasts for 1 quarter note (=2 eighth notes), whereas a_4. lasts for 1.5 quarter notes (3 eighth notes). Number of dots is remembered until a new duration is specified.

After the dots one can optionally specify a multiplier and a divider. These can be used to specify tuplets. E.g. "a4_8*2/3 b c5 d c b4 " specifies 6 notes that together form two triplets of eighth notes. Multiplier and divider are remembered until a new duration is specified.

Notes can be grouped using angular brackets to make chords. The properties of the first note in the chord are used for the complete chord. Properties attached to the second and later notes in the chord (other than octave number and note modifier) are ignored. The following makes a chord of four notes:

"<c4 e4 g c5>"

After the dots one can optionally specify additional properties. Currently the following properties are supported: vol (volume), tempo (tempo), lag (lag), pdur (played duration, aka legato). Properties come in two variants: animated and fixed. An animated property will vary over the course of time until a new value for the property is specified. Animated properties are created by including their values in curly brackets {}. A fixed property remains fixed over the course of time until a new value for the property is specified. A fixed property is specified by enclosing its value in square brackets [].

E.g. here's an example of a crescendo (becoming louder):

"c4\\vol{0.3} d e f g a b c5\\vol{0.9}"

In the above example, the c4 starts at volume 0.3 and the phrase ends at volume 0.9. The volumes of the notes in between gruadually rise so as to get a crescendo. Note: for now only linear animation is supported.

If on the other hand we would have written:

"c4\\vol[0.3] d e f g a b c5\\vol[0.9]"

Then the volume of the notes c4 to b would have remained constant at 0.3, and c5 would have suddenly had volume 0.9.

Note, as of v0.0.9, Panola also supports using the "@" sign instead of a backslash for indicating properties. So you could also write

"c4@vol[0.3] d e f g a b c5@vol[0.9]"

Panola allows you to interpret an valid Panola string by extracting information from it, either as a complete Pbind. You can ask .asPbind which returns a Pbind that is suitable for use with the supercollider server, or you can ask it to .asMidiPbind, which returns a Pbind that can communicate with external software/hardware synthesizers over MIDI.

or, more flexibly, by extracting individual information patterns:

In addition to these predefined properties, you can also use any user defined pattern, e.g.

Class Methods

Panola.new(notation, octave_default: "4", dur_default: "4", modifier_default: "", mult_default: "1", div_default: "1", vol_default: "0.5", playdur_default: "0.9", lag_default: "0", tempo_default: "80")

creates a new Panola instance

Arguments:

notation

a string containing a valid panola notation string

octave_default

which octave to use if not explicitly specified (default=4)

dur_default

which duration to use if not explicitly specified (default=quarter note)

modifier_default

which note modifier to use if not explicitly specified (default=none)

mult_default

extra multiplier used to specify tuplets (default=1)

div_default

extra divider used to specify tuplets (default=1)

vol_default

volume value to use if not explicitly specified (default=0.5)

playdur_default

legato value to use if not explicitly specified (default=0.9)

lag_default

lag value to use if not explicitly specified(default=0)

tempo_default

tempo value to use if not explicitly specified(default=80 bpm)

Returns:

an object from which several patterns can be asked

Inherited class methods

Instance Methods

.asPbind(instrument: 'default', include_custom_properties: true, custom_property_defaults, translate_std_keys: true)

returns all info in the score as a pattern. All properties are turned into Pbind keys

Arguments:

instrument

the instrument to use in the Pbind

include_custom_properties

a boolean indicating if only the standard fields (tempo, lag, midinote, duration, pdur) should be included, or if all user defined properties should be included as well

custom_property_defaults

a Dictionary containing default values for properties. These defaults are used as long as no value for the property is specified in the Panola specification. If you provide a default value for a key, but you never reference the key in the Panola string, it will not be part of the Pbind that results from calling asPbind.

translate_std_keys

if true (default), key "vol" is translated to \amp and key "pdur" is translated to \legato and key "tempo" is correctly scaled to be used in a TempoClock

Returns:

a Pbind of \type \note

.asMidiPbind(midiOut, channel: 0, include_custom_properties: true, custom_property_default, translate_std_keys: true)

returns the info in the score as a pattern that produces midi noteOn/noteOff events. This can be used with external devices.

Arguments:

midiOut

this is an instance of a MIDIOut, already connected to an external software/hardware synth

channel

midi channel (default:0) on which to send the noteOn/noteOff events

include_custom_properties

a boolean indicating if only the standard fields (tempo, lag, midinote, duration, pdur) should be included, or if all user defined properties should be included as well. In case of midi events, these extra keys most likely will not have any effect.

custom_property_default

a Dictionary containing default values for properties. These defaults are used as long as no value for the property is specified in the Panola specification. If you provide a default value for a key, but you never reference the key in the Panola string, it will not be part of the Pbind that results from calling asPbind.

translate_std_keys

if true (default), key "vol" is translated to \amp and key "pdur" is translated to \legato and key "tempo" is correctly scaled to be used in a TempoClock

Returns:

a Pbind of \type \midi

.asPmono(instrument: 'default', include_custom_properties: true, custom_property_defaults, translate_std_keys: true)

returns the info in the score as a Pmono

Arguments:

instrument

the instrument to use in the Pmono

include_custom_properties

a boolean indicating if only the standard fields (tempo, lag, midinote, duration, pdur) should be included, or if all user defined properties should be included as well

custom_property_defaults

a Dictionary containing default values for properties. These defaults are used as long as no value for the property is specified in the Panola specification. If you provide a default value for a key, but you never reference the key in the Panola string, it will not be part of the Pmono that results from calling asPmono.

translate_std_keys

if true (default), key "vol" is translated to \amp and key "pdur" is translated to \legato and key "tempo" is correctly scaled to be used in a TempoClock

Returns:

a Pmono of \type \note

.asPmonoArtic(instrument: 'default', include_custom_properties: true, custom_property_defaults, translate_std_keys: true)

returns the info in the score as a PmonoArtic

Arguments:

instrument

the instrument to use in the PmonoArtic

include_custom_properties

a boolean indicating if only the standard fields (tempo, lag, midinote, duration, pdur) should be included, or if all user defined properties should be included as well

custom_property_defaults

a Dictionary containing default values for properties. These defaults are used as long as no value for the property is specified in the Panola specification. If you provide a default value for a key, but you never reference the key in the Panola string, it will not be part of the PmonoArtic that results from calling asPmonoArtic.

translate_std_keys

if true (default), key "vol" is translated to \amp and key "pdur" is translated to \legato and key "tempo" is correctly scaled to be used in a TempoClock

Returns:

a PmonoArtic of \type \note

.gMODIFIER_DEFAULT

default note modifier

Returns:

returns default note modifier in use

.volumePattern

volumePattern

Returns:

returns a pattern generating the required volume entries

.parsed_notation

internal data structure containing parse tree of the panola notation string

Returns:

internal data structure containing parse tree of the panola notation string

.init_notation(notation, octave_default, dur_default, modifier_default, mult_default, div_default, vol_default, playdur_default, lag_default, tempo_default)

internal helper method to parse the panola notation

Arguments:

notation

string containing valid panola notation

octave_default

wich octave to use by default (4, unless specified differently during .new)

dur_default

which duration to use by default (1/4, unless specified differently during .new)

modifier_default

which modifier to use by default (none)

mult_default

which rhythm multiplier to use by default (1)

div_default

which rhythm divider to use by default (1)

vol_default

which volume to use by default (0.5)

playdur_default

which legato setting to use by default (0.9)

lag_default

which lag to use by default (0)

tempo_default

which tempo to use by default (80 bpm)

Returns:

nothing of interest

.gPLAYDUR_DEFAULT

default legato value (0.9)

Returns:

returns default legato value in use

.init_midilookup

internal helper method to create notename to midi number lookup table

Returns:

nothing

.gDIVIDER_DEFAULT

default duration divider (1)

Returns:

default duration divider

.gOCTAVE_DEFAULT

default octave (4)

Returns:

default octave

.gDOTS_DEFAULT

default number of dots (0)

Returns:

default number of dots

.gTEMPO_DEFAULT

default tempo (80 bpm)

Returns:

default tempo

.gLAG_DEFAULT

default lag (0)

Returns:

default lag

.durationPattern

pattern generating the successive durations to realize the notation

Returns:

pattern generating the successive durations to realize the notation

.customPropertyPattern(customstring, default: 0)

returns a pattern describing the values of a custom property through the score

Arguments:

customstring

this is the name of the property you're extracting from the score

default

this is the default value for the property

Returns:

a pattern

.pr_animatedPattern(prop_name: "vol", default_type: "fixed", default_propval: 0.5)

internal helper method for turning animated properties into pattern

Arguments:

prop_name

string describing name of property in panola notation

default_type

type to use if no type specified

default_propval

value to use if no property value specified

Returns:

pattern generating the property values needed to realize the notation string

.pdurPattern

pattern generating the successive legato values to realize the notation

Returns:

pattern generating the successive legato values to realize the notation

.gMULTIPLIER_DEFAULT

default duration multiplier value

Returns:

default duration multiplier value

.gDURATION_DEFAULT

default duration

Returns:

default duration

.lagPattern

pattern generating the successive lag values to realize the pattern

Returns:

pattern generating the successive lag values to realize the pattern

.gVOLUME_DEFAULT

default volume

Returns:

default volume

.midinotePattern

pattern generating the successsive midi notes to realize the pattern

Returns:

pattern generating the successsive midi notes to realize the pattern

.notationnotePattern

pattern generating the successive notated notes to realize the pattern (mostly useful for display purposes)

Returns:

pattern generating the successive notated notes to realize the pattern

.notationdurationPattern

pattern generating the successive notated durations to realize the pattern (mostly useful for display purposes)

Returns:

pattern generating the successive notated durations to realize the pattern

.tempoPattern

pattern generating the successsive tempo values to realize the pattern

Returns:

pattern generating the successsive tempo values to realize the pattern

.note_to_midi

internal lookup table

Returns:

lookup table to transform note names into midinotes

.init(notation, octave_default, dur_default, modifier_default, mult_default, div_default, vol_default, playdur_default, lag_default, tempo_default)

initialization of internal data structures + parsing of notation string

Arguments:

notation

panola string with notation

octave_default

default octave

dur_default

default duration

modifier_default

default modifier

mult_default

default multiplier

div_default

default divider

vol_default

default volume

playdur_default

default legato

lag_default

default lag

tempo_default

default tempo

Returns:

internally initialized Panola instance

Inherited instance methods

Undocumented instance methods

.customProperties

.customProperties = value

.customPropertyPatternArgs(customstring, default)

.getNoOfEvents

.noteToMidi(note)

.numberOfNotesOrChords

.pr_animatedPatternArgs(prop_name: "vol", default_type: "fixed", default_propval: 0.5)

.pr_read_token(string_so_far, token_regexp, token_default: "", semantic_token_action, token_not_found_action)

.pr_unroll(t)

.pr_unroll_checksyntax(txt)

.pr_unroll_cleanup(txt)

.pr_unroll_find_inner(txt)

.totalDuration

.unroll_loops(notation)

Examples

Using Panola without pattern:

Using Panola in a pattern

Multiple voices: first part of J.S. Bach's bwv784 2-voice invention 13

Driving a synth using custom properties

Complete piece in 4 voices being sent to a Prophet Rev 2 hardware synthesizer. This makes use of the ScProphetRev2 quark for talking to a Dave Smith Instruments prophet Rev2, available from https://github.com/shimpe/sc-prophet-rev2.You can of course use your own initialized MIDIOut object instead.