PLAY is a statement that plays music.
- Syntax: PLAY commandstring
- The commandstring can consist of the following commands:
- On - Sets the current octave (n can be between 0 to 6), example "O3"
- Nn - Plays the note n (n can be between 0 to 84, where 0 is a rest), example "N42"
- < - Down one octave (cannot get below 0).
- > - Up one octave (cannot get above 6).
- A, B, C, D, E, F or G - Play A-G in the current octave, you can use + or # for sharp and - for flat, example "C#"
- Ln - Sets length of a note (n can be 1 to 64 where 1 is a whole note and 4 is a quarter of a note etc.), example "L4"
- Tn - Sets quarter of notes per minute (n can be 32 to 255 where 120 is the default), example "T180"
- MS - Each note plays 3/4 of length (staccato)
- MN - Each note plays full length (normal)
- ML - Each note plays 7/8 of length (legato)
- Pn - Pause in the duration of n quarternotes (n can be 1 to 64), example "P32"
- MF - Play music in the foreground (each note must be completed before the other can start).
- MB - Play music in the background (the background buffer can only hold 32 notes in QuickBASIC, QB64 have no limits)
- X + VARPTR$(string-expression) - execute another command string.
Example: PLAY "c3 l16 a+ b- cdl8efl4gl16 p32 deggdel4gp1614c-p16l8cecdel4dl10c"
Explanation: (explained parts are shown in bold and separated from the rest)
"c3" means the same as "l3 c", setting the length to one third of a whole note.
a+ means A sharp (or a# which you can also use).
b- means B flat.
p32 means to pause 32 quarternotes.
You can use spaces in the string for clarity without affecting anything.