MusicTransform[music,tf]
applies the transformation tf to the music object music.
MusicTransform[music,{tf,params}]
applies tf to music with parameters params.
MusicTransform[tf]
represents an operator form of MusicTransform that can be applied to an expression.
MusicTransform
MusicTransform[music,tf]
applies the transformation tf to the music object music.
MusicTransform[music,{tf,params}]
applies tf to music with parameters params.
MusicTransform[tf]
represents an operator form of MusicTransform that can be applied to an expression.
Details
- MusicTransform is a function that applies musical transformations such as transposition, inversion and voice separation.
- Apply a specific transformation to one or more music objects.
- MusicTransform[music,"Properties"] returns the names of all available transformations as a list of strings.
- MusicTransform[music,{"Arguments","prop"}] returns the names of all available arguments for a given transformation as a list of strings.
- MusicTransform[music,{"Options","prop"}] returns the names of all available suboptions for a given transformation as a list of strings.
- The supported transformations depend on the type of music object passed as an input.
- Transformations of all objects containing a MusicPitch object (or a list of such):
-
"NormalizeAccidentals" respell pitch accidentals » "SortByPitch" order pitches according to midi value and/or key » "ScaleTranspose" modify all pitches by a number of scale degrees » "Transpose" modify all pitches by a fixed interval » - Transformations of containers such as MusicScore, MusicVoice or MusicMeasure:
-
{"Take", seq} result with only the elements specified by seq » {"Drop", seq} result with elements specified by seq dropped » {"Trim", dur} result with events occurring within duration dur » "Separate" separate a single voice into multiple monophonic voices » - Transformations unique to MusicScore and MusicVoice (or a list of such):
-
"Combine" collapse multiple voices in parallel into a single voice » "Join" sequentially join scores or voices end to end » - Transformations unique to MusicInterval:
-
"Inversion" inversion of the interval to a simple interval »
Examples
open all close allBasic Examples (2)
Transpose a MusicNote object:
MusicTransform[MusicNote["C"], {"Transpose", Quantity[7, IndependentUnit["semitones"]]}]Use the operator form of MusicTransform:
MusicTransform[{"Transpose", Quantity[7, IndependentUnit["semitones"]]}] /@ {MusicNote["C"], MusicChord["DMinor"]}Scope (37)
Music Container Primitives (22)
MusicScore (7)
List available transformations:
MusicTransform[MusicScore[{"C"}], "Properties"]Take the first voice from a score:
m = MusicScore[{MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["C major"]["PitchList"]],
MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["A minor"]["PitchList"]]}]Use the same sequence specification as Take in the transformation parameters:
MusicTransform[m, {"Take", 1}]Take the first measure from each voice:
MusicTransform[m, {"Take", All, 1}]Take the first note from each measure from each voice:
MusicTransform[m, {"Take", All, All, 1}]Drop the first voice from a score:
m = MusicScore[{MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["C major"]["PitchList"]],
MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["A minor"]["PitchList"]]}]Use the same sequence specification as Drop in the transformation parameters:
MusicTransform[m, {"Drop", 1}]Drop the first measure from each voice:
MusicTransform[m, {"Drop", None, 1}]MusicScore[{MusicVoice[{MusicChord["DMajor"], MusicChord["GMajor"]}]}];
MusicTransform[%, "Separate"]MusicMeasurements[%, "NoteList"]MusicScore@{MusicVoice[{MusicNote["B4"], MusicNote["C5"]}], MusicVoice[{MusicNote["F4"], MusicNote["E4"]}], MusicVoice[{MusicNote["G3"], MusicNote["C4"]}]};
MusicTransform[%, "Combine"]MusicMeasurements[%, "NoteList"]{MusicScore[{MusicVoice[{"C"}]}], MusicScore[{MusicVoice[{"F"}], MusicVoice[{"A"}]}]}
MusicTransform[%, "Join"]Remove leading and trailing rests from a score:
score = MusicScore[{MusicNote[#, 1 / 4]& /@ {None, None, "C", "D", "E", "F"}, MusicNote[If[StringQ[#], # <> "#", #], MusicDuration[1 / 4, "Multiplier" -> 2 / 3]]& /@ {None, None, None, "C", "D", "E", "F", "G", "A"}}]trim = MusicTransform[score, "Trim"]Extract a snippet of a score containing events durations up to 1/4:
MusicTransform[trim, {"Trim", 1 / 4}]Take the last 1/4 duration from the end of the score:
MusicTransform[trim, {"Trim", -1 / 4}]Trim to a minimum and maximum accumulated duration:
MusicTransform[trim, {"Trim", {1 / 4, 1 / 2}}]Specify the region of interest as a Quantity of beats:
MusicTransform[trim, {"Trim", Quantity[2, "Beats"]}]Specify the region of interest as a MusicDuration object:
MusicTransform[trim, {"Trim", MusicDuration["Beats" -> 1 / 4, "Multiplier" -> 2 / 3]}]MusicVoice (9)
List available transformations:
MusicTransform[MusicVoice[{"C"}], "Properties"]Available transformations on lists of voices:
MusicTransform[{MusicVoice[{"C"}]}, "Properties"]MusicTransform[MusicVoice[{MusicChord["DMajor"], MusicChord["GMajor"]}], "Separate"]MusicMeasurements[%, "NoteList"]MusicTransform[{MusicVoice[{MusicNote["B4"], MusicNote["C5"]}], MusicVoice[{MusicNote["F4"], MusicNote["E4"]}], MusicVoice[{MusicNote["G3"], MusicNote["C4"]}]}, "Combine"]MusicMeasurements[%, "NoteList"]MusicTransform[{MusicVoice[{"C"}], MusicVoice[{"F"}]}, "Join"]MusicMeasurements[%, "NoteList"]Respell pitch accidentals according to the key signature of the voice:
m = MusicVoice[{"D#", "G", "A#"}, <|"KeySignature" -> -3|>];
MusicTransform[m, "NormalizeAccidentals"]MusicMeasurements[%, "NoteList"]Take the first measure from a voice:
m = MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["C major"]["PitchList"]];
MusicTransform[m, {"Take", 1}]Drop the first measure from a voice:
m = MusicVoice[MusicNote[#, 1 / 4]& /@ MusicScale["C major"]["PitchList"]];
MusicTransform[m, {"Drop", 1}]Extract a region of interest from a voice:
m = MusicVoice[MusicNote[#, 1 / 8]& /@ {"C", "E", "G", "D", "F", "A"}, <|"TimeSignature" -> MusicTimeSignature[6, 8]|>];
MusicTransform[m, {"Trim", Quantity[-1, "Beats"]}]MusicMeasurements[%, "NoteList"]Transpose the pitches in a voice by three degrees in a specific scale:
voice = MusicVoice[MusicNote[#, 1 / 4]& /@ {"C", "D", "E", "F"}];
MusicTransform[voice, {"ScaleTranspose", 3, MusicScale["C major"]}]
MusicMeasurements["NoteList"]@%For diatonic scales, by default all pitches in the input are coerced to scale pitches in the output:
MusicTransform[voice + MusicInterval["m2"], {"ScaleTranspose", 3, MusicScale["C major"]}]
MusicMeasurements["NoteList"]@%Allow non-scale pitches in the output:
MusicTransform[voice + MusicInterval["m2"], {"ScaleTranspose", 3, MusicScale["C major"], False}]
MusicMeasurements["NoteList"]@%Compare with a transposition by a fixed interval:
MusicTransform[voice, {"Transpose", MusicInterval["Third"]}]
MusicMeasurements["NoteList"]@%MusicMeasure (6)
List available transformations:
MusicTransform[MusicMeasure[{"C"}], "Properties"]Take the first event from a measure:
m = MusicMeasure[{"C", "D", "E", "F"}];
MusicTransform[m, {"Take", 1}]Drop the first event from a measure:
m = MusicMeasure[{"C", "D", "E", "F"}];
MusicTransform[m, {"Drop", 1}]Extract a region of interest from a measure:
m = MusicMeasure[{None, "C", "E", "G"}];
MusicTransform[m, {"Trim", {1 / 4, 3 / 4}}]MusicMeasurements[%, "NoteList"]Respell pitch accidentals according to the key signature of the measure:
m = MusicMeasure[{"D#", "G", "A#"}, <|"KeySignature" -> -3|>];
MusicTransform[m, "NormalizeAccidentals"]Separate measures from chords:
MusicTransform[MusicMeasure[{MusicChord["DMajor"], MusicChord["GMajor"]}], "Separate"]MusicMeasurements[%, "NoteList"]Music Event Primitives (4)
MusicNote (3)
List available transformations:
MusicTransform[MusicNote["C"], "Properties"]Available transformations on lists of notes:
MusicTransform[{MusicNote["C"]}, "Properties"]Transpose a note by a specified MusicInterval:
MusicTransform[MusicNote["C"], {"Transpose", MusicInterval["AugmentedSecond"]}]Named diatonic intervals can be used to select the appropriate output pitch key:
MusicTransform[MusicNote["C"], {"Transpose", MusicInterval["MinorThird"]}]Check that the two transformations are enharmonically equivalent (two names specifying the same pitch):
MusicMeasurements[%, {"EnharmonicQ", %%}]Sort a list of notes according to their pitch:
notes = MusicNote /@ { "D4", "B3", "Cbb4", "C##4", "Cb4", "C4"};
MusicTransform[notes, "SortByPitch"]Music Property Primitives (11)
MusicPitch (5)
List available transformations:
MusicTransform[MusicPitch["C"], "Properties"]List available transformations for a collection of pitches:
MusicTransform[{MusicPitch["C"]}, "Properties"]Respell an accidental according to a specified key signature:
MusicTransform[MusicPitch["D#"], {"NormalizeAccidentals", MusicKeySignature[-3]}]Transpose a MusicPitch object by a fixed number of semitones:
MusicTransform[MusicPitch["E"], {"Transpose", 4}]Specify the interval as a Quantity:
MusicTransform[MusicPitch["E"], {"Transpose", Quantity[4, IndependentUnit["semitones"]]}]Specify the interval as a MusicInterval:
MusicTransform[MusicPitch["E"], {"Transpose", MusicInterval["MajorThird"]}]Transpose a list of pitches by a scale degree:
p = MusicPitch /@ {"C", "D", "E", "F"};
MusicTransform[p, {"ScaleTranspose", 3, MusicScale["C Major"]}]The pitches were transposed by different qualities of the same basic diatonic interval:
p - %Sort a list of MusicPitch objects according to pitch key, accidental and MIDI value:
p = MusicPitch /@ { "B#3", "B3", "Cbb4", "C##4", "Cb4", "C4"};
MusicTransform[p, "SortByPitch"]MusicInterval (2)
List available transformations:
MusicTransform[MusicInterval[5], "Properties"]m = MusicInterval["PerfectFifth"];
MusicTransform[m, "Inversion"]Note the interval direction is reversed:
%["Semitones"]Compound intervals (spanning more than one octave) return simple intervals (≤ one octave):
m = MusicInterval[<|"Name" -> "PerfectFifth", "CompoundOctaves" -> 2|>];
MusicTransform[m, "Inversion"]MusicScale (2)
MusicKeySignature (2)
List available transformations:
MusicTransform[MusicKeySignature[0], "Properties"]Transpose a key signature by a specified interval:
m = MusicKeySignature[-3];
MusicTransform[m, {"Transpose", MusicInterval[1]}]Transpose a key signature containing a list of alteration rules:
m = MusicKeySignature[{"F" -> 1, "B" -> -1}];
MusicTransform[m, {"Transpose", MusicInterval["Major Sixth"]}]Related Guides
History
Text
Wolfram Research (2026), MusicTransform, Wolfram Language function, https://reference.wolfram.com/language/ref/MusicTransform.html.
CMS
Wolfram Language. 2026. "MusicTransform." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MusicTransform.html.
APA
Wolfram Language. (2026). MusicTransform. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MusicTransform.html
BibTeX
@misc{reference.wolfram_2026_musictransform, author="Wolfram Research", title="{MusicTransform}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/MusicTransform.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_musictransform, organization={Wolfram Research}, title={MusicTransform}, year={2026}, url={https://reference.wolfram.com/language/ref/MusicTransform.html}, note=[Accessed: 12-June-2026]}