Sounds in MSX BASIC Part 1
by admin on Mai.23, 2009, under Music Creation, Programming
The MSX Standart was introduced in 1982 and had a lot of sound capabilities. Even the most Basic Machines had an AY-3-8910 Sounchip build-in, which is a common 3-channel PSG. Later MSX machines even had additional, much more powerful soundchips. In Part 1 though, only the BASIC Commands affecting one of the PSG Channels are covered. Polyphony will come with Part 2
BEEP
Syntax: BEEP
The most simple command that makes a tone. Just type “BEEP” into the Interpreter and you will hear the default Beep Sound, generated by the AY-3-8910.
10 BEEP
SET BEEP
Syntax: SET BEEP (type),(volume)
This requires at least an MSX2. Since a single Beep is way too boring, we can change the default beep to something else. There are 4 different kinds of Beeps available from the MSX BASIC. For example, type “SET BEEP 3,4″ to change the default to number 3 and “BEEP” to make a tone afterwards. The Volume can go from 1 to 4.
10 SET BEEP 3,4
20 BEEP
PLAY
Syntax: PLAY “(mml)”
Now its getting more interesting. The MSX BASIC supports MML with many commands available. Although this is still limited to a single channel we can play with different frequencies, the envelope generator, volume and other things.
Supported MML Commands:
- Tx | The Tempo of the Song from 32 – 256. Default is 120
- Ox | The Octave from 1 – 8. Default is 4
- Lx | The Length of a tone from 1 – 64. Higher = Shorter
- C, D, E, F, G, A, B | Our Tones
- +, # | Makes a Note Sharp
- - | Makes a Note Flat
- R | Rest (play nothing)
- Nx | We can also enter notes this way. N0 = Rest, N1 = c-1 … N96 = B-8
- Vx | Volume from 0 – 15, with 15 being the loudest.
- Sx | Envelope Shape, the AY-3-8910 has 10 different Patterns build-in, which look roughly like this:

Mx | “Envelope Period Control”, here we can control how long it takes for the PSG to cycle through one loop of the envelope. You can make a long attack with Envelope #13 or a fast Vibrato-like Envelope with #10 and the corresponding values.
- You can give M values from 1 to 65535. The higher the number the longer does it take to cycle once. To calculate this multiply the value with 143 and you have the time in microseconds.
- There is also X and =, but I did not understand their meaning from the japanese Manual. Lets just add this later.
10 PLAY “O4L4CDEFEDCREFGAGFERCRCRCRCRL8CCDDEEFFL4EDCR”
Mai 27th, 2009 on 09:31
remarks :
for the tones, you can add the lengh of a specific note, for example C4 = L4C
to play a string variable :
M$=”O4L4CDEFEDCREFGAGFERCRCRCRCRL8CCDDEEFFL4EDCR”
PLAY M$
to play a part of a string variable :
M$=”CDEFEDCREFGAGFERCRCRCRCR”
PLAY “O4L4XM$;L8CCDDEEFFL4EDCR”