Table Of Contents

Previous topic

music21.key

Next topic

music21.interval

This Page

music21.instrument

This module defines object models for instrument representations. Metadata for instrument realizations, including transpositions and default MIDI program numbers, are also included.

Instrument

Inherits from: Music21Object

class music21.instrument.Instrument

Instrument attributes

Attributes without Documentation: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

Instrument properties

mx
>>> from music21 import *
>>> i = instrument.Celesta()
>>> mxScorePart = i.mx
>>> len(mxScorePart.scoreInstrumentList)
1
>>> mxScorePart.scoreInstrumentList[0].instrumentName
'Celesta'
>>> mxScorePart.midiInstrumentList[0].midiProgram
9

Properties inherited from Music21Object: classes, duration, offset, parent, priority

Instrument methods

bestName()
Find a viable name, looking first at instrument, then part, then abbreviations.
instrumentIdRandomize()
Force a unique id by using an MD5
midiChannelAutoAssign(usedChannels=[])
Force a midi channel
partIdRandomize()
Force a unique id by using an MD5

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Bassoon

Inherits from: WoodwindInstrument, Instrument, Music21Object

class music21.instrument.Bassoon

Celesta

Inherits from: KeyboardInstrument, Instrument, Music21Object

class music21.instrument.Celesta

Clavichord

Inherits from: KeyboardInstrument, Instrument, Music21Object

class music21.instrument.Clavichord

Contrabass

Inherits from: StringInstrument, Instrument, Music21Object

class music21.instrument.Contrabass

Contrabass attributes

lowestNote
An object for storing pitch values. All values are represented internally as a scale step (self.step), and octave and an accidental object. In addition, pitches know their pitchSpace representation (self._ps); altering any of the first three changes the pitchSpace representation. Similarly, altering the pitchSpace representation alters the first three.

Attributes inherited from Instrument: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

Contrabass properties

Properties inherited from StringInstrument: stringPitches

Properties inherited from Instrument: mx

Properties inherited from Music21Object: classes, duration, offset, parent, priority

Contrabass methods

Methods inherited from Instrument: bestName(), instrumentIdRandomize(), midiChannelAutoAssign(), partIdRandomize()

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Harpsichord

Inherits from: KeyboardInstrument, Instrument, Music21Object

class music21.instrument.Harpsichord

KeyboardInstrument

Inherits from: Instrument, Music21Object

class music21.instrument.KeyboardInstrument

Piano

Inherits from: KeyboardInstrument, Instrument, Music21Object

class music21.instrument.Piano

StringInstrument

Inherits from: Instrument, Music21Object

class music21.instrument.StringInstrument

StringInstrument attributes

Attributes inherited from Instrument: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

StringInstrument properties

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[#reentrant]_

>>> vln1 = Violin()
>>> 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 *Anahit*. N.B. string to pitch conversion
>>> vln1.stringPitches = ["G3","G4","B4","D4"]
>>> vln1.stringPitches
[G3, G4, B4, D4]
..[#reentrant] 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*

Properties inherited from Instrument: mx

Properties inherited from Music21Object: classes, duration, offset, parent, priority

StringInstrument methods

Methods inherited from Instrument: bestName(), instrumentIdRandomize(), midiChannelAutoAssign(), partIdRandomize()

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Viola

Inherits from: StringInstrument, Instrument, Music21Object

class music21.instrument.Viola

Viola attributes

lowestNote
An object for storing pitch values. All values are represented internally as a scale step (self.step), and octave and an accidental object. In addition, pitches know their pitchSpace representation (self._ps); altering any of the first three changes the pitchSpace representation. Similarly, altering the pitchSpace representation alters the first three.

Attributes inherited from Instrument: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

Viola properties

Properties inherited from StringInstrument: stringPitches

Properties inherited from Instrument: mx

Properties inherited from Music21Object: classes, duration, offset, parent, priority

Viola methods

Methods inherited from Instrument: bestName(), instrumentIdRandomize(), midiChannelAutoAssign(), partIdRandomize()

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Violin

Inherits from: StringInstrument, Instrument, Music21Object

class music21.instrument.Violin

Violin attributes

lowestNote
An object for storing pitch values. All values are represented internally as a scale step (self.step), and octave and an accidental object. In addition, pitches know their pitchSpace representation (self._ps); altering any of the first three changes the pitchSpace representation. Similarly, altering the pitchSpace representation alters the first three.

Attributes inherited from Instrument: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

Violin properties

Properties inherited from StringInstrument: stringPitches

Properties inherited from Instrument: mx

Properties inherited from Music21Object: classes, duration, offset, parent, priority

Violin methods

Methods inherited from Instrument: bestName(), instrumentIdRandomize(), midiChannelAutoAssign(), partIdRandomize()

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

Violoncello

Inherits from: StringInstrument, Instrument, Music21Object

class music21.instrument.Violoncello

Violoncello attributes

lowestNote
An object for storing pitch values. All values are represented internally as a scale step (self.step), and octave and an accidental object. In addition, pitches know their pitchSpace representation (self._ps); altering any of the first three changes the pitchSpace representation. Similarly, altering the pitchSpace representation alters the first three.

Attributes inherited from Instrument: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation

Attributes inherited from Music21Object: classSortOrder, id, groups

Violoncello properties

Properties inherited from StringInstrument: stringPitches

Properties inherited from Instrument: mx

Properties inherited from Music21Object: classes, duration, offset, parent, priority

Violoncello methods

Methods inherited from Instrument: bestName(), instrumentIdRandomize(), midiChannelAutoAssign(), partIdRandomize()

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

WoodwindInstrument

Inherits from: Instrument, Music21Object

class music21.instrument.WoodwindInstrument