Close

Sound made easy

A project log for LM80C Color Computer

A Z80 homebrew computer with 32KB SRAM & 32KB ROM, TMS9918A VDP (video) and AY-3-8910 PSG (audio)

Leonardo MilianiLeonardo Miliani 08/19/2019 at 16:170 Comments

After a while (summer holidays) I got my hands on my computer again. This time I added a couple of commands to make the sound management easier. I coded a while and now VOLUME and SOUND are ready to be used.

VOLUME has a very simple sintax and just gets 2 params: the first one is the audio channel, the second one is the volume level. The channel can be an integer in the range 0~4: 1, 2, & 3 point to the corresponding channel (1->A, 2->B, 3->C) while 0 stands for “every channel”,  meaning that it’s like a global setting. The volume level is an integer in the range 0~15, where 0 is for OFF and 15 is for MAX volume level.

SOUND required more work because I had to manage 3 different user params: the channel, the frequency and the duration. The first one is clearly understandable: it chooses the channel used to reproduce the sound. The second one sets the frequency of the tone to be reproduced, in the range 0~4,095. We have to pay attention that this value doesn't represent the real frequency of the tone but it is just an index that has some sort of correlation between its value and the frequency. It gives to users the feeling that higher numbers mean higher tones, the same way of working of some old computers, i.e. my C16 did the same way. The last param sets the duration in hundreds of seconds, and this was possible thanks to the timer I implemented in the firmware using a counter of the Z80 CTC.

The new statements are available in the R2.1 release.

Discussions