The MSX has a great sound chip that can 'play' three voices at once.
Let's start with the classic command that we often hear in various programs or when an error occurs. Its name is BEEP, that is, by writing the name of this command we reproduce this sound. It is also useful for restoring all changes made with PLAY. Syntax: BEEP
As in the graphic part, also in the musical part the MSX has a small internal language: MML (Music Macro Language) and is used like DRAW, i.e. it has the same characteristics. Musical strings must be enclosed in quotes or can be placed in variables. But before understanding how to do it, below I include the list of all the instructions that can be used within the MML. Like DRAW for graphics, the primary command for starting musical instructions is PLAY. The correct syntax is: PLAY “FIRST VOICE”, “SECOND VOICE”, “THIRD VOICE” or PLAY A$, B$, C$. Voices can be used as desired. Only the first, the first and the third or the second and the third, etc. On the notes we can add the beat time (n), putting a number that will determine the speed of execution of the note. The higher this is, the faster the note will be played. If not used, it is 4 by default, unless specified at the beginning with the L statement that determines the length of the note from that point on.
COMMAND MEANING
C C
D King
And Mi
F Fa
G Sol
In La
B Yes
R Pause
+ or # Sharp
(-) minus Flat
(.) period Extends the life of the 50%
On Octave (n = 1 to 8, default 4)
Ln Duration of the note (n = 1 to 64, default 4)
Tn Rhythm (n = 32 to 255, default 120)
Vn Volume (n = 1 to 15, default 8)
Nn Value of all notes (n = 1 to 96)
Mn Envelope period (n = 1 to 65535, default 255)
Sn Waveform (n = 1 to 15, default 1)
Xvariable$ To insert a variable into the string
Example: PLAY “T120O4L8V13CDEFGABR8T150O5L4V14BAGFEDC”
We have the possibility to know if one of the voices is playing, using the PLAY(N) function, where N can be 1 for the first voice, 2 for the second and 3 for the third, if we use the zero it will check if one of the three voices it's ringing. Example: 100 IF PLAY(0) THEN 100. We told the MSX to stay on that line until it stops playing. There is another way to make the most of the sound chip, but you have to know the various registers well. To modify the various registers we use the SOUND A,B command, where A is the register and B is the data inside it. There are 14 registers and go from 0 to 13, each register is made up of 8 bits and we can vary them by modifying the second entry of the SOUND command, this goes from 0 to 255 in decimal, from 0 to 11111111 in binary and from 0 FF in hexadecimal , but not all of them use the available bits (see table below). To give an example, we want to modify the third bit of register 11 using binary numbers, since it makes us understand better because it shows us what the register really looks like, we will write SOUND 11,&B00000100. I pretended that register 11 was all at 0, so I changed the 3 bits to 1, meaning that the reading is always from right to left. In decimal it would have been: SOUND 11,4 and also in hexadecimal the same thing, adding the suffix, since the first 10 numbers are the same: SOUND 11, &H4. Below I insert a table of all the registers with the correct settings, which you can also refer to in the book MSX – Basic by Albert Sickler.
RO - R1: channel A frequency control LSB 0-255 - MSB 0-15
R2 - R3: B channel frequency control LSB 0-255 - MSB 0-15
R4 - R5: C channel frequency control LSB 0-255 - MSB 0-15
R6: noise frequency control 0-31
R7: mixer and control I/O ports 0-63
R8: channel A volume 0-15
R9: channel B volume 0-15
R10: channel C volume 0-15
R11 - R12: envelope period control LSB 0-255 - MSB 0-255
R13: envelope shape 0-14
And that's it.
Thanks and see you next time


0 Comments