Adding Sound Generation

For discussing the 65xx hardware itself or electronics projects.
User avatar
Alarm Siren
Posts: 363
Joined: 25 Oct 2016

Adding Sound Generation

Post by Alarm Siren »

So, I've been looking at how I might add sound generation hardware to my computer.

The options I've found thus far:
  • The TI SN76489, as used in the BBC Micro - No longer manufactured and I don't like the idea of scrounging for used parts. Also probably not 3.3V compatible from what I can tell.
  • One of the Yamaha YMxxxx / OPLx synthesizer chips, as used in the Adlib and some Sega machines - Ditto to the TI chips.
  • Program up a modern microcontroller to act as a sound chip - complex to implement and feels like cheating
  • The VIA Serial port based sound generation used by the VIC-20 and pnoyes' Dodo - Works well enough, but I was hoping for more than one voice, and it ties up the Serial port which I intended to use as an I/O expansion port.
Does anyone have any comments or ideas? I'm a bit stuck...

I'm terms of available interfaces, I've got SPI ports, a 10-pin GPIO port and the VIA Serial broken out along with an aux/direction pin. Direct interfacing to the processor bus is possible but problematic.
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Adding Sound Generation

Post by BigEd »

Might be worth considering the brilliant and surprisingly simple approach of the Music 5000?
viewtopic.php?f=4&t=4436
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Adding Sound Generation

Post by BigEd »

Or, look into BeebOPL which is one of a short series of modern OPL designs as an 8 bit peripheral for the BBC Micro:
http://stardot.org.uk/forums/viewtopic.php?t=11434
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Adding Sound Generation

Post by GARTHWILSON »

All the audio signal handling I've done has been with the processor babysitting it sample by sample (usually tens of thousands of times per second, governed by a VIA timer generating interrupts); however:
Alarm Siren wrote:
[In] terms of available interfaces, I've got SPI ports,
I can't take the time to find you any part numbers right now, but I know there are signal-generator ICs with SPI.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
commodorejohn
Posts: 299
Joined: 21 Jan 2016
Location: Placerville, CA
Contact:

Re: Adding Sound Generation

Post by commodorejohn »

Alarm Siren wrote:
  • The TI SN76489, as used in the BBC Micro - No longer manufactured and I don't like the idea of scrounging for used parts. Also probably not 3.3V compatible from what I can tell.
  • One of the Yamaha YMxxxx / OPLx synthesizer chips, as used in the Adlib and some Sega machines - Ditto to the TI chips.
This is gonna be true of pretty much any sound generator that isn't either an industry-standard PC solution (i.e. AC97) or a bare-bones DAC or square-wave generator, so I wouldn't let that constrain you too much. I'd lean towards a Yamaha FM chip, as that gets you a pretty good return on investment as far as sound quality/flexibility vs. CPU horsepower goes (although the OPLx chips do have an annoying requirement for delays after writes, but still.) Rolling up your own sound generator on a microcontroller is also a fun idea, although it can be a bit of a project in itself.
User avatar
Alarm Siren
Posts: 363
Joined: 25 Oct 2016

Re: Adding Sound Generation

Post by Alarm Siren »

commodorejohn wrote:
Rolling up your own sound generator on a microcontroller is also a fun idea, although it can be a bit of a project in itself.
I'm increasingly coming to the conclusion that that's the best way forward. It just feels so... dirty. "I want my retro computer to have decent sound capabilities. So I'm going to put on another, much more powerful computer to act as a sound card... wait what?"
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
User avatar
commodorejohn
Posts: 299
Joined: 21 Jan 2016
Location: Placerville, CA
Contact:

Re: Adding Sound Generation

Post by commodorejohn »

Yeah, I get that. On the other hand, you can think of it less as another computer and more as (effectively) a fixed-function large-scale integrated circuit, which is what other sound generators are. What kind of sound generator are you thinking of trying to create? If you're interested in FM, it's actually surprisingly easy to do - I can point you to some documentation on the internals of the DK Synergy, which manages 32 sine-wave operators configured in an arbitrary fashion using only phase accumulators and a lookup table, implemented entirely in TTL logic. (Doesn't even require a multiplier for level attenuation - it's absolutely freaking brilliant.)
Cray Ze
Posts: 134
Joined: 02 May 2015

Re: Adding Sound Generation

Post by Cray Ze »

It might be worth a look at the FTDI FT801, just for it's audio sub section.

http://www.ftdichip.com/Products/ICs/FT801.html
http://www.ftdichip.com/Support/Documen ... _FT801.pdf
User avatar
GaBuZoMeu
Posts: 660
Joined: 01 Mar 2017
Location: North-Germany

Re: Adding Sound Generation

Post by GaBuZoMeu »

You may also take a look at the 82C54 (intersil and others), an old style "CTC". There are 3 16bit counters with seperate clock in- and outputs. Not yet a soundchip but perhaps a part of it. I imagine that two of them and some glue logic (and software of course) could generate a lot of "noise" :D.

The 82C54 is still available (Mouser, Digikey..). Similar is the Z80-CTC (perhaps Digikey) or Motorola 6840 (obsolete).

Sorry, only parallel input (8 bit bus), no SPI :(
User avatar
Alarm Siren
Posts: 363
Joined: 25 Oct 2016

Re: Adding Sound Generation

Post by Alarm Siren »

The 82C54 looks very promising, based on my best understanding of the datasheet.

Basically, wire up the master clock (2MHz) to the clock inputs of each of the three counters. Load the 16-bit counters with N = CLK/F, where N is the counter value, CLK is the master clock and F is the desired frequency. Set the counters to Mode 3.

Now, the output pin of the counter will be a 50% duty cycle square wave of the frequency F until it is changed. Optionally stick an RC filter on the output(s) to turn them into sine waves and then feed them into a combining op-amp structure, and voila, 3-voice sound. The range of possible frequencies is between approximately 30.5Hz at N=65535 to 2MHz at N=1, easily encompassing the human hearing range, and getting progressively more accurate the closer we approach the lower end.

For example, middle C has a frequency of approximately 261.626Hz...
N = 2000000/261.626 => therefore N = 7644.5.
Round up to 7645.
Check....
F = 1/(N/2000000) => therefore F = 261.608Hz, a margin of error of 0.00007%.

Main down side: no ability to vary the duty cycle (and thus relative volume) of the channels.
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
User avatar
GaBuZoMeu
Posts: 660
Joined: 01 Mar 2017
Location: North-Germany

Re: Adding Sound Generation

Post by GaBuZoMeu »

Yes, this way it can go :D

FYI: it is not necessary to try to get sine waves - they sound pretty dull. A 50:50 square wave has lots of overtones (3., 5., 7.,... harmonics) that makes it sounds brighter. And perhaps you should try (if possible, I know it works for the 6840, but I didn't go deep into the 8254) variable duty cycle 10:90 or modulated (every few 10th of a second changed) from 10:90 .. 50:50. The smaller the duty cycle the brighter the sound (more overtones). But sadly the volume will change a bit. Thats a huge playfield. Have fun :D
User avatar
Alarm Siren
Posts: 363
Joined: 25 Oct 2016

Re: Adding Sound Generation

Post by Alarm Siren »

Pretty sure its not possible to vary the duty cycle using the 82C54, unfortunately.
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
User avatar
GaBuZoMeu
Posts: 660
Joined: 01 Mar 2017
Location: North-Germany

Re: Adding Sound Generation

Post by GaBuZoMeu »

Yes - sadly. To do so you would need twice as many PITs to combine them, still little pleasure. Well, in this case the 6840 could serve you better, but it is obsolete and AFAIK only for bus frequencies up to 2 MHz (68B40) suitable.

But you may try by software using any free port pin you may have to generate a signal with a selectable or slowly varying DC and listen. Perhaps the effect is less prominent as it looks (viewing at the FFT). Perhaps it is sufficient to have 50:50 and 25:75 available for mixing.

Perhaps you take a look at the Chorosynth http://www.appleii-box.de/S15_Synthisiz ... ynth00.htm. It is using three 555 timers and neat mixing to generate interseting sounds. Instead of the 555s a PIT should work well.

edit(1): you need to program the PITs output frequencies with a slight difference to get the chorus effect. Perhaps two instead of three timers for the base frequency are sufficient, or you just use two PITs :D
User avatar
GaBuZoMeu
Posts: 660
Joined: 01 Mar 2017
Location: North-Germany

Re: Adding Sound Generation

Post by GaBuZoMeu »

A perhaps a bit too sophisticated (audio specs!) way to control the volume & panning: LM1973. It has a moderate price and can volume control 3 signals. Drawback: only SMD :|
User avatar
Alarm Siren
Posts: 363
Joined: 25 Oct 2016

Re: Adding Sound Generation

Post by Alarm Siren »

How does this look to people?

I'm particularly unsure about my maths with regard to the 22k resistors, especially given I've thrown in that 10k pot for volume control.

Op-amps was always one my weakest subjects...

I have also never been able to find a straight answer with regards to what voltage a headphone output actually should be, peak to peak. Best I can work out? Somewhere between 0.5V and 1.5V depending on how fancy the audio equipment is - fancier equipment outputting higher voltages.
Attachments
82C54-based Sound Synth circuit schematic, revision 1.
82C54-based Sound Synth circuit schematic, revision 1.
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
Post Reply