6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 12:09 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Simple Audio Mixer
PostPosted: Sun Jun 26, 2022 8:50 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Hello everyone,

While working on the latest 6502 project, I found a way to create two square waves for audio purposes. I want to mix them into a single channel. I searched the forum for "audio mixer", you would be surprised how little is there. I went looking online and found this:

https://electronics.stackexchange.com/q ... nput-audio

With a bit more searching, this led me to trying things out in falstad.com, particularly this:

https://www.falstad.com/circuit/circuit ... bBvSoBThAA

Which I recreated with the attached picture. If both square waves are being used at once, I get an amplitude of -1V to +1V, with 0V when they are conflicting. That is the basic "adding" principle. But when I only have one square waved being used (the other is just grounded) I get an amplitude of -0.5V to +0.5V, never at 0V because there is never a conflict.

This isn't too bad, but it means each is only 'half volume' by itself.

I went looking further and found folks using op amps to do a better job:

https://www.electronics-tutorials.ws/opamp/opamp_4.html

But the more I look, the more I see the need for an negative voltage to be applied to the op amp (I'm super new to this, sorry), and often +9V and -9V, which is definitely not my simple SBC 5V target here. I also tried using a comparator in place of the op amp, but that sorely did not work, as they work on a different principle entirely.

Do any of you have recommendations on how to combine 2x 5V square waves better than what I currently have? In a *simple* way?

And, while I'm at it, are there any modern new-stock sound chips that pair well with the 6502? Something that I could buy from Mouser, let's say?

Thank you for any assistance!

Chad


Attachments:
AudioMixer.png
AudioMixer.png [ 4.84 KiB | Viewed 565 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Simple Audio Mixer
PostPosted: Sun Jun 26, 2022 8:59 pm 
Offline

Joined: Wed Jun 23, 2021 8:02 am
Posts: 166
The 'half volume' thing is inevitable if you use a simple mixer. If you add two signals of two different frequencies with equal amplitudes, the power of the combined signal will be double the power of each signal individually. To avoid that you would need to use a variable gain depending on whether one or both signals were active.


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple Audio Mixer
PostPosted: Sun Jun 26, 2022 9:34 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
I'd suggest something that's active... you can use either FETs or older bipolar transistors. Just configure them as emitter or drain followers. You can take the input signals, drive them into 10K or 20K potentiometers, the output of those will drive the FETs/Transistors and you simply sum the outputs of the followers. There will be a bit of gain loss in the followers, so you can always add another gain stage after it.

I don't have the schematic handy, but back in the 1974, I designed a simple mixer for 4-channels with discreet transistors (2SC945) with trimpots for audio input level. It all fit on a small perf board and ran off a single polarity supply.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple Audio Mixer
PostPosted: Sun Jun 26, 2022 10:08 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Using half a floor-sweepings LM358 on 5V only, I come up with this (again on the back of an envelope):
Attachment:
5VmixAmp.gif
5VmixAmp.gif [ 23.55 KiB | Viewed 548 times ]

The values are chosen to span the limits of the output voltage range with a 5V supply. (It's not a rail-to-rail amplifier, and it can't pull as close to the positive rail as it can the negative one, and when driving much of a load, it can't pull down to less than about 0.6V.) In your application, distortion shouldn't be a problem, but since it is pushing the limits of its output excursion, reducing R5 (the feedback resistor) from 33K to 30K or 27K should take care of it, at the expense of slightly reduced output. There's no need for a negative supply since a reference voltage is fed to the + (non-inverting) input. C1, the 22pF, just compensates for input capacitance. You may or may not need it. R7 prevents a heavy capacitive load from adding a pole to the transfer function and losing your phase margin and getting an oscillator. R7 and C1 will make sure it's stable under all conditions. C2 reduces noise on the reference input. For non-critical applications, you can omit it. I forgot to put a value on the output capacitor, C3. A 4.7µF will be fine. Even 1µF would be plenty if the load is light. R6 biases the output to take care of a little crossover distortion that the LM358 and '324 otherwise have. For non-critical applications, you can leave it out. Otherwise make it about 1/3 of the load impedance value; for example, for a 30K load, 10K will get rid of that slight crossover distortion.

Edit: I forgot to add a resistor at the right end to bleed off the output capacitor, C3. 100K will work fine for that. This circuit will give nearly the same output signal voltage as your passive mixer above, but can drive much heavier loads at that voltage. It would be able to do a lot more if more power-supply voltage were available.

_________________
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: Simple Audio Mixer
PostPosted: Mon Jun 27, 2022 2:03 am 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1007
Location: Canada
sburrow wrote:
If both square waves are being used at once, I get an amplitude of -1V to +1V, with 0V when they are conflicting. That is the basic "adding" principle. But when I only have one square waved being used (the other is just grounded) I get an amplitude of -0.5V to +0.5V, never at 0V because there is never a conflict.

This isn't too bad, but it means each is only 'half volume' by itself.

This is normal Chad. Even with op-amps buffering each input, the mix is the sum of the input signals. Rather than think of each signal being at "half" volume, think of it as that is their full volume. You will get much more amplitude when both inputs are high or low together. You'll get the sum.

_________________
Bill


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple Audio Mixer
PostPosted: Mon Jun 27, 2022 11:42 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Thank you all.

floobydust wrote:
I'd suggest something that's active... you can use either FETs or older bipolar transistors


I looked into that, and tried it out on the simulator and seems to work as expected. Definitely a good suggestion, thank you.

GARTHWILSON wrote:
This circuit will give nearly the same output signal voltage as your passive mixer above, but can drive much heavier loads at that voltage.


That was the deciding factor for me. I see that a 100K bleedoff resistor doesn't let C3 stabilize very quickly, so I changed it to 10K and it seems to work ok in the simulator. Then again, I don't think I can trust the simulator because when I add C2, the thing starts freaking out at random times. Lastly, for sake of whoever will read this in the future, I changed the 4.7uF cap to 10uF and it seems to give me a more squared wave, not a psuedo-triangle-thing.

Thank you very much for this Garth, I appreciate it greatly.

BillO wrote:
This is normal Chad. Even with op-amps buffering each input, the mix is the sum of the input signals. Rather than think of each signal being at "half" volume, think of it as that is their full volume. You will get much more amplitude when both inputs are high or low together. You'll get the sum.


Ok, that is good to know. I'm so new to analog, and even more new to audio mixing, that I don't even know what the goal is sometimes. I just think, "Can't I just stick them together?" And yes, kindof, but the result is as expected: Waves that interfere will cancel, waves that combine will add. Simple, but I guess I didn't understand that simple was intended. :)

Thank you all very much, I'm going to be using Garth's circuit. More updates on the 6502 project soon to come!

Chad


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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: