BMOW title
Floppy Emu banner

Mixing and Volume

I’ve done some more breadboard experiments with the audio output circuit, but I’m having a lot of trouble getting it all to work as intended.

First the good news: I built the LM386 amplifier section, and it pretty much works. I purchased a five-conductor headphone jack, which passes the left and right channels through to the mono amplifier section when nothing is plugged in, but disconnects the amplifier section when a headphone plug is inserted. The only problem is that even when disconnected, the amplifier section still picks up a faint copy of the audio signal (from antenna effects or power supply noise?) and amplifies it. Ideally the amplifier section would be switched off entirely when a headphone plug is inserted, instead of merely disconnecting its input signal.

The bad news: The portion of the circuit before the headphone jack seems able to mix three channels into two, or to control the volume, but not both. The AY-3-8913 has three separate voices: A, B, and C. I want to mix them so that A is on the left stereo channel, C is on the right channel, and a half-volume copy of B is on both channels. This job is done with a resistor network. I also want to control the output volume with a potentiometer. Below are two similar circuits for performing these tasks. Although it’s not shown here, both circuits have their L and R outputs connected to the headphone jack, which in turn is connected to the speaker amplifier section as described above.

audio mixer circuit

On the right is the “Polish circuit” I mentioned in my last post, with a 10K stereo audio potentiometer added at the output. On the left is a circuit I found on a ZX Spectrum hacking site, also with an output potentiometer. Neither circuit included a potentiometer originally.

You can probably see where this is going: the functions of mixing and attenuation conflict. Mixing works because the total resistance between A, B, or C and L or R is different for different paths. In the case of the Polish circuit (right side), if the potentiometer is turned all the way so there’s zero resistance between input and output, then the total resistance from A to L is 1K, from B to L is 2.2K, and from C to L is 5.4K. There more than 5x the resistance for C to L versus A to L, so A appears mostly on the left channel, and very little of C appears on the left channel.

If the potentiometer is now turned almost to the other extreme, so there’s 9K resistance between input and output, the situation changes. Now there the total resistance from A to L is 10K, from B to L is 11.2K, and from C to L is 14.4K. These are all similar enough that all voices go to both channels more-or-less equally, and the stereo effect is lost. This is where I’m stuck: I can get stereo mixing, or volume attenuation, but not both at the same time. The circuit on the left uses larger resistors, so the loss of stereo is less pronounced, but the maximum volume level is quieter.

Some ideas for addressing this problem:

  1. Move the potentiometer to after the headphone jack. This would allow for volume control of the amplified speaker, which is mono anyway, but the headphone jack would always be at maximum volume. In practice this would make the jack only useful as a line-out, and not for headphones.
  2. Change the stereo mix so that A and B go to the left channel, and C to the right, with no common path between them. This is simple but non-symmetrical, and the 100% stereo separation may not sound very pleasing.
  3. Use a transistor or op-amp as a voltage follower, inserted before the potentiometer, so that changes in the potentiometer resistance don’t affect the resistor network used for stereo mixing. This might be the best solution, but I’m uncertain how to build it, and don’t want to add still more elements to an already large circuit.
  4. Buy a second AY-3-8913, and create a six-channel audio system with three voices on each channel. Ha ha.
Read 7 comments and join the conversation 

7 Comments so far

  1. Steve - January 18th, 2009 6:24 pm

    Looks like my analysis was flawed, because I forgot to account for the 1K pulldown resistors that you see on the sides of the circuit. After applying electronics 101 rules to calculate the voltage at each point, I convinced myself that the stereo separation is only slightly altered by the potentiometer. I should have just tried it first. It does work.

    So now I have a nearly finished circuit prototype. You can listen in stereo with headphones or line-out to an external amp, and the volume control works. Unplugging headphones activates the internal amplified speaker.

    The only remaining problem is that music from the speaker sounds pretty poor. I wasn’t expecting a lot from a 0.25W of amplification, but it’s distorted enough to be fairly annoying. It seems to depend a lot on what sounds I play: a single tone at any frequency sounds good enough, but playing different tones on each voice sounds kind of harsh and buzzy. I checked to make sure I’m not overdriving the LM386 or the speaker. Turning down the volume still sounds harsh and buzzy, just quieter. I also tried all manner of filtering capacitors. It’s probably good enough as-is, but I have a feeling I’ll be using the headphone/line-out jack most of the time.

  2. Lee - January 19th, 2009 6:02 am

    Is there a DC isolating capacitor in the audio path to the LM386? If not it may help.

    Otherwise putting 47nF capacitors in parallel with the 1K to ground resistors will give a roll off at about 8KHz which may help. 100nF capacitors would shift the roll off to about 4KHz if 8KHz is still too high.

    Is the LM386 circuit taken from the data sheet?

  3. Steve - January 19th, 2009 8:13 am

    The complete schematic, including the amplifier/speaker section, is at http://www.bigmessowires.com/audiomixer_complete.png I did try experimenting with low-pass filters at the input, but perhaps not in the way you’re describing. Can you elaborate? It didn’t seem to help the distortion, other than that the high-end was diminished somewhat.

  4. Lee - January 19th, 2009 4:52 pm

    If all it did was remove the high end then you were probably achieving what I was suggesting.

    Other possibilities. Is the speaker good? Some small speakers just sound awfull no matter how you drive them. If the spealer is good is the LM386 good? Does the output sound better amplified by a set of active PC speakers?

    Remote diagnosis is never easy.

  5. Steve - January 19th, 2009 7:58 pm

    The speaker is a generic 2.5 inch 8 ohm speaker that I bought as surplus. You can see it in the video from the previous entry. No, it’s probably not very good. I also tried a different (smaller) speaker, and a piezo speaker, and both were quieter but not noticeably better in quality.

    Listening through headphones, or an external amplifier connected to the headphone jack, the sound is decent enough– about what you’d expect for a bunch of square waves.

    To be honest, the sound from the amplified speaker via the LM386 isn’t so awful, and maybe I’m just expecting too much. If you didn’t listen through headphones first, you might not think there was anything wrong with the LM386 sound, or think it was supposed to sound kind of buzzy and crunchy. But listen to it with headphones and you’ll hear a clearly audible difference.

    I’m pretty clueless about most audio topics, but it sounds like what I’d expect if the the signal were being clipped somewhere. Yet even when turning the volume way down, it just sounds quieter without noticeably affecting the buzziness.

    I’m going to try a different LM386, as well as a couple of more modern small power amplifiers (TDA2822M and TA7368P), and see if that helps at all. If not, I’ll just build the circuit as is, and hope that a carefully-built circuit board will have less sources of noise than a protoboard exercise with wires hanging out everywhere.

  6. Steve - January 19th, 2009 8:50 pm

    I tore the whole circuit down, and rebuilt exactly what’s in the AY-3-8913 datasheet, and it still sounded bad. But then I discovered something very interesting: if I amplify any single voice, it sounds great. But if I amplify more than one voice (wiring them directly together as per the datasheet), it sounds bad. My hunch is that the two voices combined create lots of higher frequency interference, and the LM386 introduces a lot of distortion at higher frequencies. I tried the low-pass filter at the input again, and I think it did help somewhat, but not enough. So I’m back to my plan of trying a few other amps to see if they perform better.

  7. HLSDK - January 20th, 2009 8:55 am

    Well the AY is definitely the way to go. Good to hear that you and BMOW are back and going strong!

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.