music21.instrument¶
This module represents instruments through objects that contain general information such as Metadata for instrument names, classifications, transpositions and default MIDI program numbers. It also contains information specific to each instrument or instrument family, such as string pitches, etc. Information about instrumental ensembles is also included here though it may later be separated out into its own ensemble.py module.
Instrument¶
- class music21.instrument.Instrument(instrumentName: str | None = None, **keywords)¶
Base class for all musical instruments. Designed for subclassing, though usually a more specific instrument class (such as StringInstrument) would be better to subclass.
Some defined attributes for instruments include:
partId
partName
partAbbreviation
instrumentId
instrumentName
instrumentAbbreviation
midiProgram (0-indexed)
midiChannel (0-indexed)
lowestNote (a note object or a string for _written_ pitch)
highestNote (a note object or a string for _written_ pitch)
transposition (an interval object)
inGMPercMap (bool – if it uses the GM percussion map)
soundfontFn (filepath to a sound font, optional)
Instrument
bases
Instrument
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Instrument
read/write properties
Read/write properties inherited from Music21Object
:
Instrument
methods
- Instrument.autoAssignMidiChannel(usedChannels: list[int], maxMidi=16)¶
Assign an unused midi channel given a list of used channels. Music21 uses 0-indexed MIDI channels.
assigns the number to self.midiChannel and returns it as an int.
Note that the Percussion MIDI channel (9 in music21, 10 in 1-16 numbering) is special, and thus is skipped.
>>> used = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11] >>> i = instrument.Violin() >>> i.autoAssignMidiChannel(used) 12 >>> i.midiChannel 12
Note that used is unchanged after calling this and would need to be updated manually
>>> used [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11]
Unpitched percussion will be set to 9, so long as it’s not in the filter list:
>>> used = [0] >>> i = instrument.Maracas() >>> i.autoAssignMidiChannel(used) 9 >>> i.midiChannel 9
>>> used = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> i = instrument.Woodblock() >>> i.autoAssignMidiChannel(used) 11 >>> i.midiChannel 11
If all 16 channels are used, an exception is raised:
>>> used2 = range(16) >>> i = instrument.Instrument() >>> i.autoAssignMidiChannel(used2) Traceback (most recent call last): music21.exceptions21.InstrumentException: we are out of midi channels! help!
Get around this by assinging higher channels:
>>> i.autoAssignMidiChannel(used2, maxMidi=32) 16 >>> i.midiChannel 16
- Changed in v.9 – usedChannelList is required, add maxMidi as an optional parameter.
various small tweaks for corner cases.
- Instrument.bestName()¶
Find a viable name, looking first at instrument, then part, then abbreviations.
- Instrument.instrumentIdRandomize()¶
Force a unique id by using an MD5
- Instrument.partIdRandomize()¶
Force a unique id by using an MD5
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Instrument
instance variables
Instance variables inherited from Music21Object
:
Accordion¶
- class music21.instrument.Accordion(**keywords)¶
Accordion
bases
Accordion
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Accordion
read/write properties
Read/write properties inherited from Music21Object
:
Accordion
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Accordion
instance variables
Instance variables inherited from Music21Object
:
AcousticBass¶
- class music21.instrument.AcousticBass(**keywords)¶
AcousticBass
bases
AcousticBass
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
AcousticBass
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
AcousticBass
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
AcousticBass
instance variables
Instance variables inherited from Music21Object
:
AcousticGuitar¶
- class music21.instrument.AcousticGuitar(**keywords)¶
AcousticGuitar
bases
AcousticGuitar
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
AcousticGuitar
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
AcousticGuitar
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
AcousticGuitar
instance variables
Instance variables inherited from Music21Object
:
Agogo¶
- class music21.instrument.Agogo(**keywords)¶
Agogo
bases
Agogo
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Agogo
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Agogo
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Agogo
instance variables
Instance variables inherited from Music21Object
:
Alto¶
- class music21.instrument.Alto(**keywords)¶
Alto
bases
Alto
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Alto
read/write properties
Read/write properties inherited from Music21Object
:
Alto
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Alto
instance variables
Instance variables inherited from Music21Object
:
AltoSaxophone¶
- class music21.instrument.AltoSaxophone(**keywords)¶
AltoSaxophone
bases
AltoSaxophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
AltoSaxophone
read/write properties
Read/write properties inherited from Music21Object
:
AltoSaxophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
AltoSaxophone
instance variables
Instance variables inherited from Music21Object
:
Bagpipes¶
- class music21.instrument.Bagpipes(**keywords)¶
Bagpipes
bases
Bagpipes
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Bagpipes
read/write properties
Read/write properties inherited from Music21Object
:
Bagpipes
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Bagpipes
instance variables
Instance variables inherited from Music21Object
:
Banjo¶
- class music21.instrument.Banjo(**keywords)¶
Banjo
bases
Banjo
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Banjo
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Banjo
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Banjo
instance variables
Instance variables inherited from Music21Object
:
Baritone¶
- class music21.instrument.Baritone(**keywords)¶
Baritone
bases
Baritone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Baritone
read/write properties
Read/write properties inherited from Music21Object
:
Baritone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Baritone
instance variables
Instance variables inherited from Music21Object
:
BaritoneSaxophone¶
- class music21.instrument.BaritoneSaxophone(**keywords)¶
BaritoneSaxophone
bases
BaritoneSaxophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BaritoneSaxophone
read/write properties
Read/write properties inherited from Music21Object
:
BaritoneSaxophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BaritoneSaxophone
instance variables
Instance variables inherited from Music21Object
:
Bass¶
- class music21.instrument.Bass(**keywords)¶
Bass
bases
Bass
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Bass
read/write properties
Read/write properties inherited from Music21Object
:
Bass
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Bass
instance variables
Instance variables inherited from Music21Object
:
BassClarinet¶
- class music21.instrument.BassClarinet(**keywords)¶
>>> bcl = instrument.BassClarinet() >>> bcl.instrumentName 'Bass clarinet' >>> bcl.midiProgram 71 >>> 'WoodwindInstrument' in bcl.classes True
BassClarinet
bases
BassClarinet
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BassClarinet
read/write properties
Read/write properties inherited from Music21Object
:
BassClarinet
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BassClarinet
instance variables
Instance variables inherited from Music21Object
:
BassDrum¶
- class music21.instrument.BassDrum(**keywords)¶
BassDrum
bases
BassDrum
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BassDrum
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
BassDrum
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BassDrum
instance variables
Instance variables inherited from Music21Object
:
BassTrombone¶
- class music21.instrument.BassTrombone(**keywords)¶
BassTrombone
bases
BassTrombone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BassTrombone
read/write properties
Read/write properties inherited from Music21Object
:
BassTrombone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BassTrombone
instance variables
Instance variables inherited from Music21Object
:
Bassoon¶
- class music21.instrument.Bassoon(**keywords)¶
Bassoon
bases
Bassoon
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Bassoon
read/write properties
Read/write properties inherited from Music21Object
:
Bassoon
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Bassoon
instance variables
Instance variables inherited from Music21Object
:
BongoDrums¶
- class music21.instrument.BongoDrums(**keywords)¶
BongoDrums
bases
BongoDrums
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BongoDrums
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
BongoDrums
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BongoDrums
instance variables
Instance variables inherited from Music21Object
:
BrassInstrument¶
- class music21.instrument.BrassInstrument(**keywords)¶
BrassInstrument
bases
BrassInstrument
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
BrassInstrument
read/write properties
Read/write properties inherited from Music21Object
:
BrassInstrument
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
BrassInstrument
instance variables
Instance variables inherited from Music21Object
:
Castanets¶
- class music21.instrument.Castanets(**keywords)¶
Castanets
bases
Castanets
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Castanets
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Castanets
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Castanets
instance variables
Instance variables inherited from Music21Object
:
Celesta¶
- class music21.instrument.Celesta(**keywords)¶
Celesta
bases
Celesta
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Celesta
read/write properties
Read/write properties inherited from Music21Object
:
Celesta
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Celesta
instance variables
Instance variables inherited from Music21Object
:
Choir¶
- class music21.instrument.Choir(**keywords)¶
Choir
bases
Choir
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Choir
read/write properties
Read/write properties inherited from Music21Object
:
Choir
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Choir
instance variables
Instance variables inherited from Music21Object
:
ChurchBells¶
- class music21.instrument.ChurchBells(**keywords)¶
ChurchBells
bases
ChurchBells
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ChurchBells
read/write properties
Read/write properties inherited from Music21Object
:
ChurchBells
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ChurchBells
instance variables
Instance variables inherited from Music21Object
:
Clarinet¶
- class music21.instrument.Clarinet(**keywords)¶
Clarinet
bases
Clarinet
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Clarinet
read/write properties
Read/write properties inherited from Music21Object
:
Clarinet
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Clarinet
instance variables
Instance variables inherited from Music21Object
:
Clavichord¶
- class music21.instrument.Clavichord(**keywords)¶
Clavichord
bases
Clavichord
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Clavichord
read/write properties
Read/write properties inherited from Music21Object
:
Clavichord
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Clavichord
instance variables
Instance variables inherited from Music21Object
:
Conductor¶
- class music21.instrument.Conductor(**keywords)¶
Presently used only for tracking the MIDI track containing tempo, key signature, and related metadata.
Conductor
bases
Conductor
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Conductor
read/write properties
Read/write properties inherited from Music21Object
:
Conductor
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Conductor
instance variables
Instance variables inherited from Music21Object
:
CongaDrum¶
- class music21.instrument.CongaDrum(**keywords)¶
CongaDrum
bases
CongaDrum
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
CongaDrum
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
CongaDrum
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
CongaDrum
instance variables
Instance variables inherited from Music21Object
:
Contrabass¶
- class music21.instrument.Contrabass(**keywords)¶
For the Contrabass (or double bass), the stringPitches attribute refers to the sounding pitches of each string; whereas the lowestNote attribute refers to the lowest written note.
Contrabass
bases
Contrabass
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Contrabass
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Contrabass
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Contrabass
instance variables
Instance variables inherited from Music21Object
:
Contrabassoon¶
- class music21.instrument.Contrabassoon(**keywords)¶
Contrabassoon
bases
Contrabassoon
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Contrabassoon
read/write properties
Read/write properties inherited from Music21Object
:
Contrabassoon
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Contrabassoon
instance variables
Instance variables inherited from Music21Object
:
Cowbell¶
- class music21.instrument.Cowbell(**keywords)¶
Cowbell
bases
Cowbell
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Cowbell
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Cowbell
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Cowbell
instance variables
Instance variables inherited from Music21Object
:
CrashCymbals¶
- class music21.instrument.CrashCymbals(**keywords)¶
CrashCymbals
bases
CrashCymbals
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
CrashCymbals
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
CrashCymbals
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
CrashCymbals
instance variables
Instance variables inherited from Music21Object
:
Cymbals¶
- class music21.instrument.Cymbals(**keywords)¶
Cymbals
bases
Cymbals
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Cymbals
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Cymbals
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Cymbals
instance variables
Instance variables inherited from Music21Object
:
Dulcimer¶
- class music21.instrument.Dulcimer(**keywords)¶
Dulcimer
bases
Dulcimer
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Dulcimer
read/write properties
Read/write properties inherited from Music21Object
:
Dulcimer
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Dulcimer
instance variables
Instance variables inherited from Music21Object
:
ElectricBass¶
- class music21.instrument.ElectricBass(**keywords)¶
ElectricBass
bases
ElectricBass
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ElectricBass
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
ElectricBass
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ElectricBass
instance variables
Instance variables inherited from Music21Object
:
ElectricGuitar¶
- class music21.instrument.ElectricGuitar(**keywords)¶
ElectricGuitar
bases
ElectricGuitar
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ElectricGuitar
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
ElectricGuitar
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ElectricGuitar
instance variables
Instance variables inherited from Music21Object
:
ElectricOrgan¶
- class music21.instrument.ElectricOrgan(**keywords)¶
ElectricOrgan
bases
ElectricOrgan
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ElectricOrgan
read/write properties
Read/write properties inherited from Music21Object
:
ElectricOrgan
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ElectricOrgan
instance variables
Instance variables inherited from Music21Object
:
ElectricPiano¶
- class music21.instrument.ElectricPiano(**keywords)¶
>>> p = instrument.ElectricPiano() >>> p.instrumentName 'Electric Piano' >>> p.midiProgram 2
ElectricPiano
bases
ElectricPiano
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ElectricPiano
read/write properties
Read/write properties inherited from Music21Object
:
ElectricPiano
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ElectricPiano
instance variables
Instance variables inherited from Music21Object
:
EnglishHorn¶
- class music21.instrument.EnglishHorn(**keywords)¶
EnglishHorn
bases
EnglishHorn
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
EnglishHorn
read/write properties
Read/write properties inherited from Music21Object
:
EnglishHorn
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
EnglishHorn
instance variables
Instance variables inherited from Music21Object
:
FingerCymbals¶
- class music21.instrument.FingerCymbals(**keywords)¶
FingerCymbals
bases
FingerCymbals
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
FingerCymbals
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
FingerCymbals
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
FingerCymbals
instance variables
Instance variables inherited from Music21Object
:
Flute¶
- class music21.instrument.Flute(**keywords)¶
Flute
bases
Flute
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Flute
read/write properties
Read/write properties inherited from Music21Object
:
Flute
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Flute
instance variables
Instance variables inherited from Music21Object
:
FretlessBass¶
- class music21.instrument.FretlessBass(**keywords)¶
FretlessBass
bases
FretlessBass
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
FretlessBass
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
FretlessBass
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
FretlessBass
instance variables
Instance variables inherited from Music21Object
:
Glockenspiel¶
- class music21.instrument.Glockenspiel(**keywords)¶
Glockenspiel
bases
Glockenspiel
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Glockenspiel
read/write properties
Read/write properties inherited from Music21Object
:
Glockenspiel
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Glockenspiel
instance variables
Instance variables inherited from Music21Object
:
Gong¶
- class music21.instrument.Gong(**keywords)¶
Gong
bases
Gong
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Gong
read/write properties
Read/write properties inherited from Music21Object
:
Gong
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Gong
instance variables
Instance variables inherited from Music21Object
:
Guitar¶
- class music21.instrument.Guitar(**keywords)¶
Guitar
bases
Guitar
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Guitar
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Guitar
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Guitar
instance variables
Instance variables inherited from Music21Object
:
Handbells¶
- class music21.instrument.Handbells(**keywords)¶
Handbells
bases
Handbells
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Handbells
read/write properties
Read/write properties inherited from Music21Object
:
Handbells
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Handbells
instance variables
Instance variables inherited from Music21Object
:
Harmonica¶
- class music21.instrument.Harmonica(**keywords)¶
Harmonica
bases
Harmonica
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Harmonica
read/write properties
Read/write properties inherited from Music21Object
:
Harmonica
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Harmonica
instance variables
Instance variables inherited from Music21Object
:
Harp¶
- class music21.instrument.Harp(**keywords)¶
Harp
bases
Harp
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Harp
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Harp
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Harp
instance variables
Instance variables inherited from Music21Object
:
Harpsichord¶
- class music21.instrument.Harpsichord(**keywords)¶
Harpsichord
bases
Harpsichord
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Harpsichord
read/write properties
Read/write properties inherited from Music21Object
:
Harpsichord
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Harpsichord
instance variables
Instance variables inherited from Music21Object
:
HiHatCymbal¶
- class music21.instrument.HiHatCymbal(**keywords)¶
HiHatCymbal
bases
HiHatCymbal
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
HiHatCymbal
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
HiHatCymbal
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
HiHatCymbal
instance variables
Instance variables inherited from Music21Object
:
Horn¶
- class music21.instrument.Horn(**keywords)¶
>>> hn = instrument.Horn() >>> hn.instrumentName 'Horn' >>> hn.midiProgram 60 >>> 'BrassInstrument' in hn.classes True
Horn
bases
Horn
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Horn
read/write properties
Read/write properties inherited from Music21Object
:
Horn
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Horn
instance variables
Instance variables inherited from Music21Object
:
Kalimba¶
- class music21.instrument.Kalimba(**keywords)¶
Kalimba
bases
Kalimba
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Kalimba
read/write properties
Read/write properties inherited from Music21Object
:
Kalimba
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Kalimba
instance variables
Instance variables inherited from Music21Object
:
KeyboardInstrument¶
- class music21.instrument.KeyboardInstrument(**keywords)¶
KeyboardInstrument
bases
KeyboardInstrument
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
KeyboardInstrument
read/write properties
Read/write properties inherited from Music21Object
:
KeyboardInstrument
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
KeyboardInstrument
instance variables
Instance variables inherited from Music21Object
:
Koto¶
- class music21.instrument.Koto(**keywords)¶
Koto
bases
Koto
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Koto
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Koto
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Koto
instance variables
Instance variables inherited from Music21Object
:
Lute¶
- class music21.instrument.Lute(**keywords)¶
Lute
bases
Lute
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Lute
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Lute
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Lute
instance variables
Instance variables inherited from Music21Object
:
Mandolin¶
- class music21.instrument.Mandolin(**keywords)¶
Mandolin
bases
Mandolin
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Mandolin
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Mandolin
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Mandolin
instance variables
Instance variables inherited from Music21Object
:
Maracas¶
- class music21.instrument.Maracas(**keywords)¶
Maracas
bases
Maracas
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Maracas
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Maracas
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Maracas
instance variables
Instance variables inherited from Music21Object
:
Marimba¶
- class music21.instrument.Marimba(**keywords)¶
Marimba
bases
Marimba
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Marimba
read/write properties
Read/write properties inherited from Music21Object
:
Marimba
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Marimba
instance variables
Instance variables inherited from Music21Object
:
MezzoSoprano¶
- class music21.instrument.MezzoSoprano(**keywords)¶
MezzoSoprano
bases
MezzoSoprano
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
MezzoSoprano
read/write properties
Read/write properties inherited from Music21Object
:
MezzoSoprano
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
MezzoSoprano
instance variables
Instance variables inherited from Music21Object
:
Oboe¶
- class music21.instrument.Oboe(**keywords)¶
Oboe
bases
Oboe
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Oboe
read/write properties
Read/write properties inherited from Music21Object
:
Oboe
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Oboe
instance variables
Instance variables inherited from Music21Object
:
Ocarina¶
- class music21.instrument.Ocarina(**keywords)¶
Ocarina
bases
Ocarina
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Ocarina
read/write properties
Read/write properties inherited from Music21Object
:
Ocarina
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Ocarina
instance variables
Instance variables inherited from Music21Object
:
Organ¶
- class music21.instrument.Organ(**keywords)¶
Organ
bases
Organ
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Organ
read/write properties
Read/write properties inherited from Music21Object
:
Organ
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Organ
instance variables
Instance variables inherited from Music21Object
:
PanFlute¶
- class music21.instrument.PanFlute(**keywords)¶
PanFlute
bases
PanFlute
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
PanFlute
read/write properties
Read/write properties inherited from Music21Object
:
PanFlute
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
PanFlute
instance variables
Instance variables inherited from Music21Object
:
Percussion¶
- class music21.instrument.Percussion(**keywords)¶
Percussion
bases
Percussion
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Percussion
read/write properties
Read/write properties inherited from Music21Object
:
Percussion
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Percussion
instance variables
Instance variables inherited from Music21Object
:
Piano¶
- class music21.instrument.Piano(**keywords)¶
>>> p = instrument.Piano() >>> p.instrumentName 'Piano' >>> p.midiProgram 0
Piano
bases
Piano
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Piano
read/write properties
Read/write properties inherited from Music21Object
:
Piano
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Piano
instance variables
Instance variables inherited from Music21Object
:
Piccolo¶
- class music21.instrument.Piccolo(**keywords)¶
Piccolo
bases
Piccolo
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Piccolo
read/write properties
Read/write properties inherited from Music21Object
:
Piccolo
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Piccolo
instance variables
Instance variables inherited from Music21Object
:
PipeOrgan¶
- class music21.instrument.PipeOrgan(**keywords)¶
PipeOrgan
bases
PipeOrgan
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
PipeOrgan
read/write properties
Read/write properties inherited from Music21Object
:
PipeOrgan
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
PipeOrgan
instance variables
Instance variables inherited from Music21Object
:
PitchedPercussion¶
- class music21.instrument.PitchedPercussion(**keywords)¶
PitchedPercussion
bases
PitchedPercussion
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
PitchedPercussion
read/write properties
Read/write properties inherited from Music21Object
:
PitchedPercussion
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
PitchedPercussion
instance variables
Instance variables inherited from Music21Object
:
Ratchet¶
- class music21.instrument.Ratchet(**keywords)¶
Ratchet
bases
Ratchet
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Ratchet
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Ratchet
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Ratchet
instance variables
Instance variables inherited from Music21Object
:
Recorder¶
- class music21.instrument.Recorder(**keywords)¶
Recorder
bases
Recorder
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Recorder
read/write properties
Read/write properties inherited from Music21Object
:
Recorder
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Recorder
instance variables
Instance variables inherited from Music21Object
:
ReedOrgan¶
- class music21.instrument.ReedOrgan(**keywords)¶
ReedOrgan
bases
ReedOrgan
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
ReedOrgan
read/write properties
Read/write properties inherited from Music21Object
:
ReedOrgan
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
ReedOrgan
instance variables
Instance variables inherited from Music21Object
:
RideCymbals¶
- class music21.instrument.RideCymbals(**keywords)¶
RideCymbals
bases
RideCymbals
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
RideCymbals
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
RideCymbals
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
RideCymbals
instance variables
Instance variables inherited from Music21Object
:
Sampler¶
- class music21.instrument.Sampler(**keywords)¶
Sampler
bases
Sampler
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Sampler
read/write properties
Read/write properties inherited from Music21Object
:
Sampler
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Sampler
instance variables
Instance variables inherited from Music21Object
:
SandpaperBlocks¶
- class music21.instrument.SandpaperBlocks(**keywords)¶
SandpaperBlocks
bases
SandpaperBlocks
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SandpaperBlocks
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SandpaperBlocks
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SandpaperBlocks
instance variables
Instance variables inherited from Music21Object
:
Saxophone¶
- class music21.instrument.Saxophone(**keywords)¶
Saxophone
bases
Saxophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Saxophone
read/write properties
Read/write properties inherited from Music21Object
:
Saxophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Saxophone
instance variables
Instance variables inherited from Music21Object
:
SearchLanguage¶
- class music21.instrument.SearchLanguage(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
SearchLanguage
bases
Shakuhachi¶
- class music21.instrument.Shakuhachi(**keywords)¶
Shakuhachi
bases
Shakuhachi
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Shakuhachi
read/write properties
Read/write properties inherited from Music21Object
:
Shakuhachi
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Shakuhachi
instance variables
Instance variables inherited from Music21Object
:
Shamisen¶
- class music21.instrument.Shamisen(**keywords)¶
Shamisen
bases
Shamisen
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Shamisen
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Shamisen
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Shamisen
instance variables
Instance variables inherited from Music21Object
:
Shehnai¶
- class music21.instrument.Shehnai(**keywords)¶
Shehnai
bases
Shehnai
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Shehnai
read/write properties
Read/write properties inherited from Music21Object
:
Shehnai
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Shehnai
instance variables
Instance variables inherited from Music21Object
:
Siren¶
- class music21.instrument.Siren(**keywords)¶
Siren
bases
Siren
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Siren
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Siren
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Siren
instance variables
Instance variables inherited from Music21Object
:
Sitar¶
- class music21.instrument.Sitar(**keywords)¶
Sitar
bases
Sitar
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Sitar
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Sitar
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Sitar
instance variables
Instance variables inherited from Music21Object
:
SizzleCymbal¶
- class music21.instrument.SizzleCymbal(**keywords)¶
SizzleCymbal
bases
SizzleCymbal
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SizzleCymbal
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SizzleCymbal
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SizzleCymbal
instance variables
Instance variables inherited from Music21Object
:
SleighBells¶
- class music21.instrument.SleighBells(**keywords)¶
SleighBells
bases
SleighBells
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SleighBells
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SleighBells
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SleighBells
instance variables
Instance variables inherited from Music21Object
:
SnareDrum¶
- class music21.instrument.SnareDrum(**keywords)¶
SnareDrum
bases
SnareDrum
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SnareDrum
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SnareDrum
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SnareDrum
instance variables
Instance variables inherited from Music21Object
:
Soprano¶
- class music21.instrument.Soprano(**keywords)¶
Soprano
bases
Soprano
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Soprano
read/write properties
Read/write properties inherited from Music21Object
:
Soprano
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Soprano
instance variables
Instance variables inherited from Music21Object
:
SopranoSaxophone¶
- class music21.instrument.SopranoSaxophone(**keywords)¶
SopranoSaxophone
bases
SopranoSaxophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SopranoSaxophone
read/write properties
Read/write properties inherited from Music21Object
:
SopranoSaxophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SopranoSaxophone
instance variables
Instance variables inherited from Music21Object
:
SplashCymbals¶
- class music21.instrument.SplashCymbals(**keywords)¶
SplashCymbals
bases
SplashCymbals
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SplashCymbals
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SplashCymbals
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SplashCymbals
instance variables
Instance variables inherited from Music21Object
:
SteelDrum¶
- class music21.instrument.SteelDrum(**keywords)¶
SteelDrum
bases
SteelDrum
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SteelDrum
read/write properties
Read/write properties inherited from Music21Object
:
SteelDrum
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SteelDrum
instance variables
Instance variables inherited from Music21Object
:
StringInstrument¶
- class music21.instrument.StringInstrument(**keywords)¶
StringInstrument
bases
StringInstrument
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
StringInstrument
read/write properties
- StringInstrument.stringPitches¶
stringPitches is a property that stores a list of Pitches (or pitch names, such as “C4”) that represent the pitch of the open strings from lowest to highest.[*]
>>> vln1 = instrument.Violin() >>> [str(p) for p in vln1.stringPitches] ['G3', 'D4', 'A4', 'E5']
instrument.stringPitches are full pitch objects, not just names:
>>> [x.octave for x in vln1.stringPitches] [3, 4, 4, 5]
Scordatura for Scelsi’s violin concerto Anahit. (N.B. that string to pitch conversion is happening automatically)
>>> vln1.stringPitches = ['G3', 'G4', 'B4', 'D4']
([*]In some tuning methods such as reentrant tuning on the ukulele, lute, or five-string banjo the order might not strictly be from lowest to highest. The same would hold true for certain violin scordatura pieces, such as some of Biber’s *Mystery Sonatas*)
Read/write properties inherited from Music21Object
:
StringInstrument
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
StringInstrument
instance variables
Instance variables inherited from Music21Object
:
SuspendedCymbal¶
- class music21.instrument.SuspendedCymbal(**keywords)¶
SuspendedCymbal
bases
SuspendedCymbal
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
SuspendedCymbal
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
SuspendedCymbal
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
SuspendedCymbal
instance variables
Instance variables inherited from Music21Object
:
Taiko¶
- class music21.instrument.Taiko(**keywords)¶
Taiko
bases
Taiko
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Taiko
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Taiko
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Taiko
instance variables
Instance variables inherited from Music21Object
:
TamTam¶
- class music21.instrument.TamTam(**keywords)¶
TamTam
bases
TamTam
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TamTam
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
TamTam
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TamTam
instance variables
Instance variables inherited from Music21Object
:
Tambourine¶
- class music21.instrument.Tambourine(**keywords)¶
Tambourine
bases
Tambourine
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Tambourine
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Tambourine
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Tambourine
instance variables
Instance variables inherited from Music21Object
:
TempleBlock¶
- class music21.instrument.TempleBlock(**keywords)¶
TempleBlock
bases
TempleBlock
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TempleBlock
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
TempleBlock
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TempleBlock
instance variables
Instance variables inherited from Music21Object
:
Tenor¶
- class music21.instrument.Tenor(**keywords)¶
Tenor
bases
Tenor
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Tenor
read/write properties
Read/write properties inherited from Music21Object
:
Tenor
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Tenor
instance variables
Instance variables inherited from Music21Object
:
TenorDrum¶
- class music21.instrument.TenorDrum(**keywords)¶
TenorDrum
bases
TenorDrum
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TenorDrum
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
TenorDrum
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TenorDrum
instance variables
Instance variables inherited from Music21Object
:
TenorSaxophone¶
- class music21.instrument.TenorSaxophone(**keywords)¶
TenorSaxophone
bases
TenorSaxophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TenorSaxophone
read/write properties
Read/write properties inherited from Music21Object
:
TenorSaxophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TenorSaxophone
instance variables
Instance variables inherited from Music21Object
:
Timbales¶
- class music21.instrument.Timbales(**keywords)¶
Timbales
bases
Timbales
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Timbales
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Timbales
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Timbales
instance variables
Instance variables inherited from Music21Object
:
Timpani¶
- class music21.instrument.Timpani(**keywords)¶
Timpani
bases
Timpani
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Timpani
read/write properties
Read/write properties inherited from Music21Object
:
Timpani
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Timpani
instance variables
Instance variables inherited from Music21Object
:
TomTom¶
- class music21.instrument.TomTom(**keywords)¶
TomTom
bases
TomTom
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TomTom
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
TomTom
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TomTom
instance variables
Instance variables inherited from Music21Object
:
Triangle¶
- class music21.instrument.Triangle(**keywords)¶
Triangle
bases
Triangle
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Triangle
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Triangle
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Triangle
instance variables
Instance variables inherited from Music21Object
:
Trombone¶
- class music21.instrument.Trombone(**keywords)¶
Trombone
bases
Trombone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Trombone
read/write properties
Read/write properties inherited from Music21Object
:
Trombone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Trombone
instance variables
Instance variables inherited from Music21Object
:
Trumpet¶
- class music21.instrument.Trumpet(**keywords)¶
Trumpet
bases
Trumpet
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Trumpet
read/write properties
Read/write properties inherited from Music21Object
:
Trumpet
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Trumpet
instance variables
Instance variables inherited from Music21Object
:
Tuba¶
- class music21.instrument.Tuba(**keywords)¶
Tuba
bases
Tuba
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Tuba
read/write properties
Read/write properties inherited from Music21Object
:
Tuba
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Tuba
instance variables
Instance variables inherited from Music21Object
:
TubularBells¶
- class music21.instrument.TubularBells(**keywords)¶
TubularBells
bases
TubularBells
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
TubularBells
read/write properties
Read/write properties inherited from Music21Object
:
TubularBells
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
TubularBells
instance variables
Instance variables inherited from Music21Object
:
Ukulele¶
- class music21.instrument.Ukulele(**keywords)¶
Ukulele
bases
Ukulele
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Ukulele
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Ukulele
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Ukulele
instance variables
Instance variables inherited from Music21Object
:
UnpitchedPercussion¶
- class music21.instrument.UnpitchedPercussion(**keywords)¶
UnpitchedPercussion
bases
UnpitchedPercussion
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
UnpitchedPercussion
read/write properties
- UnpitchedPercussion.modifier¶
Returns or sets the modifier for this instrument. A modifier could be something like “low-floor” for a TomTom or “rimshot” for a SnareDrum.
If the modifier is in the object’s ._modifierToPercMapPitch dictionary then changing the modifier also changes the .percMapPitch for the object
>>> bd = instrument.BongoDrums() >>> bd.modifier 'high'
>>> bd.percMapPitch 60 >>> bd.modifier = 'low' >>> bd.percMapPitch 61
Variations on modifiers can also be used and they get normalized:
>>> wb1 = instrument.Woodblock() >>> wb1.percMapPitch 76 >>> wb1.modifier = 'LO' >>> wb1.percMapPitch 77 >>> wb1.modifier # n.b. -- not LO 'low'
Read/write properties inherited from Music21Object
:
UnpitchedPercussion
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
UnpitchedPercussion
instance variables
Instance variables inherited from Music21Object
:
Vibraphone¶
- class music21.instrument.Vibraphone(**keywords)¶
Vibraphone
bases
Vibraphone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Vibraphone
read/write properties
Read/write properties inherited from Music21Object
:
Vibraphone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Vibraphone
instance variables
Instance variables inherited from Music21Object
:
Vibraslap¶
- class music21.instrument.Vibraslap(**keywords)¶
Vibraslap
bases
Vibraslap
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Vibraslap
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Vibraslap
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Vibraslap
instance variables
Instance variables inherited from Music21Object
:
Viola¶
- class music21.instrument.Viola(**keywords)¶
Viola
bases
Viola
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Viola
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Viola
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Viola
instance variables
Instance variables inherited from Music21Object
:
Violin¶
- class music21.instrument.Violin(**keywords)¶
Violin
bases
Violin
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Violin
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Violin
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Violin
instance variables
Instance variables inherited from Music21Object
:
Violoncello¶
- class music21.instrument.Violoncello(**keywords)¶
Violoncello
bases
Violoncello
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Violoncello
read/write properties
Read/write properties inherited from StringInstrument
:
Read/write properties inherited from Music21Object
:
Violoncello
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Violoncello
instance variables
Instance variables inherited from Music21Object
:
Vocalist¶
- class music21.instrument.Vocalist(**keywords)¶
n.b. called Vocalist to not be confused with stream.Voice
Vocalist
bases
Vocalist
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Vocalist
read/write properties
Read/write properties inherited from Music21Object
:
Vocalist
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Vocalist
instance variables
Instance variables inherited from Music21Object
:
Whip¶
- class music21.instrument.Whip(**keywords)¶
Whip
bases
Whip
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Whip
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Whip
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Whip
instance variables
Instance variables inherited from Music21Object
:
Whistle¶
- class music21.instrument.Whistle(**keywords)¶
Whistle
bases
Whistle
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Whistle
read/write properties
Read/write properties inherited from Music21Object
:
Whistle
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Whistle
instance variables
Instance variables inherited from Music21Object
:
WindMachine¶
- class music21.instrument.WindMachine(**keywords)¶
WindMachine
bases
WindMachine
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WindMachine
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
WindMachine
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WindMachine
instance variables
Instance variables inherited from Music21Object
:
Woodblock¶
- class music21.instrument.Woodblock(**keywords)¶
Woodblock
bases
Woodblock
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Woodblock
read/write properties
Read/write properties inherited from UnpitchedPercussion
:
Read/write properties inherited from Music21Object
:
Woodblock
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Woodblock
instance variables
Instance variables inherited from Music21Object
:
WoodwindInstrument¶
- class music21.instrument.WoodwindInstrument(**keywords)¶
WoodwindInstrument
bases
WoodwindInstrument
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
WoodwindInstrument
read/write properties
Read/write properties inherited from Music21Object
:
WoodwindInstrument
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
WoodwindInstrument
instance variables
Instance variables inherited from Music21Object
:
Xylophone¶
- class music21.instrument.Xylophone(**keywords)¶
Xylophone
bases
Xylophone
read-only properties
Read-only properties inherited from Music21Object
:
Read-only properties inherited from ProtoM21Object
:
Xylophone
read/write properties
Read/write properties inherited from Music21Object
:
Xylophone
methods
Methods inherited from Instrument
:
Methods inherited from Music21Object
:
Methods inherited from ProtoM21Object
:
Xylophone
instance variables
Instance variables inherited from Music21Object
:
Functions¶
- music21.instrument.bundleInstruments(streamIn: stream.Stream, *, inPlace=False) stream.Stream | None ¶
>>> up1 = note.Unpitched() >>> up1.storedInstrument = instrument.BassDrum() >>> upUnknownInstrument = note.Unpitched()
>>> up2 = note.Unpitched() >>> up2.storedInstrument = instrument.Cowbell() >>> s = stream.Stream() >>> s.append(up1) >>> s.append(upUnknownInstrument) >>> s.append(up2) >>> s2 = instrument.unbundleInstruments(s) >>> s3 = instrument.bundleInstruments(s2) >>> for test in s3: ... print(test.storedInstrument) Bass Drum Bass Drum Cowbell
- music21.instrument.deduplicate(s: stream.Stream, inPlace: bool = False) stream.Stream ¶
Check every offset in s for multiple instrument instances. If the .partName can be standardized across instances, i.e. if each instance has the same value or None, and likewise for .instrumentName, standardize the attributes. Further, and only if the above conditions are met, if there are two instances of the same class, remove all but one; if at least one generic Instrument instance is found at the same offset as one or more specific instruments, remove the generic Instrument instances.
Two Instrument instances:
>>> i1 = instrument.Instrument(instrumentName='Semi-Hollow Body') >>> i2 = instrument.Instrument() >>> i2.partName = 'Electric Guitar' >>> s1 = stream.Stream() >>> s1.insert(4, i1) >>> s1.insert(4, i2) >>> list(s1.getInstruments()) [<music21.instrument.Instrument 'Semi-Hollow Body'>, <music21.instrument.Instrument 'Electric Guitar: '>] >>> post = instrument.deduplicate(s1) >>> list(post.getInstruments()) [<music21.instrument.Instrument 'Electric Guitar: Semi-Hollow Body'>]
One Instrument instance and one subclass instance, with inPlace and parts:
>>> from music21.stream import Score, Part >>> i3 = instrument.Instrument() >>> i3.partName = 'Piccolo' >>> i4 = instrument.Piccolo() >>> s2 = stream.Score() >>> p1 = stream.Part() >>> p1.append([i3, i4]) >>> p2 = stream.Part() >>> p2.append([instrument.Flute(), instrument.Flute()]) >>> s2.insert(0, p1) >>> s2.insert(0, p2) >>> list(p1.getInstruments()) [<music21.instrument.Instrument 'Piccolo: '>, <music21.instrument.Piccolo 'Piccolo'>] >>> list(p2.getInstruments()) [<music21.instrument.Flute 'Flute'>, <music21.instrument.Flute 'Flute'>] >>> s2 = instrument.deduplicate(s2, inPlace=True) >>> list(p1.getInstruments()) [<music21.instrument.Piccolo 'Piccolo: Piccolo'>] >>> list(p2.getInstruments()) [<music21.instrument.Flute 'Flute'>]
- music21.instrument.ensembleNameBySize(number)¶
return the name of a generic ensemble with “number” players:
>>> instrument.ensembleNameBySize(4) 'quartet' >>> instrument.ensembleNameBySize(1) 'solo' >>> instrument.ensembleNameBySize(83) 'treoctogetet'
- music21.instrument.fromString(instrumentString: str, language: SearchLanguage = SearchLanguage.ALL)¶
Given a string with instrument content (from an orchestral score for example), attempts to return an appropriate
Instrument
.>>> t1 = instrument.fromString('Clarinet 2 in A') >>> t1 <music21.instrument.Clarinet 'Clarinet 2 in A'> >>> t1.transposition <music21.interval.Interval m-3>
>>> t2 = instrument.fromString('Clarinetto 3') >>> t2 <music21.instrument.Clarinet 'Clarinetto 3'>
>>> t3 = instrument.fromString('flauto 2') >>> t3 <music21.instrument.Flute 'flauto 2'>
Excess information is ignored, and the useful information can be extracted correctly as long as it’s sequential.
>>> t4 = instrument.fromString('I <3 music saxofono tenore go beavers') >>> t4 <music21.instrument.TenorSaxophone 'I <3 music saxofono tenore go beavers'>
Some more demos:
>>> t5 = instrument.fromString('Bb Clarinet') >>> t5 <music21.instrument.Clarinet 'Bb Clarinet'> >>> t5.transposition <music21.interval.Interval M-2>
>>> t6 = instrument.fromString('Clarinet in B-flat') >>> t5.__class__ == t6.__class__ True
>>> t5.transposition == t6.transposition True
>>> t7 = instrument.fromString('B-flat Clarinet.') >>> t5.__class__ == t7.__class__ and t5.transposition == t7.transposition True
>>> t8 = instrument.fromString('Eb Clarinet') >>> t5.__class__ == t8.__class__ True >>> t8.transposition <music21.interval.Interval m3>
Note that because of the ubiquity of B-flat clarinets and trumpets, and the rareness of B-natural forms of those instruments, this gives a B-flat, not B-natural clarinet, using the German form:
>>> t9 = instrument.fromString('Klarinette in B.') >>> t9 <music21.instrument.Clarinet 'Klarinette in B.'> >>> t9.transposition <music21.interval.Interval M-2>
Use “H” or “b-natural” to get an instrument in B-major. Or donate one to me, and I’ll change this back!
Standard abbreviations are acceptable:
>>> t10 = instrument.fromString('Cl in B-flat') >>> t10 <music21.instrument.Clarinet 'Cl in B-flat'> >>> t10.transposition <music21.interval.Interval M-2>
This should work with or without a terminal period (for both ‘Cl’ and ‘Cl.’):
>>> t11 = instrument.fromString('Cl. in B-flat') >>> t11.__class__ == t10.__class__ True
Previously an exact instrument name was not always working:
>>> instrument.fromString('Flute') <music21.instrument.Flute 'Flute'>
This common MIDI instrument was not previously working:
>>> instrument.fromString('Choir (Aahs)') <music21.instrument.Choir 'Choir (Aahs)'>
By default, this function searches over all stored instrument names. This includes multiple languages as well as the abbreviations (an honorary ‘language’ for these purposes).
Alternatively, you can specify the language to search using the language argument. (New in v7.3.)
>>> t12 = instrument.fromString('Klarinette', language=instrument.SearchLanguage.GERMAN) >>> t12 <music21.instrument.Clarinet 'Klarinette'>
This case works because the name ‘Klarinette’ is a recognised instrument name in German and appears in the German language list. If you search for a German name like ‘Klarinette’ on the French list (language=’french’), then it won’t be found and an InstrumentException will be raised. An InstrumentException is also raised if the specified language is not one of those currently supported: ‘english’, ‘french’, ‘german’, ‘italian’, ‘russian’, ‘spanish’, and ‘abbreviation’.
Note that the language string is not case-sensitive, so ‘French’ is also fine.
- music21.instrument.getAllNamesForInstrument(instrumentClass: Instrument, language: SearchLanguage = SearchLanguage.ALL)¶
Retrieves all currently stored names for a given instrument.
The instrumentClass should be a valid music21
Instrument
.By default, this function searches over all supported languages including instrument name abbreviations (an honorary ‘language’ for these purposes), and returns a dict with keys for the language tested and values as a list of strings for any names in that language.
>>> instrument.getAllNamesForInstrument(instrument.Flute()) {'english': ['flute', 'flutes', 'transverse flute'], 'french': ['flûte', 'flûte traversière', 'flûtes', 'grande flûte'], 'german': ['flöte', 'flöten', 'querflöte'], 'italian': ['flauti', 'flauto', 'flauto traverso'], 'russian': ['fleita'], 'spanish': ['flauta', 'flauta de boehm', 'flauta de concierto', 'flauta traversa', 'flauta travesera', 'flautas'], 'abbreviation': ['fl']}
Alternatively, you can specify the language to search using the language argument.
>>> instrument.getAllNamesForInstrument(instrument.Flute(), language='german') {'german': ['flöte', 'flöten', 'querflöte']}
An InstrumentException is raised if the specified language is not one of those currently supported: ‘english’, ‘french’, ‘german’, ‘italian’, ‘russian’, ‘spanish’, and ‘abbreviation’.
Note that the language string is not case-sensitive, so ‘German’ is also fine.
- music21.instrument.instrumentFromMidiProgram(number: int) Instrument ¶
Return the instrument with “number” as its assigned MIDI program. Notice any of the values 0-5 will return Piano.
Lookups are performed against instrument.MIDI_PROGRAM_TO_INSTRUMENT.
>>> instrument.instrumentFromMidiProgram(4) <music21.instrument.ElectricPiano 'Electric Piano'> >>> instrument.instrumentFromMidiProgram(21) <music21.instrument.Accordion 'Accordion'> >>> instrument.instrumentFromMidiProgram(500) Traceback (most recent call last): music21.exceptions21.InstrumentException: No instrument found for MIDI program 500 >>> instrument.instrumentFromMidiProgram('43') Traceback (most recent call last): TypeError: Expected int, got <class 'str'>
- music21.instrument.partitionByInstrument(streamObj: stream.Stream) stream.Stream ¶
Given a single Stream, or a Score or similar multi-part structure, partition into a Part for each unique Instrument, joining events possibly from different parts.
>>> p1 = converter.parse("tinynotation: 4/4 c4 d e f g a b c' c1") >>> p2 = converter.parse("tinynotation: 4/4 C#4 D# E# F# G# A# B# c# C#1")
>>> p1.getElementsByClass(stream.Measure)[0].insert(0.0, instrument.Piccolo()) >>> p1.getElementsByClass(stream.Measure)[0].insert(2.0, instrument.AltoSaxophone()) >>> p1.getElementsByClass(stream.Measure)[1].insert(3.0, instrument.Piccolo())
>>> p2.getElementsByClass(stream.Measure)[0].insert(0.0, instrument.Trombone()) >>> p2.getElementsByClass(stream.Measure)[0].insert(3.0, instrument.Piccolo()) # not likely >>> p2.getElementsByClass(stream.Measure)[1].insert(1.0, instrument.Trombone())
>>> s = stream.Score() >>> s.insert(0, p1) >>> s.insert(0, p2) >>> s.show('text') {0.0} <music21.stream.Part ...> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.instrument.Piccolo 'Piccolo'> {0.0} <music21.clef.TrebleClef> {0.0} <music21.meter.TimeSignature 4/4> {0.0} <music21.note.Note C> {1.0} <music21.note.Note D> {2.0} <music21.instrument.AltoSaxophone 'Alto Saxophone'> {2.0} <music21.note.Note E> {3.0} <music21.note.Note F> {4.0} <music21.stream.Measure 2 offset=4.0> {0.0} <music21.note.Note G> {1.0} <music21.note.Note A> {2.0} <music21.note.Note B> {3.0} <music21.instrument.Piccolo 'Piccolo'> {3.0} <music21.note.Note C> {8.0} <music21.stream.Measure 3 offset=8.0> {0.0} <music21.note.Note C> {4.0} <music21.bar.Barline type=final> {0.0} <music21.stream.Part ...> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.instrument.Trombone 'Trombone'> {0.0} <music21.clef.BassClef> {0.0} <music21.meter.TimeSignature 4/4> {0.0} <music21.note.Note C#> {1.0} <music21.note.Note D#> {2.0} <music21.note.Note E#> {3.0} <music21.instrument.Piccolo 'Piccolo'> {3.0} <music21.note.Note F#> {4.0} <music21.stream.Measure 2 offset=4.0> {0.0} <music21.note.Note G#> {1.0} <music21.instrument.Trombone 'Trombone'> {1.0} <music21.note.Note A#> {2.0} <music21.note.Note B#> {3.0} <music21.note.Note C#> {8.0} <music21.stream.Measure 3 offset=8.0> {0.0} <music21.note.Note C#> {4.0} <music21.bar.Barline type=final>
>>> s2 = instrument.partitionByInstrument(s) >>> len(s2.parts) 3
# TODO: this step might not be necessary:
>>> for p in s2.parts: ... p.makeRests(fillGaps=True, inPlace=True)
# TODO: this step SHOULD not be necessary (.template()):
>>> for p in s2.parts: ... p.makeMeasures(inPlace=True) ... p.makeTies(inPlace=True)
>>> s2.show('text') {0.0} <music21.stream.Part Piccolo> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.instrument.Piccolo 'Piccolo'> {0.0} <music21.clef.TrebleClef> {0.0} <music21.meter.TimeSignature 4/4> {0.0} <music21.note.Note C> {1.0} <music21.note.Note D> {2.0} <music21.note.Rest quarter> {3.0} <music21.note.Note F#> {4.0} <music21.stream.Measure 2 offset=4.0> {0.0} <music21.note.Note G#> {1.0} <music21.note.Rest half> {3.0} <music21.note.Note C> {8.0} <music21.stream.Measure 3 offset=8.0> {0.0} <music21.note.Note C> {4.0} <music21.bar.Barline type=final> {0.0} <music21.stream.Part Alto Saxophone> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.instrument.AltoSaxophone 'Alto Saxophone'> {0.0} <music21.clef.TrebleClef> {0.0} <music21.meter.TimeSignature 4/4> {0.0} <music21.note.Rest half> {2.0} <music21.note.Note E> {3.0} <music21.note.Note F> {4.0} <music21.stream.Measure 2 offset=4.0> {0.0} <music21.note.Note G> {1.0} <music21.note.Note A> {2.0} <music21.note.Note B> {3.0} <music21.bar.Barline type=final> {0.0} <music21.stream.Part Trombone> {0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.instrument.Trombone 'Trombone'> {0.0} <music21.clef.BassClef> {0.0} <music21.meter.TimeSignature 4/4> {0.0} <music21.note.Note C#> {1.0} <music21.note.Note D#> {2.0} <music21.note.Note E#> {3.0} <music21.note.Rest quarter> {4.0} <music21.stream.Measure 2 offset=4.0> {0.0} <music21.note.Rest quarter> {1.0} <music21.note.Note A#> {2.0} <music21.note.Note B#> {3.0} <music21.note.Note C#> {8.0} <music21.stream.Measure 3 offset=8.0> {0.0} <music21.note.Note C#> {4.0} <music21.bar.Barline type=final>
Changed in v8: returns the original stream if there are no instruments.
TODO: parts should be in Score Order. Coincidence that this almost works. TODO: use proper recursion to make a copy of the stream. TODO: final barlines should be aligned.
- music21.instrument.unbundleInstruments(streamIn: stream.Stream, *, inPlace=False) stream.Stream | None ¶
takes a
Stream
that hasNotRest
objects and moves their .storedInstrument attributes to a new Stream (unless inPlace=True)>>> up1 = note.Unpitched() >>> up1.storedInstrument = instrument.BassDrum() >>> up2 = note.Unpitched() >>> up2.storedInstrument = instrument.Cowbell() >>> s = stream.Stream() >>> s.append(up1) >>> s.append(up2) >>> s2 = instrument.unbundleInstruments(s) >>> s2.show('text') {0.0} <music21.instrument.BassDrum 'Bass Drum'> {0.0} <music21.note.Unpitched 'Bass Drum'> {1.0} <music21.instrument.Cowbell 'Cowbell'> {1.0} <music21.note.Unpitched 'Cowbell'>