Digitally controlled analog (audio) mixer - Page 1
Forum section: electronics / beginners

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 01, 2024, 04:16:20 pm
content: Hey everybodyImagine a traditional analog audio mixer, but without EQ, compressor and all the other stuff, just inputs, their volume control, and outputs that can be any combination of the inputs.Would it be possible to create such a circuit, dealing with analog signals but digitally controlled?I found this chip called AD75019, which is a 16 x 16 matrix mixer containing 256 analog switches. Looks great on paper, but there is no way to have access to the inside nodes. See this circuit:(circuit here:https://tinyurl.com/2cefdkkm)It works fine when mixing multiple inputs into one output (many to one), but when duplicating one input into multiple outputs (one to many) it divides the voltage. If I move the 100k resistors on the right side of the matrix, i.e. next to the output opamps, then the "one to many" works, but "many to one" does not (shorting the opamps' output to each other).The only solution I could find would be to add resistors inside the matrix, so that each input opamp has 16 resistors in parallel. This is possible if using 16 chips with only 16 analog switches each, but that's a lot of ICs, hard to find, and would be very expensive.Any ideas?Thanks!

author: PGPG
author_rank: Frequent Contributor
timestamp: October 01, 2024, 04:43:45 pm
content: You need 6 100k resistors (3 at each input of output amplifier) and switches before these resistors.First what come to my mind as digitally controlled switch is CD4066.

author: BrianHG
author_rank: Super Contributor
timestamp: October 01, 2024, 04:47:37 pm
content: Whats wrong with an I2C digitally controlled potentiometer?Google: digitally I2C controlled potentiometersOr, us a voltage output dac to drive a 4 quadrant multiplying mixer. Though, this guy is usually expensive.Or, an opamp with voltage controlled gain.

author: rteodor
author_rank: Frequent Contributor
timestamp: October 01, 2024, 05:03:56 pm
content: Just throwing my 2c: maybe use non-inverting topo as the output buffers ?And out of curiosity, how many inputs, outputs and "mixing lanes" are we talking about ?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 01, 2024, 05:37:26 pm
content: Anymultiplying DACcould be used to control the volume, just like a digital potentiometer, but that does not take care of the combining of the inputs to the outputs.A4051analog multiplexer/demultiplexer could be used for this. Allows for 8 channels to be mixed to 1 channel. With proper resistors for the mixing of the inputs and a high impedance input at the output stage should work even when routing one input to multiple outputs.The AD75019 seems to provide the same but for 16 inputs to 16 outputs (Yes I know it is bidirectional, but for the purpose of the mixer from in to out is all that is needed) it allows for a smaller PCB.Make sure to use coupling capacitors in the audio paths to avoid DC shift of the signals.Edit: The problem with your setup is that the output buffers see the 100k mixing resistors as input resistor and when more then one output is connected you get parallel networks that modify the output stage gain. So using non inverting buffers (opamp voltage follower) would solve that problem.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 01, 2024, 08:28:33 pm
content: Thanks for all the replies.Quote from: PGPG on October 01, 2024, 04:43:45 pmSorry I don't get it, three 100k resistors in series? To make 300k? But that will change the gain on the output opamps, and using the same input for multitple output will still have the same issue, wouldn't it?Quote from: BrianHG on October 01, 2024, 04:47:37 pmThat's a great idea - you meant to control the volumes at the inputs and outputs, right? Do you have any recommendations? And what about the mixing and multiplexing of the input signals?Quote from: rteodor on October 01, 2024, 05:03:56 pmWell I was thinking 16x16 (16 inputs and 16 outputs) since that's the size of the AD75019.And good points about the suggestions - 4051 would work but for a 16x16 I would need 2 for each output, so 32 chips total. That might be both pricey but also take a lot of spaceAs for using non-inverting topo as the output buffers, that's a great idea but because of the high impedance input of the output opamps the voltage gets divided when mixing to inputs (so we're in the opposite situation: now one-to-many works, but many-to-one does not). See this circuit:( -> circuit here:https://tinyurl.com/28m3cgvo)

author: BrianHG
author_rank: Super Contributor
timestamp: October 01, 2024, 09:04:23 pm
content: MCP4351All pot outputs buffered through opamps are mixed together, then an optional final volume and buffer opamp.TLO74 should be fine for audio.Your volume settings controls the mixing levels.

author: BrianHG
author_rank: Super Contributor
timestamp: October 01, 2024, 10:14:48 pm
content: If you want greater than 0-5v support, like +/-18v support, try this part:https://www.microchip.com/en-us/product/MCP41HV51

author: The Soulman
author_rank: Super Contributor
timestamp: October 01, 2024, 10:34:09 pm
content: The Gamble DCX may provide some inspiration:https://web.archive.org/web/20240226010438/https://www.gambleboards.com/Article.htm

author: BrianHG
author_rank: Super Contributor
timestamp: October 01, 2024, 11:57:02 pm
content: Also look here:https://www.analog.com/en/parametricsearch/12881#/Make sure you know what you are doing with audio...and here:https://www.analog.com/media/en/technical-documentation/data-sheets/ad5124_5144_5144a.pdf

author: rteodor
author_rank: Frequent Contributor
timestamp: October 02, 2024, 05:53:43 am
content: Quote from: Saimoun on October 01, 2024, 08:28:33 pmQuote from: Saimoun on October 01, 2024, 08:28:33 pmHow so ? 10k and 1M is about 1% loss of amplitude. But there is another problem with current schematic: there will be a loss of amplitude with each additional input connected to the same mixing channel/lane. Without taking into account opamps output impedance, all 16 inputs mixing into one lane mean there would be 15 * (10k ||). That's 10k with 666 ohms. This is drops the amplitude in 16 steps down to about 4%. To say that this would be a bad mixer is an understatement.I think it would be simpler to use "inverting summing amplifier" a.k.a "virtual earth mixer". Hopefully this image link and article could clarify it:Source: Summing Amplifier or Op Amp Adder Circuit:https://circuitdigest.com/tutorial/inverting-operational-amplifier-op-amp

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 02, 2024, 06:03:43 am
content: Quote from: Saimoun on October 01, 2024, 08:28:33 pmThe AD75019 ain't cheap either, so it is more about board space, and most likely less noise with the single chip solution due to shorter and less tracks on the input side.Quote from: Saimoun on October 01, 2024, 08:28:33 pmMove the mixing resistors to the other side of the switches. Yes this multiplies the number of resistors but solves the problem to some extend. This way the mixer is driven by low impedance outputs, instead of higher impedance outputs driving multiple high impedance inputs. With small SMD resistors it only takes a little bit more space on the PCB.And don't forget coupling capacitors to remove any DC offset from the signals, otherwise it might fail in real life.

author: PGPG
author_rank: Frequent Contributor
timestamp: October 02, 2024, 07:34:38 am
content: Quote from: Saimoun on October 01, 2024, 08:28:33 pmNo."3 at each input of output amplifier".How to say it more clearly?Each of 2 output amps has its (-) input. You connect 3 100k resistors to this (-) input. Each resistor has one end connected to this point. The other (not connected with (-) input) ends of these 3 resistors are 3 inputs to the output amplifier."and switches before these resistors."You locate analog switches before these resistors that means between pre-amplifier outputs and these resistors.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 02, 2024, 08:50:49 am
content: Hi all, thanks for the replies again. I'll try to reply to everybody here, please feel free to let me know if I missed one of your comments.Quote from: rteodor on October 02, 2024, 05:53:43 amLook at the picture in my last post - on the top right the output is 3V instead of 6V (5+1). It's not because of the 10k/1M, it's because the input opamps feed into each other. If I increase the 10k to 100k they feed less, but then there is less current going into the opamps on the right, so we're still at 3V.Quote from: rteodor on October 02, 2024, 05:53:43 amThanks for the suggestion, but if you look at my first post, this is what I had in the first place, then people here suggested a non-inverting configuration. And yes moving to inverting solves the many-to-one problem, but then the one-to-many does not work.Quote from: pcprogrammer on October 02, 2024, 06:03:43 amAs explained in my first post, that does not work because in this case the output of the opamps on the left get shorted. It would work if we could place one resistor on each "node" but that means the resistors have to be "inside" the 16x16 matrix, which is not possible with the AD75019. It would be possible with the 32 CD4051 chips.Quote from: PGPG on October 02, 2024, 07:34:38 amOk, so in parallel then? so 3 resistors connected in parallel to (-) of each of the two output opamps, that makes 6 resistors total, so far I'm following.Then the other end is "3 inputs to the output amplifier" - I think I understand, you mean these are connected to theoutputof each the 3input opamps(the opamps on the left), correct? Yes that would work but would require placing resistors on each node, i.e. "inside" the matrix as I've just explained above - which is not possible with AD75019.Quote from: BrianHG on October 01, 2024, 09:04:23 pmThat's an interesting idea, then we could ditch the matrix altogether, just using the pots to control which inputs goes where. But that would mean one 16 volume control for each output, so 256 in total. So 256 opamps and also 256 digitally controlled pots, which would take a huge amount of space on the PCB.And thanks for the AD5124 suggestion (4x I2C controlled pots). About $4 / unit though (so $1 / pot), so just to have volume control on inputs and outputs, that would already be 32 pots, i.e. $32. For the option above, that would be $256.So, clarifying the current situation: (not judging in any way, and I appreciate all your help very much, I'm just making sure we know where we are)We do not have any solution using theAD75019(16x16 switches), we've tried:moving the resistors on one side of the matrixon the other sideusing inverting and non-inverting topoIn all those cases, either the one-to-many or the many-to-one configuration does not workIf someone has a working solution with this chip I'm all earsUsing 32x CD4051 chips would work, but that's a lot of board space (+ could have noise issues as pcprogrammer noted)Using no switches and only digitally controlled pots (or VCAs?) would also work, but that would require 256 pots - large space and expensive

author: BrianHG
author_rank: Super Contributor
timestamp: October 02, 2024, 02:33:14 pm
content: If your goal was a cross matrix 16 ins to any 16 outs, your cheapest solution would be all digital.You can get 24bit per channel, 192khz sampling, 8 channel adc/dac audio codecs for around 5$ and you would only need 2 for 16 ins and 16 outs. For a better studio quality SNR, you would go for 8x 2 channel units.For absolute minimum delay, we are talking a few microseconds, use a cheap FPGA like an Altera MAX10 or bottom end Xilinx or Lattice ECP5 series.The volume mixer code should only be around 2 pages of verilog, (another page for the I2S audio data bus and another for the PLL setup), but you will get you 256 x 16bit volume controls with 24bit audio data, 32 bit summed mixed audio out stream with software controlled clipping/limiting to feed each 24bit dac. You will also have the ability of inverting channel volume, even bass and treble controls if you want to. Full EQ if you can tolerate a few additional microseconds depending on the finite quality you are looking for, however, anything you do here will exceed you analog solution in sound quality and noise by a huge mile.

author: PGPG
author_rank: Frequent Contributor
timestamp: October 02, 2024, 03:13:26 pm
content: Quote from: Saimoun on October 02, 2024, 08:50:49 amI would never name resistor being connected parallel if only one their ends are connected together?Quote from: Saimoun on October 02, 2024, 08:50:49 amWhy you mix here AD75019?Your first question was:Quote from: Saimoun on October 01, 2024, 04:16:20 pmAnd I am writing only about it and not about using this or that IC to switch analog signals.

author: rteodor
author_rank: Frequent Contributor
timestamp: October 02, 2024, 03:56:40 pm
content: Quote from: Saimoun on October 02, 2024, 08:50:49 amWhat I had in mid was something like this:(maybe you can use then AD75019 to select the output - the part in the middle)

author: BrianHG
author_rank: Super Contributor
timestamp: October 02, 2024, 04:33:37 pm
content: Quote from: Saimoun on October 02, 2024, 08:50:49 amJust use the equivalent MCP4351. at $1.36 each. Need 64 of them = $87.04.Opamp voltage inverter with an output with enough current to drive the top of all pots in parallel = 16 of them. or 4 quad opampsOpamps to drive the output ports into a negative input mixer = 16 of them, or 4 quad opamps.This project is doable within around 150$ USD.An all digital FPGA solution would be around 75$-150$ USD and that 150$ one would kill the analog one in precision, channel separation, mute and channel isolation, and total SNR by a gigantic margin, like an order of magnitude or more. (Correction, the 75$ one will be an order of magnitude better than the 150$ analog solution, the 150$ FPGA version approaches 2 orders of magnitude better.)Note to deal with the MCP4351 and the analog false ground, I would literally power that IC with +2.7v for Vcc and -2.7v for GND. The level translate for the digital I2C bus giving us a solid GND for the audio path to operate on. For the opamps, I would use +/-5v unless they have really poor drive as they approach their rails.Note the MCP4351 uses SPI instead of I2C, so no extra stupid I2C addressing for 64 chips, you just serial link the in to out and control them all from 3 wire bus, plus a global reset signal.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 02, 2024, 04:39:32 pm
content: Thinking about your matrix problem, the 4051 is not the right choice after all. They select a single input to be connected to the output, so it does not allow for mixing unless you use loads of them creating redundant switches.The 4066 would indeed be better but with only 4 switches per package you would need 64 of them to get the same setup as the AD75019, but it does allow the resistors to be in the right place. Even in sop-14 SMD package it would take quite a bit of PCB space and needs lots of trace routing, plus 256 outputs of a digital system to control the switches.Technically speaking the AD75019 does not short the outputs of the opamps together due to the on resistance of the switches. But with a typical value of 150 Ohm it is a bit low, and makes it a problem as you stated yourself.The digital solution BrianHG mentioned does sound good.You could look into PCM1808 for the inputs and PCM5102 for the outputs.

author: BrianHG
author_rank: Super Contributor
timestamp: October 02, 2024, 04:46:41 pm
content: Quote from: pcprogrammer on October 02, 2024, 04:39:32 pmI already codded it and placed it on github,...Changing my code below to 16 channels and 32bit audio with 16bit volume controls would be childs play.https://github.com/BrianHGinc/YM2149_PSG_system/blob/master/BHG_audio_filter_mixer.svReworking the DC-filter, bass and treble controls each independent input instead of for each output would take some modifications. But if you only need global bass and treble for each of the 16 outputs, then no modifications necessary.

author: BrianHG
author_rank: Super Contributor
timestamp: October 02, 2024, 05:12:07 pm
content: Quote from: pcprogrammer on October 02, 2024, 04:39:32 pmHmmm, for price and board space, try this guy:https://www.ti.com/lit/ds/symlink/pcm3168a.pdf?ts=17278484284586 independent ADCs, differential input if you want studio balanced inputs. (96khz, 24bit each)8 independent DACs, differential again. (192khz, 24 bit each)Only around 6$ each, so you will need 3 of them, 18$ total.With this guy, expect the 107db snr / channel with a perfect lossless digital mixer.I would set my input analog gain for 2x overhead and analog output amp to 2x, still giving you a 1:1 in to out, but, you now have an extra 6db or 2x analog grace/extended zone where no clipping will occur.My github code will need to run at 32x the sampling frequency to mix 18 channels, so, 192khz x 32 = a core clock of 6.144Mhz. (That would be running 16 of my mixers in parallel eating up 16x 32bit DPS blocks in an FPGA) You may also run my code 16x faster and use only 1 DSP block, IE a smaller FPGA, but you need to run the FPGA at 98.304MHz. Still an easy thing as the slowest FPGAs will get you beyond 150MHz without breaking a sweat.I would also add a logarithmic LUT since you want a volumetric volume control, not a linear volume control. But, I guess you may encode that table anywhere you like and just use a simple 16bit linear gain volume as my example code has it's volume as 7bit linear plus invert sign volume. (I didn't need too much quality for old 8 bit computer audio...)

author: donlisms
author_rank: Frequent Contributor
timestamp: October 02, 2024, 07:31:22 pm
content: (As a point of potential historical curiosity… SSM2163, no longer made.)

author: BrianHG
author_rank: Super Contributor
timestamp: October 02, 2024, 08:28:20 pm
content: 1 big plus about going digital FPGA,you can do 'Zero-crossing' detection before changing each volume step to eliminate stepping sound when attenuating large steps.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 03, 2024, 11:39:29 am
content: @PGPG: true, but the AD75019 is a nice compact and inexpensive (per switch) chip so if we could find a solution that work with it great@rteodor: thanks, that's an interesting suggestion indeed! So for a 16x16 we would need 32 CD4066 ICs, correct?@pcprogrammer: Ohhh very good point about the 4051! I did not notice that. Then yes I guess the 4066 or similar would work - maybe with rteodor's solution.@BrianHG: I have literally no experience with FPGA but I'd actually love to try it! I think you pretty much answered the why you can find analog mixers, and digital mixers, but never a "digitally controlled analog mixer"Just wondering, why would using an FPGA instead of a traditional MCU be better? Most ADC / DAC work with the I2S protocol, so a simple MCU could get the digital data, mix it as it pleases, and then output it again?As for the choice of DAC, I remember looking at the PCM1681 before which was quite affordable for 8 channels, then we only need 2. And for the ADC we could use the PCMD3180.Or use Cirrus chips for better performance.Quote from: BrianHG on October 02, 2024, 08:28:20 pmI am not sure what that means?

author: BrianHG
author_rank: Super Contributor
timestamp: October 03, 2024, 01:43:35 pm
content: Quote from: Saimoun on October 03, 2024, 11:39:29 amThe reason for not using an MCU/CPU is that they have an input and output buffer, processing cycles and re-clock timing on those audio buffers no matter how small they may be, this furthers you away from the effect of a real-time analog device.The FPGA you would have running in real time. No buffers, all audio data coming in in parallel and going out in parallel while the FPGA code will have no software cycles in the line. You are literally coding a 32 bit multiplier and adder running with the ADC and DAC clock. This means (we'll use 96khz for the 6 channel cheap chip I chose) 1 sample to load the las one, 1 sample to multiply and sum all the 16x16 matrix, 1 sample to shift out the results.This means 3 sample delay at 96Khz going through the FPGA, IE, the same delay as an 'analog' 32khz bandwidth pre-amp.You wont trim your timing through 256 volume control settings and 16adc & 16 dac channels with this streamline timing on any MCU unless you find and or do some special coding of your own.(Not that for the ADC/DAC, they also have an internal pipeline delay making things a little slower, but with all ADC/DAC filters and processing turned off, you will get something like an additional 8+8 pipeline on to out delay.)I'm saying your fixed audio pipeline delay will be something like less than 1/4000th of a second after all considerations going with an FPGA solution. Nothing anyone could hear.With an MCU, you may be talking as short as 1/200th of a second with 2x256 word audio buffers, or, maybe slower with some soft of OS involved. (Which is why many PC audio Codecs have an internal analog mixer for piping auxiliary audio input to the line out when necessary.)-- Zero crossing --Unlike a slow mechanical hand manipulated volume control, digital volume controls are instant fast. Say your source audio has a 20hz bass note and the source audio is currently at it's peak +1.3v point in the sine wave. Going from a volume setting of 0% to 100% (or eve going from a volume of 0% to 100%) at this point will result in a flat output changing into an instant vertical spike, full power at the change of volume. You hear these as a pop or click in the sound when moving a volume control at instant speeds. A zero crossing detector just waits for the input audio signal to cross 0v in the sine wave before allowing transition to a new volume level to prevent this kind of stepping sound. This is not needed if you will always be smoothly fading the volume control settings.The 6 channel chip I recommended is cheap and fast. All you need are 3 of them, all the audio ins come in on one side of each chip and all the audio outs go out the other side with around 16 digital IO to control each. I would make a separate audio board with the audio codecs and get wire those 3 in parallel except what needs to be separate through a ribbon flex cable or IDC header. Make you FPGA or MCU board separate. This way, you may choose a different processor board or even an FPGA development board to drive your analog module.Whatever you were going to use to control your volume settings, keep on using that and have that device talk to the FPGA, IE send volume settings to the FPGA through your choice of RS232 UART, I2C, SPI, parallel 8 bit with address/data clock, anything you like as an FPGA will eat anything you throw at it. (For simple things, I like to use RS232 since I can use any PC software environment to talk to my FPGA projects with a little USB/TTL RS232 adapter cable.)

author: BrianHG
author_rank: Super Contributor
timestamp: October 03, 2024, 02:14:09 pm
content: The pcm3168a I recommended is an I2S controlled chip, except it has 4 bit lines for 8 channel audio instead of 1 bit line for normal I2S stereo mode. It also has a separate I2S buss for ADC and DAC.It also supports other interface modes if you want to run it the in and out buss merges with fewer IOs.For the FPGA, you literally program your own input/output serializer / deserializer port, so you may use any mode you like.

author: BrianHG
author_rank: Super Contributor
timestamp: October 03, 2024, 02:43:56 pm
content: If you prefer analog devices, they have their AD1937/AD1938/AD1939 which contain 4 ADCs and 8 DACs each.There is no question if you use discrete separate stereo ADCs and DACs, your SNR on the ADC side will improve drastically.But remember, you were thinking of feeding 16 analog audio signals through 16x16 analog switched/volume controls. Even with a separation of 90db between everything, all that cross-talk and board routing will have summed up with a total system THD+N only in the 85db range unless you only had 1 or 2 audio sources running.The FPGA solution would also offer you a free digital 16 channel TOSSLINK / ADAT audio interface output. (hmm, you are approaching 100megabits/sec for uncompressed full 192k/24bit/16channels.)If you want an Analog devices 8 channel sampler with studio grade performance, use this guy: AD7768All you need are 2 of those ADCs and choose an 8 channel studio grade DAC for the other side.Careful and do not order the -4 version, that one only has 4ADCs in it...

author: BrianHG
author_rank: Super Contributor
timestamp: October 03, 2024, 03:09:07 pm
content: For your DAC, go for the analog devices ADAU1966A or ADAU1966, 16 channels...Note that the Analog devices ADC and DAC have an un-filtered 192khz modes designed for minimum pipeline delay.something like 192000/8 for the adc, 192000/4 samples for the fpga and 192000/2 samples for the dac.Though, to get better ADC performance, you will need to turn on its sinc filter increasing it's latency by approximately 4x.This would be nothing anyone could hear, we are still in the microsecond domain.Obviously read the datasheets and double check everything I said.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 04, 2024, 08:15:01 am
content: Amazing, that's very clear thank you! Looking forward to starting to learn about FPGA then ha haEDIT: Oh and thanks for all the ADC/DAC recommendations as well!

author: BrianHG
author_rank: Super Contributor
timestamp: October 04, 2024, 03:15:25 pm
content: Quote from: Saimoun on October 04, 2024, 08:15:01 amFor an FPGA, you are literally coding the logic gates and their wiring as functions. It is basically describing a gigantic TTL schematic with words and how its wired to each pin. But, you also get tools to see your code simulated logic analyzer images as well as real-time scope shots of you functioning circuit for most better FPGAs.Note that dedicated audio DSPs can also get really fast performance if coded properly and you get the advantage of normal C language development. You just need to make sure you have one fast enough to handle 32 audio channels at 24bit, 192khz. The high end ones can do this without issue.