music
Functions specificly related to the Music
data type are contained in this module.
NOTE This module is automatically imported for all scripts, and thus never needs to be manually imported.
Functions
cc( control : int, value : int )
Emits a ControlChangeEvent
for the current voice. The controls available and their valid values are the taken from the MIDI specification are listed here.
1 2 3 4 |
|
setvoice( voice : Voice )
Changes the current voice to the voice given. Note that the voice should be passed as a variable (with a $
prefix) instead of the usual :
voice prefix.
1 2 3 |
|
setinstrument( instrument : int )
Keeps the same voice but changes it's instrument. Expects a number representing the intrument ID (usually follows the General MIDI specification).
1 |
|
sfload( soundfont : str, alias : str = none, only_new : bool = false )
Loads a custom soundfont. An optional alias can be passed in to avoid having to reference the full file path everytime we want to set instruments.
1 2 3 |
|
sfunload( soundfont : str, only_new : bool = false )
Unloads and releases the resources associated with a soundfont. Can pass either the file path or the alias (if the font has one).
1 |
|
interval( semitones : int = 0, octaves : int = 0 )
Creates an interval with the given semitones and octaves. Both parameters are optional, and can be used as positional or named parameters.
1 2 3 4 5 6 |
|
Intervals can be added and subtracted with each other, as well as with plain integers (treated as semitones).
1 2 3 4 |
|
They can also be added to Music sequences or single note events, effectively transposing the notes with the given interval.
1 2 3 4 5 |
|
scale( intervals : List[int] )
Creates a scale with the given intervals. There are two predefined scales, $scales::white_keys
and $scales::black_keys
. The scales wrap around, going up octaves or down, when the index is negative.
1 2 3 |
|
save( music, outputs )
Save a music expression to a sequencer. The sequencers can either be:
- A
str
, such as a file name. - A
Sequencer
instance, created with make_sequencer for example. - A of sequencers' options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|