A sound synthesiser for retro computing. - Page 1
Forum section: electronics / projects

author: GK
author_rank: Super Contributor
timestamp: May 29, 2017, 10:31:16 am
content: I'm designing a retro video games console. The video graphics capabilities will be somewhere between that of a Commodore VIC20 and 64, but with vastly superior 6-bit colour and colour bit-mapping.All of the video and sound synth functions are being realised in generic, current production logic chips (74AC, 74HC, etc) - not a single NOS, out of production or otherwise specialized part.I was originally going to lay the whole thing out on one large motherboard (with a "cartridge" slot for plug-in software), but, after finalizing the sound syth circuitry, decided that that part is worth presenting as a separate design, so the project is now modular.What I've replicated (albeit on steroids) in 74HC logic is the internal function of the obsolete SN76489 sound synth chip as used in many past arcade games machines and home computers (my BBC micro included).This chip has three programmable-freq. tone generators and one programmable-freq. noise generator, giving 4 sound channels in total, equipped with independent amplitude control. The block diagram of this chip is attached below.The '76489s programmable (/n) dividers for setting the tone generator frequencies are 10-bit and the part was typically clocked at either 4MHz (the max. specified clock freq.) or close to it (for example the NTSC chroma carrier freq.). With the internal fixed clock division of 16 and the post-programmable-divider division of 2 (to give a square wave output), those 10-bits would get you down to 122 Hz minimum-freq. with a 4MHz clock. For music synthesis proper the part was generally used up to about 5kHz maximum as much above that the programmable frequency steps become quite chunky.In my replication I've quadrupled the master clock frequency and have increased the bit-depth of the programmable frequency-setting dividers from 10 to 15. These measures simultaneously improve (significantly) the high-frequency step resolution and shift the lowest output frequency down into the subsonic.My programmable dividers each consist of four cascaded 4-bit 74HC193 up/down counters wired to count down only. The programmable frequency-setting word ("n") is parallel-loaded at the terminal count. Because the terminal count includes count zero, the dividers divide the master clock by n+1. I've attached a spreadsheet giving computed values for n in HEX for each note in the A4 musical scale, extending from C sub-contra-octave (the lowest note on a 101-key piano) all the way up to 20 kHz in 12 semitone steps. The frequency error is also computed/tabulated and shown to be quite negligible.For the noise generator channel I've provided 3 control bits giving 8 frequency-setting options. 0-to-6 step the clock input to the 16-bit maximal-count pseudo-random-bit-generator from 15625 Hz to 244Hz in octave steps. A setting of 0 results in a "white"-like high frequency noise akin to an off-tuned radio, whilst 6 gives a low frequency rumble. The last programmable setting, 7, connects the noise generator clock input to the frequency output of the third tone generator.The most important parts of the synth though are the programmable attenuators, as the programming of these is how modulation envelopes are generated. I've replicated the '76489 function here, with four control bits and thus 16 discrete amplitude settings each attenuator, ranging from 0dB attenuation for step 0, to -28dB for step 14, in -2dB steps. Step 15 is off, or infinite attenuation.To realise the logarithmic volume-control function for each individual voice the four binary control lines are 1-of-16 decoded by a 'HC4514 to then, by means of a simple diode matrix, select 1-of-16 positions of an 8-bit multiplying DAC. The attenuator circuity is duplicated for each voice and the outputs of all are mixed together to give a single, composite audio output.Programming is very simple. All of the required data is stored in a total of eight 8-bit registers; communication is thus via an 8-bit (byte-wide) data bus and a 3-bit address bus. There is a single control line, "!WR", strobed low to write the applied byte to the selected address.The first six byte-wide registers, a0-a5, are best considered 16-bit pairs; 0&1, 2&3, 4&5. The fifteen LSBs of 0&1 hold frequency-setting value "n" for tone-generator "voice" 1. 2&3 similarly hold "n" for tone-generator "voice" 2 and 4&5 for tone-generator "voice" 3. The remaining three MSBs of these 16-bit registers are the three control lines for the noise channel, "voice" 4. The control line MSB being the MSB of 4&5.The final two registers, 6 and 7, hold the four amplitude-control nibbles. The least-significant nibble of register 6 sets the amplitude of voice 1, the most-significant nibble sets voice 2. The least-significant nibble of register 7 sets the amplitude of voice 3 and the most-significant the amplitude of voice 4, the noise channel.Dunno what kind of interest there might be out there for this kind of project. IMO it would be pretty cool companion synth for a retro computer project, which seem to be quite popular around here and elsewhere. It's all going to layed out in a single board in SMD; SOIC for the logic, SOT-23 and 1206 for most of the rest. Should have the Gerber files to post in a week or two (have another project on the bench to finish off in the meanwhile).The SN76489:This circuit duplicated for the other three voices:A4 frequency table:

author: chris_leyson
author_rank: Super Contributor
timestamp: May 29, 2017, 11:44:15 am
content: Cool project. A long time ago I had a few Cinematonics arcade games running on a Spartan 3 FPGA, the 12-bit processor was the easy bit but each game had a custom sound generator board. Anyway I thought it might be easier to replicate something like an SN76489 in VHDL and emulate each sound generator board. Seemed like a good idea but I still had to reverse engineer each custom sound generator board and that was when I gave up. I might have a go at a VHDL SN76489 or AY-3-8910 one day because retro sound effects are cool.

author: danadak
author_rank: Super Contributor
timestamp: May 29, 2017, 01:59:25 pm
content: In early 870's I built music synthesizers based on DTL and some TTL, favorite was74192, 193 up/dwn counters. Lots of fun generating harmonic rich sounds. Pro-grammed by patch panel.Take a look at Cypress PSOC as well for future designs. It has digital filter, counters,PWM, Wavedac for generating sine, tri, ramp, square, and custom, lots of HW stuffwrapped around an arm core.A further note, I think it would be capable of simulating multiple 76489's, can beprogrammed in Verilog, has the DACs.......For me what stands out is -1) Routability2) Fast 12 bit SAR A/D and slow 20 bit DelSig3) DFB (Digital Filter Block) that is dual channel, handle FIR or IIR filters, or DFBcan be used as a GP fast processor block, similar to RISC block4) MSI logic elements GUI based and/or the UDB Verilog capability. Eg. the FPGAlike capability5) Onboard Vref6) IDAC, VDAC, OpAmps (up to 4), comparator, mixer, switch cap, analog mux....7) LCD, COM, UART, I2C, I2S, One Wire, SPI, Parallel, LIN, CAN, BLE, USB9) Custom components capability, create with schematic capture or Verilog10) DMA to offload processes like filters, COM, Display11) ARM M0 (PSOC 4) or M3 (PSOC 5LP) or 8051 core(PSOC 3)12) Extensive clock generation capabilities13) All components supported by extensive prewritten APIshttps://www.element14.com/community/thread/23736/l/100-projects-in-100-days?displayFullThread=truehttp://www.cypress.com/documentation/code-examples/psoc-345-code-examplesGreat video libraryAttached component list. A component is an on chip HW resource.Free GUI design tool with schematic capture, "Creator". Components have rich API library attachedto each component. Compilers free as well.PSOC 4 is low end of family, consider 5LP parts as well. PSOC 4 also has arduino footprint boards (pioneer) as wellhttps://www.elektormagazine.com/labs/robot-build-with-cypress-psochttp://www.cypress.com/products/32-bit-arm-cortex-m-psocRegards, Dana.

author: Jr460
author_rank: Regular Contributor
timestamp: May 29, 2017, 02:54:39 pm
content: Interesting.Maybe I missed it, any programable filtering?Also can you express the frequency error in cents rather than percent?

author: Fungus
author_rank: Super Contributor
timestamp: May 29, 2017, 04:06:46 pm
content: Quote from: Jr460 on May 29, 2017, 02:54:39 pmThose chips didn't have it. It was just square waves and two types of noise (white and periodic).I think the only chip from that era with a filter was the C64's SID.

author: stj
author_rank: Super Contributor
timestamp: May 29, 2017, 04:51:49 pm
content: to clarify something, most arcade games used those chips in multiples.you wont get really good effects with only one.konami games often used 3 or even 4 ay8910's - now that produced some really good sound!!

author: Fungus
author_rank: Super Contributor
timestamp: May 29, 2017, 05:13:12 pm
content: Quote from: stj on May 29, 2017, 04:51:49 pmYep, one chip per sound channel was the norm. That was why arcade machines sounded better than home computers.Quote from: stj on May 29, 2017, 04:51:49 pmI invented a way to do ring modulation on an AY8910. You can hear it on one of my games here (eg. when the guy appears at game start and in various other places):I haven't ever heard anybody else do that with one of those chips. :-)

author: stj
author_rank: Super Contributor
timestamp: May 29, 2017, 05:34:33 pm
content: never heard of it, i thought it needed specialised chips from yamaha!

author: Fungus
author_rank: Super Contributor
timestamp: May 29, 2017, 06:41:39 pm
content: Quote from: stj on May 29, 2017, 05:34:33 pmIt's using a single AY-3-8910 chip (on a MSX computer in that video).

author: james_s
author_rank: Super Contributor
timestamp: May 29, 2017, 11:14:44 pm
content: Quote from: chris_leyson on May 29, 2017, 11:44:15 amThe AY-3-8910 has already been implemented in VHDL, I think the SN76489 has too.Do you still have the VHDL for the Cinematronics CPU? I've been working with the Asteroids code that came from fpgaarcade, I've got it driving a custom 5" CRT vector monitor, plays perfectly just like the original.

author: GK
author_rank: Super Contributor
timestamp: May 30, 2017, 01:49:57 am
content: Quote from: Jr460 on May 29, 2017, 02:54:39 pmNo, there isn't any filtering. 1 cent, being the 1200th root of 2, is equal to a frequency shift of 0.058%. So just divide the shown error % by 0.058 to convert to error in cents. For most of the musical scale the error for each note is less than 1 cent.

author: GK
author_rank: Super Contributor
timestamp: May 30, 2017, 02:00:43 am
content: Quote from: FungusPeriodic "noise" for the SN76489 was just a low duty cycle rectangular wave. The XOR feedback for the shift register was bypassed so that just a single set bit was continuously rotated; so technically, not really noise.I've omitted the periodic setting in favour of having 8 frequency setting options for the noise generator rather than only 4.

author: ebastler
author_rank: Super Contributor
timestamp: May 30, 2017, 04:37:50 am
content: Quote from: james_s on May 29, 2017, 11:14:44 pmYes:https://github.com/ddle/verification-sn76489/tree/master/sn76489-1.0

author: tombi
author_rank: Regular Contributor
timestamp: May 30, 2017, 04:39:55 am
content: Hello,If you are willing to go a bit beyond the chip you are emulating, the C64 I recall had the capability to set attack/decay rates which was pretty handy for turning white noise into drums or explosions etc. This might be a nice feature to add.Another cool project!Tom

author: GK
author_rank: Super Contributor
timestamp: May 30, 2017, 08:51:53 am
content: Adding ADSR control to the design would probably quadruple the complexity or more. All those things can still be done with design here though under uP control, just by timed stepping of the attenuator settings. This, for example, is how the BASIC command "Envelope" worked on the BBC Micro (which used the SN76489 for sound).

author: Fungus
author_rank: Super Contributor
timestamp: May 30, 2017, 10:12:13 am
content: Quote from: tombi on May 30, 2017, 04:39:55 amAll that can be done in software.

author: chris_leyson
author_rank: Super Contributor
timestamp: May 30, 2017, 11:26:52 am
content: QuoteHi James_s, somewhere I've got archived versions for the 12-bit processor. The vector hardware was done in VHDL as a pair of digital integrators and the output was 12-bit SPI to drive a pair of DACs. Can't remember if the integrators were linear or exponential approximation.At the time I noticed that there were quite a few people working on VHDL implementations but none of them worked and my gut feeling was that they were second guessing too many things. I used a simulation approach writing descriptions for each chip using typical propagation delays and once I had got all of the bugs and mistakes fixed I had working model albeit very slow. Next step was to tweak the model for synthesis rather than simulation and then add the integrators and SPI drivers. Got Rip Off running on a TEK 465 but the small CRT didn't do it justice, Speed Freak was much better on a small CRT and I even managed to emulate the sound generators.Will try to dig out the archived HDL next week.

author: Fungus
author_rank: Super Contributor
timestamp: May 30, 2017, 11:32:55 am
content: Can we fix the bug in the AY-3-8910?Those chips generate square wave timings with an internal counter that counts up towards a target value (in the frequency registers). When it reaches the target it flips the output pin and resets.If you change the frequency registers downwards the counter will overshoot and wrap around. This causes nasty clicks when you're trying to sweep the frequency, do vibrato, etc.It would be good to fix that.

author: dentaku
author_rank: Frequent Contributor
timestamp: May 30, 2017, 11:42:58 am
content: That's great stuff. I like seeing projects like this.I currently have an SN76477N on a breadboard sitting on my desk. It's really basic

author: schmitt trigger
author_rank: Super Contributor
timestamp: May 30, 2017, 01:13:30 pm
content: A long time ago, late 70s or early 80s, I can't recall, I read about the SN76477 in one of the electronics hobby magazines, and I immediately ordered one.I built a demo board full of switches and potentiometers over a few weekends.Then I played with it endlessly, it was so much fun, to the annoyance of my new wife.I also hooked up a two channel scope, and watching how the LFO would modulate or shape the main carrier was a great learning experience.I even kept a notebook where I would write down the settings of interesting sounds, and would give those sounds humorous names: I.e, Darth Vader burps.Unfortunately I threw it away, along many of my early projects, when the family started to grow and we had to move to other homes.

author: james_s
author_rank: Super Contributor
timestamp: May 30, 2017, 07:14:00 pm
content: Quote from: chris_leyson on May 30, 2017, 11:26:52 amI'd love to have a play with that. I used a triple VGA DAC for my Asteroids project, got Asteroids and Asteroids Deluxe running but I still need to implement some of the sounds for the original Asteroids. I got stuck trying to get Lunar Lander to work, the hardware is extremely similar but for some reason I just could not make it run, I got burned out and had to set it aside for a while.The guy who was working on this with me designed an all in one deflection/HV board to turn a larger TV tube into a vector monitor, he also pioneered re-winding the vertical deflection coil to convert a raster yoke from a cheap portable TV into a vector yoke. One of these days I'll build a miniature cabinet for my 5" Asteroids.

author: GK
author_rank: Super Contributor
timestamp: June 05, 2017, 10:03:00 am
content: Just need to tidy the silk screen up now. I've made a few circuit improvements too, including a power-on-reset/sequence circuit which, upon the application of power, presets the amplitude (volume) control registers to FF, FF, which turns off the audio on all four voices. This will prevent any unpleasant noises until the remote controlling device (whatever it may be) boots.Out of paranoia, before sending the board off for manufacture, I've bread-boarded the PRB (noise) generator. Sounds funky with a ramping-frequency clock source starting at 20 Hz; like a rocket launching.

author: GK
author_rank: Super Contributor
timestamp: June 06, 2017, 01:22:43 pm
content: OK, I've double, triple and quadruple checked the schematics and PCB layout.A multi-page PDF the complete schematic set:https://www.eevblog.com/forum/projects/sound-synthesiser-for-retro-computing/?action=dlattach;attach=321789The PCB layers:https://www.eevblog.com/forum/projects/sound-synthesiser-for-retro-computing/?action=dlattach;attach=321790I can get 5 boards delivered for $109 AUD (PCB Way), which is the cheapest I've found yet. OHS-park at $5USD per square inch is hardly economical for anything bigger than a eurocard.That's four more boards than what I need. Probably not, but anyone else want to build a 74HC sound synth?