Re: Audio IC
Posted: Fri Jul 14, 2023 7:27 am
The only analog audio output I've done on a 6502 was by feeding samples to a D/A converter, on regular intervals from a VIA's T1 time-out IRQ, with no FIFO. My workbench computer runs at 5MHz and I've done up to 140,000 samples per second this way, although because of the jitter I get at 5MHz, there's seldom any reason to go beyond about 24,000 interrupts per second, depending on the application. The processor has no problem keeping up, assuming you don't have a lot of math or other processing to do for each sample. You could still combine sounds at different frequencies and from different wave tables in software numerically controlled oscillators (NCO). Barnacle wrote that brick-wall filtering is hard. The reason for this is that component tolerances have to get really tight compared to what we usually deal with in hobby. I can give you a circuit for a 5th-order low-pass filter though, which although not an 8th-order, achieves the purpose if you stay a little further below the Nyquist frequency, and works well with relatively standard resistors and MLCCs. You can scale the cut-off frequency up and down by dividing or multiplying resistor and/or capacitor values by the proportion you want to move it.
I've done intelligible speech at about 6 or 8ksps and only two or three bits, which was all you got from early talking toys. (This assumes the speech is already compressed into a very narrow dynamic range.) The toys usually did not go to the expense of using an output anti-aliasing filter though, so there were some strange effects which you'll avoid if you do use one. Even for music, I don't think you'll need nearly as many bits per sample as you probably think you do if the music doesn't have the dynamic range of classical music.
The sound quality of high-end audio cassettes, just before CDs took over, was pretty darned good; and you can get almost the same S/N ratio with just 8 bits, and you can get much better frequency response if your sampling rate is up to the job, and much more consistent high-frequency output, and without the flutter. The first time I heard digital audio was at an Audio Engineering Society (AES) convention. Although it sounded really good and mostly really clean, there was something about it that sounded strange, which I figured later must have been because their anti-alias filters were inadequate, and the small amount of intermodulation distortion probably from the speakers acting on the ultrasonic image aliases were producing these artifacts at audible frequencies.
Here are a couple others of my posts that I think will be helpful:
viewtopic.php?p=30252#p30252
viewtopic.php?p=16393#p16393
See also other posts in the same topics. (Wow—I can't believe these are about a decade old already!)
Proxy wrote:
question just is, what's a good sampling rate? (ie speed at which data is loaded into a DAC/SN76489). 44.1kHz would be ideal, but that also means loading 43kB of data every second.
I've done intelligible speech at about 6 or 8ksps and only two or three bits, which was all you got from early talking toys. (This assumes the speech is already compressed into a very narrow dynamic range.) The toys usually did not go to the expense of using an output anti-aliasing filter though, so there were some strange effects which you'll avoid if you do use one. Even for music, I don't think you'll need nearly as many bits per sample as you probably think you do if the music doesn't have the dynamic range of classical music.
The sound quality of high-end audio cassettes, just before CDs took over, was pretty darned good; and you can get almost the same S/N ratio with just 8 bits, and you can get much better frequency response if your sampling rate is up to the job, and much more consistent high-frequency output, and without the flutter. The first time I heard digital audio was at an Audio Engineering Society (AES) convention. Although it sounded really good and mostly really clean, there was something about it that sounded strange, which I figured later must have been because their anti-alias filters were inadequate, and the small amount of intermodulation distortion probably from the speakers acting on the ultrasonic image aliases were producing these artifacts at audible frequencies.
Here are a couple others of my posts that I think will be helpful:
viewtopic.php?p=30252#p30252
viewtopic.php?p=16393#p16393
See also other posts in the same topics. (Wow—I can't believe these are about a decade old already!)