Approximately three years ago, I posted an article about converting sheet music into Mathematica audio. At that time, the conversion was limited to simple sheet music.
At the end of the article, I listed two future goals under “In the future”:
- Achieving richer musical expression
- Reducing the manual effort in digitizing sheet music
- Achieving richer musical expression
- Reducing the manual effort in digitizing sheet music
Now, three years later, with the advent of generative AI and Mathematica version 15’s Computational Music support, these have become achievable.
This time, I attempted to convert the following sheet music into Mathematica code using GPT-5.6.
Since a request for a simple chord conversion was insufficient, I used a prompt that provided an example from the first measure and asked for the chords for the remaining measures, from the second through the fourth.
Please convert sheet music into the Wolfram Language.
Using the example below?which shows how the chord and bass parts of the first measure have been converted to the Wolfram Language?please convert measures 2 through 4 into the Wolfram Language.
Conversion of the chord part in the first measure
{
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 3/8, “TieType” -> “NotTied”|>],
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 1/8, “TieType” -> “TiedAfter”|>],
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 1/2, “TieType” -> “TiedBefore”|>]
}
Conversion of the bass part in the first measure
{
MusicNote[“A2”, <|”Duration” -> 3/8, “TieType” -> “NotTied”|>],
MusicNote[“A2”, <|”Duration” -> 1/8, “TieType” -> “TiedAfter”|>],
MusicNote[“A2”, <|”Duration” -> 1/4, “TieType” -> “TiedBefore”|>],
MusicNote[“E2”, <|”Duration” -> 1/8, “TieType” -> “NotTied”|>],
MusicNote[“G#2”, <|”Duration” -> 1/8, “TieType” -> “NotTied”|>]
}
Using the example below?which shows how the chord and bass parts of the first measure have been converted to the Wolfram Language?please convert measures 2 through 4 into the Wolfram Language.
Conversion of the chord part in the first measure
{
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 3/8, “TieType” -> “NotTied”|>],
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 1/8, “TieType” -> “TiedAfter”|>],
MusicChord[{“E4”, “C#4”, “A3”}, <|”Duration” -> 1/2, “TieType” -> “TiedBefore”|>]
}
Conversion of the bass part in the first measure
{
MusicNote[“A2”, <|”Duration” -> 3/8, “TieType” -> “NotTied”|>],
MusicNote[“A2”, <|”Duration” -> 1/8, “TieType” -> “TiedAfter”|>],
MusicNote[“A2”, <|”Duration” -> 1/4, “TieType” -> “TiedBefore”|>],
MusicNote[“E2”, <|”Duration” -> 1/8, “TieType” -> “NotTied”|>],
MusicNote[“G#2”, <|”Duration” -> 1/8, “TieType” -> “NotTied”|>]
}
As a result, a pitch error was observed in the blue-highlighted section, but all other pitches, note lengths, and ties were accurately output as code.
The corrected code is as follows:
In[]:=
chord={(*1st*)MusicChord[{"E4","C#4","A3"},<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicChord[{"E4","C#4","A3"},<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicChord[{"E4","C#4","A3"},<|"Duration"->1/2,"TieType"->"TiedBefore"|>],(*2nd*)MusicChord[{"E4","C#4","A3"},<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicChord[{"E4","C#4","A3"},<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicChord[{"E4","C#4","A3"},<|"Duration"->1/2,"TieType"->"TiedBefore"|>],(*3rd*)MusicChord[{"F#4","C#4","A3"},<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicChord[{"F#4","C#4","A3"},<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicChord[{"F#4","C#4","A3"},<|"Duration"->1/2,"TieType"->"TiedBefore"|>],(*4th*)MusicChord[{"F#4","C#4","A3"},<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicChord[{"F#4","C#4","A3"},<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicChord[{"F#4","C#4","A3"},<|"Duration"->1/2,"TieType"->"TiedBefore"|>]};
In[]:=
low={(*1st*)MusicNote["A2",<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicNote["A2",<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicNote["A2",<|"Duration"->1/4,"TieType"->"TiedBefore"|>],MusicNote["E2",<|"Duration"->1/8,"TieType"->"NotTied"|>],MusicNote["G#2",<|"Duration"->1/8,"TieType"->"NotTied"|>],(*2nd*)MusicNote["A2",<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicNote["A2",<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicNote["A2",<|"Duration"->1/4,"TieType"->"TiedBefore"|>],MusicNote["A2",<|"Duration"->1/8,"TieType"->"NotTied"|>],MusicNote["G#2",<|"Duration"->1/8,"TieType"->"NotTied"|>],(*3rd*)MusicNote["F#2",<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicNote["F#2",<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicNote["F#2",<|"Duration"->1/4,"TieType"->"TiedBefore"|>],MusicNote["E2",<|"Duration"->1/4,"TieType"->"NotTied"|>],(*4th*)MusicNote["F#2",<|"Duration"->3/8,"TieType"->"NotTied"|>],MusicNote["F#3",<|"Duration"->1/8,"TieType"->"TiedAfter"|>],MusicNote["F#3",<|"Duration"->1/4,"TieType"->"TiedBefore"|>],MusicNote["F#3",<|"Duration"->1/8,"TieType"->"NotTied"|>],MusicNote["E3",<|"Duration"->1/8,"TieType"->"NotTied"|>]};
Let’s set the instrument and tempo and play the sound.
In[]:=
MusicScore[{MusicVoice[chord,<|"Instrument"->"GuitarMuted"|>],MusicVoice[low,<|"Instrument"->"GuitarMuted"|>]},MusicTempo->120]
Out[]=