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§
- Search
Language - Which of music21’s name tables
Instrument::from_namereads: music21’sSearchLanguage.
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 undoesunbundle_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’sensembleNameBySize, which isNonepast 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. - for_
percussion_ key_ or_ unmapped - The instrument a key of the General MIDI percussion map plays, and a
bare unpitched percussion instrument carrying the key where the map
names nothing at all: music21’s
midiPitchToInstrumentasked withraiseIfUnmapped=False, which is how its MIDI reader asks. - named_
percussion_ sounds - Every General MIDI percussion sound that is no instrument, each with
the name music21 gives it: music21’s
namedSoundMapping, a hand clap and a metronome among them. - 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. - percussion_
keys - Every key of the General MIDI percussion map that names an instrument
class, in key order: music21’s
reverseInstrumentMappingread as its keys, which is how a caller listing the map asks for one class per key without the named sounds among them. - 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.