Small Basic: How to Use Sound.PlayMusic()
This article describes MML (Music Macro Language) in Sound.PlayMusic(MML) operation of Small Basic programming language.
Syntax
(1) Pitch (A, B, C, D, E, F, G)
A ~ G of this command represent the pitch. A = la, B = si, C = do, D = re, E = mi, F = fa, to G = sol. By adding #, + (♯), - (♭) after this command can be expressed a semitone.
(2) Rest (R, P)
Both R and P commands specifie the rest.
(3) Tone length (Ln)
This command specifies the length of the tone. N is the value of 1-64 and reciprocal of the length of the tone which 1 is the max length. Subsequent command after this command is played in the specified same length. When you add n after the tone or the rest, only the tone / rest is played with the length.
ex.
Do of quarter note ...... L4C or C4
Fa of sixteenth note ...... L16F#, F#16 or F+16
Sol ♭ of whole note ...... L1G- or G-1
(4) Octave (On,>,<)
This command specifies the octave. N is an integer from 1-8. In addition, the standard frequency 440Hz, the sound of la (A) is octave 4 (O4). > is for octave up, < is for octave down.
Tips
MML in Small Basic doesn't have Tn command. T is to change Tempo. n is a number of quarter notes per one minite. In Small Basic, n is always aproximately 150.
Sample Programs
Following samples should be run in your local Small Basic IDE (Integrated Development Environment). Because Sound.PlayMusic() operation doesn't work in remote environment (with web browser).
Play MML
http://smallbasic.com/program/?MCP222
Kimigayo
http://smallbasic.com/program/?XQF377
99 Bottles of Beer
http://smallbasic.com/program/?QZZ047
Piano
http://smallbasic.com/program/?ZWF718-1
Chord Wave Form
http://smallbasic.com/program/?JCC750
Measure Tempo of Sound.PlayMusic
http://smallbasic.com/program/?JFM059
Metronome for Sound.PlayMusic
http://smallbasic.com/program/?VPW885
See Also
Other Resources
Following blog article is the first information about MML in Small Basic.
Following blog article shows how to play musical chords in Small Basic.