This module defines object models for instrument representations. Metadata for instrument realizations, including transpositions and default MIDI program numbers, are also included.
Inherits from: Music21Object, JSONSerializer
Instrument attributes
- classSortOrder¶
Property which returns an number (int or otherwise) depending on the class of the Music21Object that represents a priority for an object based on its class alone – used as a tie for stream sorting in case two objects have the same offset and priority. Lower numbers are sorted to the left of higher numbers. For instance, Clef, KeySignature, TimeSignature all come (in that order) before Note. All undefined classes have classSortOrder of 20 – same as note.Note
>>> from music21 import * >>> tc = clef.TrebleClef() >>> tc.classSortOrder 0 >>> ks = key.KeySignature(3) >>> ks.classSortOrder 1 New classes can define their own default classSortOrder >>> class ExampleClass(base.Music21Object): ... classSortOrderDefault = 5 ... >>> ec1 = ExampleClass() >>> ec1.classSortOrder 5Attributes without Documentation: instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: 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 9Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: WoodwindInstrument, Instrument, Music21Object, JSONSerializer
Inherits from: KeyboardInstrument, Instrument, Music21Object, JSONSerializer
Inherits from: KeyboardInstrument, Instrument, Music21Object, JSONSerializer
Inherits from: StringInstrument, Instrument, Music21Object, JSONSerializer
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: classSortOrder, instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: id, groups
Contrabass properties
Properties inherited from StringInstrument: stringPitches
Properties inherited from Instrument: mx
Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: KeyboardInstrument, Instrument, Music21Object, JSONSerializer
Inherits from: Instrument, Music21Object, JSONSerializer
Inherits from: KeyboardInstrument, Instrument, Music21Object, JSONSerializer
Inherits from: Instrument, Music21Object, JSONSerializer
StringInstrument attributes
Attributes inherited from Instrument: classSortOrder, instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: 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: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: StringInstrument, Instrument, Music21Object, JSONSerializer
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: classSortOrder, instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: id, groups
Viola properties
Properties inherited from StringInstrument: stringPitches
Properties inherited from Instrument: mx
Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: StringInstrument, Instrument, Music21Object, JSONSerializer
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: classSortOrder, instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: id, groups
Violin properties
Properties inherited from StringInstrument: stringPitches
Properties inherited from Instrument: mx
Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: StringInstrument, Instrument, Music21Object, JSONSerializer
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: classSortOrder, instrumentId, instrumentName, midiChannel, partId, partName, midiProgram, instrumentAbbreviation, transposition, partAbbreviation
Attributes inherited from Music21Object: id, groups
Violoncello properties
Properties inherited from StringInstrument: stringPitches
Properties inherited from Instrument: mx
Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority
Properties inherited from JSONSerializer: json
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(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Instrument, Music21Object, JSONSerializer