Skip to main content

Module instrument

Module instrument 

Source
Expand description

Instruments: music21’s instrument module. Instruments: music21’s instrument module.

An Instrument is one of music21’s instrument classes – a piano, a clarinet in B-flat, a triangle – with what an instrument of that class starts out as: its name and abbreviation, its General MIDI program and sound, the range it plays, the interval from what is written for it to what sounds, and for unpitched percussion the General MIDI drum it plays. The class survives as the instrument’s kind, and a kind belongs to the families above it, so a clarinet is a woodwind and a triangle unpitched percussion (Instrument::is_a).

An instrument is found by kind (Instrument::of_kind), by MIDI program (Instrument::from_midi_program) or by what a score calls it, in six languages and their abbreviations (Instrument::from_name, music21’s fromString), which also reads the key a transposing instrument is in: "Clarinet in A" is a clarinet sounding a minor third below what is written.

What an instrument does to a stream it stands in is here too: moving the instruments notes keep as their own into the stream and back (unbundle_instruments, bundle_instruments), folding together the instruments a part says twice (deduplicate) and splitting a score into a part for each instrument (partition_by_instrument).

Structs§

Instrument
An instrument of one of music21’s kinds: music21’s Instrument.

Enums§

SearchLanguage
Which of music21’s name tables Instrument::from_name reads: music21’s SearchLanguage.

Functions§

bundle_instruments
Gives each note, chord or stroke of a stream the instrument standing last before it as its own, and takes the instruments out of the stream: music21’s bundleInstruments, which undoes unbundle_instruments.
deduplicate
Folds together the instruments a part says more than once: music21’s instrument.deduplicate.
ensemble_name_by_size
What an ensemble of so many players is called, from "no performers" to "centet": music21’s ensembleNameBySize, which is None past a hundred.
for_percussion_key
The instrument a key of the General MIDI percussion map plays, played the way that key says: music21’s midi.percussion.PercussionMapper.midiPitchToInstrument.
partition_by_instrument
Splits a score into a part for each instrument playing in it, each part gathering what is played on that instrument from every part of the score: music21’s partitionByInstrument.
unbundle_instruments
Puts the instrument each note, chord or stroke of a stream keeps as its own into the stream beside it, at its offset: music21’s unbundleInstruments.