​

Random Melodies
Play random melodies with various scales and instruments.

Run the code to create a musical note, then click the Play button to hear it. Try note numbers other than 0:
1.

Sound[SoundNote[
0
]]
In[]:=
Play a sequence of notes. Try other sequences:
2.

Sound[{SoundNote[
0
],SoundNote[
2
],SoundNote[
4
]}]
In[]:=
Play the notes faster. Try other durations:
3.

Sound[{SoundNote[
0
],SoundNote[
2
],SoundNote[
4
]},
1
]
In[]:=
Play a random 8-note melody. Try other lengths of melodies:​
Hint: run the code again to get a different melody.
4.

Sound[Table[SoundNote[RandomInteger[12]],{
8
}],2]
In[]:=
Play a random melody from a scale. Try different scales:
5.

Sound[Table[SoundNote[RandomChoice[{
1,3,6,8,10
}]],{8}],2]
In[]:=
Play a random melody on random instruments. Try other instruments, like "Oboe", "Glockenspiel" or "HonkyTonkPiano":​
Hint: you can also specify instruments with numbers from 1 to 128.
6.

​