Optical Digital Audio Mixer/Combiner

I would like to combine and mix 2 (optical) digital dolby 5.1 audio signals into one. Simply mix them at a fixed 50-50% ratio. The only commercial products I can find that do it have lots of inputs (not just 2) and all kinds of other features and start at $900.
Now, I recognize since this is a digital audio stream (as opposed to analog) with multiple channels and dolby enhancement this is not exactly gonna be simple. Googling has led me to lots of different decoder chips, all of which seem way overly complicated for what I want to do. Googling has also led me to some encoder chips (not near as many) which again seem overly complicated and which don't appear to match up in any direct or semi-direct way to the decoder chips. I Was originally hoping to find 2 prebuilt basic decoder modules and a prebuilt basic encoder module and connect them together in a "Y". But now I suspect that I will need some sort of processor and software to act as intermediary.

Can anyone suggest some parts I might want to look at to start from?

Note: I've found plenty of splitters and switches for sale. And some people are reporting using a splitter as a combiner (or maybe more accurately, an automatic switch) but that depends on only one device being powered on at a time, and it does not mix the audio.

How much hardware/software experience do you have?

Conceptually it's pretty easy. Mixing is done by summation (analog mixers are built-around analog summing amplifiers). You just sum sample-by-sample and you have a mix.

However, you do have to scale-down the data before or after summing to prevent clipping. Most DSP is done in floating-point so you can scale-down after summing as long as the data sent to the DAC doesn't go over 0dBFS.

If the streams have different sample rates, you'll have to re-sample at least one stream.

I'm not sure if the Arduino is fast-enough to do this, and I'm almost certain that you can't sum 6-channels of floating-point data with the Arduino.

To perform an audio mix down you would have to decode both stream to audio and the perform an audio mix of them and then convert them back to Dolby. Dolby decoders / encoders are not free.

You would need to buy a license from dolby for the relevant codecs. You can not mix the digital streams.

DVDdoug:
Conceptually it's pretty easy. Mixing is done by summation (analog mixers are built-around analog summing amplifiers). You just sum sample-by-sample and you have a mix.

Well it is a lot more complex that that. First of all the data in sent in packets which are synchronised to a time stamp. Then in the packet their is all sorts of Meta data along with any sample streams. The data is compressed with their own compression algorithm. Then the whole thing is encrypted quite strongly and their is no published information on the decryption. So even if you knew what to do it is definitely illegal without the license.

I have found a box for $20 that breaks down a optical digital dolby 5.1 signal into 6 analog outputs. Can't find a corresponding box that goes from 6 analog inputs to a digital stream. Would just as soon not go to analog and back if I can avoid it.

How much hardware/software experience do you have?

A good bit. Electrical engineer and programmer for 40 years. However, I don't have much working experience in the area of digital audio, just theory. I should be able to handle this if I can find parts that do the heavy lifting of decoding and encoding the proprietary dolby digital format. Have found lots of chips from lots of mfrs, such as intersil D2-74583, Cirrus CS4953xx, NXP DSP56362, ST STA310, more... But perusing the datasheets, they all seem like extreme overkill having all kinds of advanced features I don't want or care about. All in large QFP packages and none of them have less that 100 pins. Not as many choices for encoder chips (but still a bunch) and again, they all look like total overkill. So I was hoping that someone reading this might be familiar with some more straightforward, basic, no-frills, not-so-advanced-featured decoders and encoders.

I'm not sure if the Arduino is fast-enough to do this, and I'm almost certain that you can't sum 6-channels of floating-point data with the Arduino.

Yup, expected as much. But I have plenty of fast 32-bit ARM based microcontrollers in my arsenal, some with FPUs. Don't think the digital audio is floating point tho, should be a signed 16 or 24 bit integer, at a rate of 44.1K or higher samples per second.

Grumpy Mike: Yeah, I know dolby is a copyrighted and patented and very complicated set of algorithms and must be licensed. Even if I had a license, I wouldn't care to attempt all the code and math required. Thusly, my desire to use readily available decoder/encoder chips where the mfr has already licensed it.

It would be awesome if I could find a decoder that simply feeds me 6 streams of numbers (16-24 bit, 44.1K+ SPS) and I could just divide by 2, add them, and then feed the 6 streams of numbers into an encoder chip.

So let me re-phrase my question: Is anyone out there reading this familiar with such decoder/encoder chips and can suggest some specific parts for this? Or at least tell me where the shallow end is so I can jump in with both feet but not be over my head and drown!

(Thanks to all that have already answered with tips/suggestions!)

DrWizard:
It would be awesome if I could find a decoder that simply feeds me 6 streams of numbers (16-24 bit, 44.1K+ SPS) and I could just divide by 2, add them, and then feed the 6 streams of numbers into an encoder chip.

It's not as easy as just dividing a digital number by 2 and adding to another number divided by 2.

Grumpy_Mike has already explained the difficulty in understanding the protocol used.

Also you would need to do this manipulation at the data rate.

If the stream happens to be Dolby Atmos or DTS:X then it includes "objects" which must be decoded by the final decoder and added to the 5.1 "conventional" speaker channels. Eg. the sound effect of a helicopter can be panned overhead using the available speakers instead of fixed to the channels which you may not even have in your setup.

I suspect objects can be mixed by just adding all the objects to the stream.

Thusly, my desire to use readily available decoder/encoder chips where the mfr has already licensed it.

No that is not how licensing works with Dolby or many other thing. It is not payed for by the chip manufacturer it is payed for by the people who solder the chip down and use it. I know because I used to design set top boxes and I had to go into all the gory licensing stuff. In the Sky set top box for example, the Dolby stream is not decoded but simply passed through the box to the Dolby decoder in your sound system.

I don't even want to think about decoding a dolby stream myself, I know it's super complicated, that's why I wanna use decoder chips. Seems like every major chipmaker has some. (TI, STM, Intersil, Cirrus, NXP...) some are as cheap as $7 although I have yet to find any of them available in small quantities. May have to request engineering samples from the sales depts.

All of the decoder chips I have looked at so far output the fully decoded signal on 6 or more PCM or PWM pins, ready to amplify and send to the speakers. But PCM and PWM are not good ways to get a signal into a microcontroller (or even an FPGA) nor can they be directly added. They also all have some variation of I2S or Serial Audio Interfaces which I believe can probably be used to read and/or write decoded digital audio. If I'm understanding the datasheets correctly, the I2S interfaces would be the way to get the raw digital audio data into and out of a microcontroller or DSP.

All of the decoder chips I have looked at have internal mixers and have from 2 to 6 S/PDIF inputs and 2 or more outputs. Alas, on all the chips I have looked at, the S/PDIF inputs and outputs are multiplexed and only 1 is active at a time, therefore I can't mix them. (If I could, it would be a simple 1 chip solution).

It [license] is not payed for by the chip manufacturer it is payed for by the people who solder the chip down and use it.

Seems screwball, but I believe you. Only 1 of the 11 datasheets I have read so far mentions this. The rest would lead you to believe the chip is already licensed. For now anyway, I only want to build 2 of these for personal use so I'm not overly concerned about a license. Doubt they would sell me one anyway for just 2 devices. I suspect there may be a niche market for such a product however.

Look at the Teensy audio library for I2S input and output using an ARM Cortex CPU. The library includes a mixer node. You will need more than one to handle so many channels. But this might result in sync problems.

although I have yet to find any of them available in small quantities. May have to request engineering samples from the sales depts.

Yes that is how it works. You request a sample and then you get a visit from a sales rep, who amongst other things assesses your company, your project and the potential sort of numbers you will end up ordering. They will also ask about other manufactures chips you are looking at. Then if he is satisfied that it is a legitimate opportunity he will get you to sign a none disclosure agreement and then you get your samples. In my experance these things are not handed out like candy. The minimum order quantity is there for a reason.

This happens all the time with specialist chips for consumer products. You try buying a chip for part of a set top box, with many companies you can't even get a data sheet. For example take the Broadcom chip used in the Raspberry Pi, you can get the peripheral specifications but not the complete data sheet. And they have sold upwards on 11 million of those. The Pi only got designed because several of the Pi people were employees of Broadcom and they let them "buy" an obsolete ( technically ) chip.