6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 28, 2024 4:07 pm

All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Audio IC
PostPosted: Fri Jul 14, 2023 7:27 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8444
Location: Southern California
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.

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!)

_________________
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Fri Jul 14, 2023 4:43 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 694
Location: Potsdam, DE
GARTHWILSON wrote:
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.


Aliasing occurs when a signal of higher frequency than the Nyquist limit remains present on the signal being sampled. The practical effect is that it is reflected into the frequency below the Nyquist limit: for example, if you're sampling an 11kHz signal at 10kHz, the alias frequency is at 9kHz and as that frequency increase, the alias frequency drops. But the filtering reduces its level as it gets further above the Nyquist limit so you mostly hear aliases close to the limit. And of course, once they're sampled, they're there for good; there is absolutely no way to remove them.

So it's possible to get ultrasonic aliases - and you're most likely to get them there because of the limitations of practical filters - but most people aren't going to hear them, unless the amplifiers/speakers are really bad.

Interestingly; that's how software defined radio works: an RF signal is sampled at a rate _way_ too low to meet Nyquist, deliberately introducing aliases in defined bands, one of which can be isolated for further processing.

Neil


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Fri Jul 14, 2023 7:52 pm 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 104
Location: Long Island, NY
AndrewP wrote:
I'm going this route too but I'm putting the DAC behind a pair of 74HCT40105 16x4bit FIFOs (in parallel for 8bits). I then use a 32KHz clock divided-by-two to tick 8bits out of the FIFOs into the DAC at 16KHz.


I too have a "FIFO" though it's only one byte :P

I have a bit less to worry about with timing though since I dedicate a second 6502 to producing samples. The interrupts are produced by a 40103 clocked at 1/4th the rate of the audio processor clock. At the slowest setting it has 1024 cycles to produce samples at 13.6kHz.


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Wed Sep 20, 2023 1:40 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 707
Location: Texas
Agumander wrote:
How much of the lifting do you want it to do for audio? I just use a TLC7524 DAC and compute samples directly on a 6502


gfoot wrote:
If you have a VGA-capable video circuit then that is outputting about 30,000 scanlines per second - you could piggyback on that to grab one or two bytes during each blanking period for audio output. It's kind of life a free FIFO - the CPU can populate those bytes ahead of time once per frame and not have to worry about timing as much as the video circuit will then send them to the sound hardware at the right rate.


I read through the entire topic and, besides being very confused about definitions and other particulars, I didn't see a one-size-fits-all answer. I like the two ideas above though. I went through the TLC7524 datasheet and, well, I don't even know where to start with DACs it seems. They recommend op-amps connected to it, etc etc. Couldn't someone create their own DAC with a latch and some resistors? I feel like I do the same thing with my video circuits, but I'm just so unfamiliar with audio basics.

Any recommended resources for me to get a rough idea of where to start? I just watched George's videos on a similar topic, one of which is here: https://www.youtube.com/watch?v=iFAMWvIqvng, I suppose I could just make duplicates of this circuit to get more voices?

I've been using my 6522's T1 timer to generate tones for a while now, but I'm looking for something more capable than a single-voice output. Any suggestions are welcome. Thank you everyone!

Chad


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Wed Sep 20, 2023 6:12 pm 
Offline

Joined: Mon Feb 15, 2021 2:11 am
Posts: 100
I ran across a page of microcontroller audio projects. Perhaps there are some ideas that could be cadged from there.

http://elm-chan.org/he_a_e.html


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Wed Sep 20, 2023 7:03 pm 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
sburrow wrote:
I read through the entire topic and, besides being very confused about definitions and other particulars, I didn't see a one-size-fits-all answer. I like the two ideas above though. I went through the TLC7524 datasheet and, well, I don't even know where to start with DACs it seems. They recommend op-amps connected to it, etc etc. Couldn't someone create their own DAC with a latch and some resistors? I feel like I do the same thing with my video circuits, but I'm just so unfamiliar with audio basics.

I think you could use a resistor network for the DAC, depending on what you're driving though I think you may still need an op amp or something similar to form an analogue buffer. There's a very simple way of using an op amp to just copy a voltage level, by connecting the output pin to the inverting input pin.

Quote:
Any recommended resources for me to get a rough idea of where to start? I just watched George's videos on a similar topic, one of which is here: https://www.youtube.com/watch?v=iFAMWvIqvng, I suppose I could just make duplicates of this circuit to get more voices?

I never followed that video up, but I did put two of those together, and it worked fairly well. It's basically what you're doing with the 6522, but using external counters. You only get square wave output of course, and constant volume. If you used two or more together then you'd need to mix the signals, but you could use a XOR gate for that as the signals are digital - or you could use an op amp to add two analogue signals together (or rather, to interpolate between them, but it's effectively the same thing).

I also tried to add a digital volume control/mixer, but my analogue electronics were not up to scratch, I'm sure my approach was very poor. This is where unless you're really interested in how to make the circuit work, it makes more sense to use an off-the-shelf part, if you can find useful ones that are still produced.

If you want really good sounding audio then Moritz Klein has made many YouTube videos about various aspects of analogue synths, which are well presented and fairly easy to follow, but perhaps not so much aimed at microprocessor control.

If I ever want to make good audio with a 6502-based system, my main plan has always been to use large ROMs for wavetable synthesis. I have some ridiculously huge EPROMs that could be programmed with all sorts of things - different waveforms, amplitudes, mixes between signals, etc.

But I do like the idea of encoding it into the video memory, for something mixed by the CPU. Another approach that AndrewP pointed out (I think?) is to use FIFOs, allowing the CPU to take an interrupt and write a batch of samples into the FIFO, then the other end of the FIFO drives some form of DAC. All that said, I am wary of anything where the data comes from the CPU though as it's going to be fairly expensive on the CPU to do any serious mixing.


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Thu Sep 21, 2023 1:49 am 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 159
Location: Texas
sburrow wrote:
Agumander wrote:
...

I read through the entire topic and, besides being very confused about definitions and other particulars, I didn't see a one-size-fits-all answer. I like the two ideas above though. I went through the TLC7524 datasheet and, well, I don't even know where to start with DACs it seems. They recommend op-amps connected to it, etc etc. Couldn't someone create their own DAC with a latch and some resistors? I feel like I do the same thing with my video circuits, but I'm just so unfamiliar with audio basics.


You could make a DAC with a resistor ladder for an audio circuit just as you would for a video circuit, how good it would be would depend on how accurate your resistor tolerances are. Personally I'd prefer to use a premade DAC for that purpose. That way I don't have to mess with having to figure out if I have a problem with wiring vs. resistors vs. something else.

As for the Op Amp, these can be had for fairly cheap and if you're just driving line level voltages to another bit of stereo equipment, you shouldn't need to go crazy. Take a look at the LM386, there are a plethora of instructions on the web on how to hook it up to act as a hi fidelity amplifier for high end headphones. (Note, that would be too high for line level voltages, but the principles are the same.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Audio IC
PostPosted: Thu Sep 21, 2023 9:48 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
It's well worth checking out the Music 5000 thread (viewtopic.php?f=4&t=4436) that Chris Jordan has just joined and resurrected - it was a very impressive system from the 80s that he designed, and while it's probably more complex and capable than you were looking for, it could be a good source of inspiration and maybe there are some useful subsets of the functionality that could make sense.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 38 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: