MusicMeasure[{event1,event2,…}]
returns a musical measure that contains the musical events eventi.
MusicMeasure[events,ts,ks]
returns a musical measure with time signature ts and key signature ks.
MusicMeasure[events,ts,ks,properties]
returns a musical measure with the specified property association properties.
MusicMeasure[music,events,ts,ks,properties]
returns a musical measure with properties inherited from another measure music.
MusicMeasure
MusicMeasure[{event1,event2,…}]
returns a musical measure that contains the musical events eventi.
MusicMeasure[events,ts,ks]
returns a musical measure with time signature ts and key signature ks.
MusicMeasure[events,ts,ks,properties]
returns a musical measure with the specified property association properties.
MusicMeasure[music,events,ts,ks,properties]
returns a musical measure with properties inherited from another measure music.
Details and Options
- MusicMeasure represents a musical measure containing a collection of musical events such as notes, chords or rests.
- MusicMeasure represents a musical measure containing a collection of musical events such as notes, chords or rests.
- The events can be:
-
MusicNote a note defined by a pitch and a duration MusicChord a chord defined by a pitch list and a duration MusicRest a rest defined by a duration - The association properties can contain the following keys:
-
"NoteList" list of events as MusicNote, MusicChord or MusicRest "Instrument" instrument used for playback "KeySignature" measure key signature as MusicKeySignature "MusicTempo" tempo used for playback "TimeSignature" measure time signature as MusicTimeSignature - For a music measure object obj, any of the above properties can be obtained using obj["prop"]. Use obj["PropertyAssociation"] to retrieve the values of all available properties.
- If no "TimeSignature" is specified and the cumulative duration of the event list is less than the measure duration of the default time signature (4/4 or 6/8 depending on the "BeatDuration" of the first event duration), then the event list is padded with a rest. If the cumulative duration of the event list exceeds the default measure duration, the default time signature will be expanded to hold all events.
- If a "TimeSignature" property is specified, the cumulative duration of the event list cannot exceed the measure duration mandated by the time signature.
- The following options are supported:
-
MusicTempo tempo used for playback
Examples
open all close allBasic Examples (4)
Construct the music measure containing the specified notes and rests:
MusicMeasure[{MusicNote["G", 1 / 4], MusicRest[1 / 4], MusicChord["DMajor", 1 / 2]}]Construct the music measure with the specified time signature and key signature:
MusicMeasure[{MusicNote["G", 1 / 4], MusicRest[1 / 4], MusicChord["DMajor", 1 / 4]}, MusicTimeSignature[3, 4], MusicKeySignature[1]]Construct the music measure with properties specified in an Association:
MusicMeasure[{MusicNote["C"]}, <|"TimeSignature" -> MusicTimeSignature[3, 4]|>]Construct the music measure with default properties inherited from another MusicMeasure:
m = MusicMeasure[<|"TimeSignature" -> MusicTimeSignature[3, 4]|>]MusicMeasure[m, {MusicNote["G"]}, <|"KeySignature" -> MusicKeySignature[1]|>]Scope (6)
List all available properties:
MusicMeasure[{None, "G", "C"}]["Properties"]List all available properties and their values:
MusicMeasure[{None, "G", "C"}]["PropertyAssociation"]//DatasetGet and set the "MusicTempo" property:
d = MusicMeasure[{None, "G", "C"}];
d["MusicTempo"]MusicMeasure[d, MusicTempo -> 88];
%["MusicTempo"]Get and set the "KeySignature" property:
d = MusicMeasure[{None, "G", "C"}];
d["KeySignature"]MusicMeasure[d, MusicKeySignature["G"]]Get and set the "TimeSignature" property:
d = MusicMeasure[{MusicNote["C", 1]}]
d["TimeSignature"]MusicMeasure[d, MusicTimeSignature[2, 2]]If the total duration of events is shorter than the duration of the measure, a rest is appended:
MusicMeasure[{MusicNote["C", 1 / 2]}]
%["NoteList"]If the total duration of the events is longer than 1, and the time signature is not specified, the time signature is adjusted to accommodate all the events:
MusicMeasure[{MusicNote["C", 7 / 4]}]
%["TimeSignature"]If a time signature is specified, the total duration of the events needs to be shorter than or equal to the duration of the measure:
MusicMeasure[{MusicNote["C", 7 / 4]}, MusicTimeSignature[4, 4]];Retrieve the "NoteList" property:
d = MusicMeasure[{None, "E5", "G#"}];
d["NoteList"]Cases[d["NoteList"], _MusicNote ? (Positive[#["Pitch"]["Accidental"]]&)]Find the positions of all rests:
Position[d["NoteList"], _MusicRest]Retrieve the octave values of all note pitches in the measure:
Cases[d["NoteList"], m_MusicNote :> m["Pitch"]["Octave"], Infinity]ReplaceAll[d, r_MusicRest :> MusicNote["D", MusicDuration[r]]]Transpose all note pitches up by a fifth:
d + MusicInterval["PerfectFifth"]Set the "Instrument" property, to be used for playback:
m = MusicMeasure[{None, "G", "C"}, <|"Instrument" -> "Trumpet"|>]Convert to an Audio object, using the specified instrument style:
Audio[m]Convert to a Sound object, preserving the specified instrument style:
Sound[m]Export to a "MIDI" file, preserving the specified instrument style:
Import[Export["out.mid", m], "SoundNotes"]Options (1)
MusicTempo (1)
Specify a tempo to use for playback:
m = MusicMeasure[{"C", "G", "E", "F"}, MusicTempo -> 88]Compute the measure duration as a quantity of seconds, using the specified tempo:
Duration[m]By default, the tempo for playback is set to 120 beats per minute:
Duration[MusicMeasure[{"C", "G", "E", "F"}]]Properties & Relations (2)
Use MusicMeasurements to compute properties of a measure:
MusicMeasurements[MusicMeasure[{"C", "D", "G", "Eb"}], {"Ambitus", "EstimatedKey", "PitchClasses"}]Use MusicTransform to modify a measure:
MusicTransform[{"Transpose", 5}]@MusicMeasure[{"C", "D", "G", "Eb"}]Related Guides
History
Text
Wolfram Research (2026), MusicMeasure, Wolfram Language function, https://reference.wolfram.com/language/ref/MusicMeasure.html.
CMS
Wolfram Language. 2026. "MusicMeasure." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MusicMeasure.html.
APA
Wolfram Language. (2026). MusicMeasure. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MusicMeasure.html
BibTeX
@misc{reference.wolfram_2026_musicmeasure, author="Wolfram Research", title="{MusicMeasure}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/MusicMeasure.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_musicmeasure, organization={Wolfram Research}, title={MusicMeasure}, year={2026}, url={https://reference.wolfram.com/language/ref/MusicMeasure.html}, note=[Accessed: 12-June-2026]}