Page 1 of 2

Looking for sound generation suggestions

Posted: Wed Oct 04, 2006 1:04 am
by Kallikak
Hi,

I thought I'd ask for suggestions about adding sound to my 6502 SBC (a Replica 1). Specifically, I want it to be a fairly minimal board that I could connect to the expansion interface. This is really just to amuse my kids, so it doesn't need to be polyphonic - even just a few notes would do. Maybe the simplest thing would be to use a DTMF chip? But if there is an easy way to build a more general solution, I'd like to do it.

Any and all suggestions and pointers to info is very welcome.

Thanks,

Ken

Posted: Wed Oct 04, 2006 1:20 am
by leeeeee
The simplest is to hang a speaker on a port line much as is done in this diagram ..

http://www.themotionstore.com/leeedavis ... mpf02.html

.. but this costs in software effort to make it do much more than 'beep'.

A more usefull solution is to use one of the sound chips such as the AY-3-89xx series. These have tone and noise sources as well as ADSR envelope generators and can make a wide range of noises with little processor effort. They are also fairly easy to interface to the 6502.

Lee.

Posted: Wed Oct 04, 2006 2:12 am
by GARTHWILSON
From tip #5 at viewtopic.php?t=342 :
Quote:
The 6522's SR can also be used in mode 100 (shift out free-running at T2 rate) to output a 9-level PWM (0 to 8 bits high), which when followed by an RC filter, is suitable for a 9-level D/A. I've used it to generate DTMF. This is slightly better than 3-bit resolution. Some talking toys only use 2-bit resolution!
If you go down to Tip #11, it gives the idea of how to do MIDI (musical instrument digital interface) which you can use with a MIDI-capable musical keyboard if you have one, and Tip #15 suggests using a simple 8-bit parallel D/A converter like the DAC0808 (MC1408) on an output port.

Posted: Wed Oct 04, 2006 1:19 pm
by coredump
I like the suggestion to connect up an AY-3-8910 Programmable Sound Generator. But there are other choices: how about connecting a SID chip from a junked Commodore 64? Or you could use the TI sound chip, the SN76477:

http://www.mkv.mh.se/staff/per/diy/76477/

A similar chip, the SN76489, was used in the BBC Micro:

http://web.inter.nl.net/users/J.Kortink ... /index.htm

Or maybe desolder an OPL-3 sound chip from an old ISA soundcard:

http://www.ucapps.de/mbhp_opl3.html

Or, if you can get one, how about the polyphonic ring-tone generator from a mobile phone? That's what the XGameStation uses, for instance.

Posted: Wed Oct 04, 2006 4:26 pm
by kc5tja
Since none of the chips discussed so far are in regular production, another solution that might interest you is to use an ATmega microcontroller chip.

The microcontroller has an internal SPI port which you can bit-bang with a VIA chip. This would form the communications link between the Apple I and the microcontroller.

The microcontroller also has a VIA-like parallel port, which you can use with a simple R-2R DAC to provide digital audio. Just feed that into a lowish-noise op-amp (741 is OK, but it tends to be noisy) for filtration and isolation, and you should have a reasonable audio generator.

The microcontroller can be programmed to synthesize audio through various waveforms in ROM and, if your adventurous, through downloadable audio waveforms in RAM. In amateur radio designs, the technique used is called "Phase-Accumulator Synthesis," or "Direct Digital Synthesis." The only difference is, instead of IF or RF frequencies, you're scaling it down to audio frequencies.

Posted: Wed Oct 04, 2006 6:42 pm
by Memblers
I've wrote a sound synth that runs on an 18F PIC on my NES cartridge. Pretty much how kc5tja is saying.

I've got waveforms in RAM (which can be gradually modified to do SID-like effects such as pulse-width modulation, or pre-set to any kind of waveform). Use fixed-point to get the sound frequency (resampling), multiply the wave sample by a volume setting to scale volume control, then I do that 4 times (for 4 channels polyphony) and add it together, shift it to fit the DAC's bit-range, and there it is. And doing it 22,050 times per second. Really fun stuff.

Wrote a random # generator to make noise output, that works too.

You can do all this on the 6502 itself too of course, just need something like an IRQ coming at a constant rate so you get a steady sample rate. Get IRQ, write previous sample, calculate next one, RTI. Using a PIC in my setup I get to skip the (pretty intensive) calculate sample part. :)

Posted: Mon Oct 09, 2006 1:55 am
by Kallikak
Thanks for the many and varied suggestions!

Ken

Posted: Sun Mar 18, 2007 10:32 pm
by nineTENdo
Im Pursing this my self and found some good books on it. "Musical Appllications of Microprocessors" by Hal Camberlin has an enourmous about of information for the 6502. Wave Look Up Tables, Digital Sound Generation, Midi Keyboards with Midi Interfaces and there respective Chips to them, and even DSP (FFT and Such). I bought this book awhile back before i started working the 6502 and later looked back to find a cove of useful information. "Programming the 6502 with Experiments" by Blacksburg Contining Education Series, has a few cool little tricks on D/A Convertion for making Tones with OP AMps for generating chords and w/ formulas for implemating a F# in Hex and Such. Its worth a look.

Re: Looking for sound generation suggestions

Posted: Mon Mar 19, 2007 9:44 pm
by TMorita
Kallikak wrote:
Hi,

I thought I'd ask for suggestions about adding sound to my 6502 SBC (a Replica 1). Specifically, I want it to be a fairly minimal board that I could connect to the expansion interface. This is really just to amuse my kids, so it doesn't need to be polyphonic - even just a few notes would do. Maybe the simplest thing would be to use a DTMF chip? But if there is an easy way to build a more general solution, I'd like to do it.

Any and all suggestions and pointers to info is very welcome.

Thanks,

Ken
If you want a simple interface, just use a single bit output port connected to an LM386 or Rat Shack pocket amplifier, then use a software timing loop to tweak the output bit.

Toshi

Posted: Thu Apr 12, 2007 7:18 pm
by Nightmaretony
ninTENdo, will have to get in that book. a later project involves a dsound synthesizer planned from a wave table architecture to an FPGA. (it had some other tricks I dont want to divulge just yet, but it involves throwing everything together in a huge pile of data :D

Cheap and easy is still an 8 bit D/A port and send out sound samples or waveforms. Gottlieb pinball boards used this architecture.

The SN76477 and SN76489 were NOT the same architectgure or even remotely related. The 76477 used discrete analog sound units within and oyu set with RC components. Very limited chip. The 76489 used simple tone generators and has much more in common with the AY3-8910/12/13 series and SID chips.

The OPL FM series can be a little pain and seem this kind of obsolete these days. Sound was thin, just check out the DX7 sometime.

Wavetables I like, from the Ensoniq Mirage series and Apple ][ GS sound system, also used in the ESQ-1.

Later systems loved using a DSP with a D/A output.

Posted: Fri Apr 13, 2007 12:56 am
by kc5tja
Agreed. TMorita's suggestion of constructing a 1-bit DAC is doable, but it requires MASSIVE CPU bandwidth. That's not something 6502s are known for.

For only 20 cents more, you can use 16 resistors (arranged as an R-2R ladder) on an 8-bit port, and you'll have the equivalent of one quarter of a Paula. ;) Get four of those going together, and you'll be able to match the Amiga's Paula chip capabilities. Most microcontrollers are powerful enough these days to handle limited audio mixing too, so you can perhaps simulate multiple voices (suppose 3 8-bit ports, and enough RAM to store 3 look-up tables; if you need 9 voices, you can assign 3 voices to the same wavetable).

Posted: Fri Apr 13, 2007 11:18 pm
by RichCini
leeeeee wrote:
The simplest is to hang a speaker on a port line much as is done in this diagram ..

http://www.themotionstore.com/leeedavis ... mpf02.html

.. but this costs in software effort to make it do much more than 'beep'.

A more usefull solution is to use one of the sound chips such as the AY-3-89xx series. These have tone and noise sources as well as ADSR envelope generators and can make a wide range of noises with little processor effort. They are also fairly easy to interface to the 6502.

Lee.
I like the AY389xx suggestion too. I pulled a copy of the data sheet that I have and it doesn't have an application circuit section. I was able to find a real simple schematic (for the 8080) and one in SYM-PHSIS #7. In that issue the schematic is actually textual rather than drawn and it includes code. The 8080-based one is connected directly to the CPU bus and the SYM version is connected to a VIA. Why that additional layer is needed I don't know - the 8910 should work well with a direct connection.

Posted: Mon Apr 23, 2007 10:38 pm
by Nightmaretony
If you go for the AY3-89XX series, look for old Apple 2 code for the Mockingboard which used those...

Posted: Sun Apr 29, 2007 12:51 pm
by smilingphoenix
I like the AY-3-891x chips. They can be connected directly to the 6502 bus at clock speeds of 2MHz, they might work OK at faster speeds but my data sheet doesn't have the timing data :( Only problem is, I havn't been able to locate a source for them recently.

If you are using the original datasheets, take care. All the programming data, for some weird reason, is in octal instead of hex. This can be very confusing for the unaware. (eg me)

Posted: Sun Apr 29, 2007 1:00 pm
by RichCini
smilingphoenix wrote:
I like the AY-3-891x chips. They can be connected directly to the 6502 bus at clock speeds of 2MHz, they might work OK at faster speeds but my data sheet doesn't have the timing data :( Only problem is, I havn't been able to locate a source for them recently.

If you are using the original datasheets, take care. All the programming data, for some weird reason, is in octal instead of hex. This can be very confusing for the unaware. (eg me)
I just bought two from a guy on eBay who is in Florida. He had them for $15 each with free shipping. I bought two of the 315 he had.

Search for userid "honestcard" or "ay38910".