Page 1 of 1

Idea to quickly emulate another sound board

Posted: Sat Dec 19, 2015 6:24 pm
by stefano
Around the 1982 a book called "66 programmi per zx81" proposed a cool way to connect a 555 based oscillator to the ZX81 and get a cheap and simple sound board. The book is available online as well as a re-arrangement of the circuit (the board is now called "Octavia").
I thought at a quick hack to get it emulated: to use the already existing AY emulation and convert the bytes being poked to the sound card to AY registers.
The conversion expression is not very good (can you find a better one?) but the idea looks nice.. feel free to use it into your favorite emulator: here's my code for the SZ81:

if (Address>8191 && Address<16384) {
extern void sound_ay_write(int reg,int val);
/* keep only audio channel 0 */
sound_ay_write(7,254);
/* set volume to zero if "makic key" found to disable audio */
if ((Data & 15) == 15) {sound_ay_write(8,0);}
else {
/* enable the 555 oscillator */
int val=170*Data*Data/7040-39227*Data/3520+1450;
sound_ay_write(8,7); /* raise volume */
sound_ay_write(0,(val)&255);
sound_ay_write(1,(val>>8)&15);
sound_ay_write(6,0);
}
}

..I can provide a (partial) tone conversion table, in case a maths would want to challenge himself

Re: Idea to quickly emulate another sound board

Posted: Sun Dec 20, 2015 9:43 pm
by stefano
Reference to the sound card:

Original book (in good resolution) Sound card is described starting at page 95:
http://www.microatena.it/scheda_libro.php?id=198&ord=N

..there is an error in the sound table in page 100, note #47 should be played by POKEing value 237 rather than 372.

Remake:
http://zx81.ordi5.free.fr/brico/son/index.htm

I understood that every bit in the value has a different "weight" than expected, I'm still trying to decode it in a better way, but few demos sound good already, even if music wouldn't play right.

Re: Idea to quickly emulate another sound board

Posted: Sun Dec 20, 2015 10:02 pm
by 1024MAK
stefano wrote:R..there is an error in the sound table in page 100, note #47 should be played by POKEing value 237 rather than 372.
Yes, 372 does not fit in an 8 bit byte :lol:

Mark

Re: Idea to quickly emulate another sound board

Posted: Mon Dec 21, 2015 2:22 pm
by stefano
This should explain why the current conversion function is not accurate: I provided a simple parabolic conversion while the sigle bits weight differently. Here's the diagram of the right values based on a conversion table. you can see the 4 octaves split in 4 note blocks.

[img=0]octavia-zonx.jpg[/img]

Re: Idea to quickly emulate another sound board

Posted: Tue Dec 22, 2015 3:27 pm
by stefano
Ok, I partially decoded the board logic and got a better simulation of the oscillator. Bit 6 and 7 are octave multipliers, bit 4 and 5 shift the frequency in one of the possible three positions for the 4 notes in the 12 semi-tones scale.
Bit 1..4, inverted, determine the reference frequency for the note and normally are not combined (but for the higer 2 notes).

this code snippets fits into SZ81, in file "zx81.c", just before the line:

Code: Select all

if (Address>8191 && Address<16384 && zx81.shadowROM && zx81.protectROM) return;
Here it is:

Code: Select all

        if (Address>8191 && Address<16384) {
			extern void sound_ay_write(int reg,int val);
			/* keep only audio channel 0 */
			sound_ay_write(7,254);
			/* set volume to zero if "makic key" found to disable audio */
			if ((Data & 15) == 15) {sound_ay_write(8,0);}
			else {
				/* enable the 555 oscillator */
				
				float freq=(60.0 + 5.4*(float)(~Data>>3&1) + 9.4*(float)(~Data>>2&1) + 13.2*(float)(~Data>>1&1) + 22.1*(float)(~Data&1) + 17.5*(float)(Data>>4&1) + 42.1*(float)(Data>>5&1)) * (float)(1<<(Data>>6));

				unsigned int val=(1625000/(16*freq));
				/* raise volume */
				sound_ay_write(8,7);
				sound_ay_write(0,(val)&255);
				sound_ay_write(1,(val>>8)&15);
				sound_ay_write(6,0);
			}
		}

23/12.. edited the expression for freq to make it more suitable for music. Tuning is not perfect but it is close to the results I'd likely get building the circuit myself :lol:

I'm not sure on how to name this board, I like the "Octavia" name but the its original description is probably historically correct: "50 notes music interface" by Gaetano Marano.

Re: Idea to quickly emulate another sound board

Posted: Fri Jan 15, 2016 3:38 pm
by stefano
More sound demos, they integrate the ones already published by XavSnap.
more-sound-Demos.zip
(9.99 KiB) Downloaded 357 times

Re: Idea to quickly emulate another sound board

Posted: Sun Jun 20, 2021 10:21 am
by stefano
I just found this article:

http://www.muzines.co.uk/articles/zx81-sequencer/3220

Similar idea, different implementation. In the article it looks that the valid values to POKE had to be <127. 5 octaves, though!