# Help needed in audio conversion

Started by May 9, 2006
```Hello All,

I am currently looking for an 2 channel to 5.1 channel
audio conversion algorithm implementation, plz can anybody help in
regarding this, as there may be a set of formulas or algorithm
available.

With warm regards,

```
```Prasad wrote:

> Hello All,
>
>
>
>             I am currently looking for an 2 channel to 5.1 channel
> audio conversion algorithm implementation, plz can anybody help in
> regarding this, as there may be a set of formulas or algorithm
> available.

Sure. The simplest way:

Out.L  = In.L
Out.R = In.R
Out.C = 0
Out.RL = 0
Out.RR = 0

The most complex way:

Out.L  = hL2L * In.L + hR2L * In.R
Out.R = hL2R * In.L + hR2R * In.R
Out.C = hL2C * In.L + hR2C * In.R
Out.RL = hL2RL * In.L + hR2RL * In.R
Out.RR = hL2RR * In.L + hR2RR * In.R

where hL2L, hR2L, ..., hR2RR are a bunch of impulse responses, and *
denotes convolution. Between the two methods, you can choose the one
that suits your purposes / hardware / specs the best.

Hint: getting the impulse responses might be a bit of a hassle.

Regards,
Andor

```
```i wan to do the second one, and can you please help me or just give me
the procedure of finding the impulse response

```
```Hi Andor,

i wan to do the second one, and can you please help me or just give me
the procedure of finding the impulse response.

Your suggestion would be of great help

Regards,

```
```mailprassi@gmail.com wrote:
> i wan to do the second one, and can you please help me or just give me
> the procedure of finding the impulse response

It's quite an euphemism to say it would be a hassle. If I didn't
misunderstand anything, here's how it should be like

Well, I can think of it in two ways, one simple, one not. The problem
with the first one is that you're supposed to be able to use each
element of your 5.1 system (btw Andor wasn't it a 4.1 system you
described or does the "C" one counts for both a satellite and a bass?)
as a microphone, and since it's unlikely that you can do that, I can
only think of one suitable way to do that.

First, you have to get yourself a microphone, and correct me if i'm
wrong, but I think you need to know its frequency response (you can do
so using a speaker and something that would be used both as a speaker
and as a microphone but it would take a lengthy explanation, well ask
me if you want it). Let's assume you got the impulse response matching
to the mic, and call it hM

Now, you need to choose a signal to use. In order to make things much
simpler, use one with a linear frequency response, like a linear
frequency sweep or a MLS signal.

Now, play and record with your mic this signal being played through
each part of the 5.1 system, deconvolve each with hM and then cross
correlate each. there you got the impulse response for each part. Now
convolve impulse responses together to obtain the impulse response
described by Andor.

Example : hL * hR = hL2R

I only hope I didn't get it wrong. Anyways, I don't think it's worth
the hassle, and I don't even know why you need to know the frequency
response for each speaker in order to do it, if you could explain me
Andor :-)

Alright since I'm really bored I'll explain you how to get hM, the
speaker, and well... i'd go for one speaker with a transformer (to
amplify the sound to decent voltages when using it as a mic). We'll
call the mic M, the speaker S and the speaker with a transformer T.

Play your signal (a linear chirp or MLS signal) throw S, record it with
M and record it with T. Then play your signal through T and record it
with M.

Cross correlate each obtained signal with the original signal, and what
do you got? your first signal is hS * hM, the second one is hS * hT and
the third one is hT * hM

Since what you're looking for is hM, you need to convolve the 1st
signal with the 3rd one, and deconvolve the result with the 2nd. There
you got hM*hM. In order to obtain hM from that, FFT that signal, turn
it into the polar form, sqrt only the magnitude bins, turn back to
rectangular form, IFFT and there you should have your impulse response