DSPRelated.com
Forums

90 degree phase shift

Started by ingresman June 9, 2006
Hi Guys

Hope you guys can help.

I'm just getting into DSP (indirectly really). I'm trying to create a
quadraphonic SQ decoder in software. To do this I need to shift the
enitre audio range through +90 or -90 degrees. I belive after a lot of
reading and an immense amount of confusion I need a hilbert transform
implemeted via a  FIR filter.
What I've got is is a PCM (.wav) file with loads of samples (I'm sure
you know the numbers) and what I thought would be the way was to
de-scale each sample (by dividing by 32768) to get the original sin
value , add or subtract 90 to this an re-sin it and multiply bt 32768.
It works for 180 shift but for anything else it just gets worse and
worse as i get nearer to 90. Pretty Niave i think now. I tried a simple
delay but I now see that would work only for a single frequncy. (but I
did get a cool reverb program !)
The design of the decoder  splits the .wav file in to 4 seperate .wav
files (left front,left back, right front and right back) which I've
done, and then apply some shifts and then a combine after attenuaing by
.707 (sqrt(2)/2).
I seen loads of posts on this group about this particular  shift
including one from a guy asking exactly the same question.
What I really need is a pointer to how to implement such a filter
prefrably in C without too much trouble or too much theory which is
frankly way being my 1978 O Level (UK 16+ exam). A code sample would be
ideal and greatfully recieved. It does not need to be really fast as
the decoder will work in an offline mode. Once the 4 channels are
produced they will be put through a Dolby DTS encoder to play on a
normal DVD/PC.
So could someone help me please ?
The decoder will be availale for free when produced (it's just a
challenge really) so if you have some old SQ records come and join the
party.
If you need any detals please reply.
Again, I hope some one can help me.
Regards

Kevin

ingresman wrote:
> Hi Guys > > Hope you guys can help. > > I'm just getting into DSP (indirectly really). I'm trying to create a > quadraphonic SQ decoder in software. To do this I need to shift the > enitre audio range through +90 or -90 degrees. I belive after a lot of > reading and an immense amount of confusion I need a hilbert transform > implemeted via a FIR filter.
It will be require a long delay to cover the entire audio band. 90 degrees at 20 Hz is a delay of 12.5 ms; figure that a practical filter will require at least half again as much. Your FIR will need 600 or more taps.
> What I've got is is a PCM (.wav) file with loads of samples (I'm sure > you know the numbers) and what I thought would be the way was to > de-scale each sample (by dividing by 32768) to get the original sin > value , add or subtract 90 to this an re-sin it and multiply bt 32768. > It works for 180 shift but for anything else it just gets worse and > worse as i get nearer to 90. Pretty Niave i think now. I tried a simple > delay but I now see that would work only for a single frequncy. (but I > did get a cool reverb program !)
Wholly inappropriate. The samples exist in time. You want to create a shift in the phase of each frequency that collectively create the waveform. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
ingresman wrote:
> Hi Guys > > Hope you guys can help. > > I'm just getting into DSP (indirectly really). I'm trying to create a > quadraphonic SQ decoder in software. To do this I need to shift the > enitre audio range through +90 or -90 degrees. I belive after a lot of > reading and an immense amount of confusion I need a hilbert transform > implemeted via a FIR filter.
After reading this http://en.wikipedia.org/wiki/Quadraphonic it seems like you are correct: each channel has to be passed through a Hilbert transformer with a frequency range of 20 Hz - 20 kHz. If you denote the input signal by x[n] then the N-th order FIR filter output signal y[n] can be calculated as y[n] = sum_{k=0}^{N} a_k x[n-k], where the a_k are your N+1 Hilbert FIR filter coefficients. The order N is determined by the deviation from the theoretical response that you allow. Jerry's guess of N = 600 sounds sensible. You can get the filter coefficients from a filter design program, or perhaps, if you ask very nicely, somebody here will do it for you if you post the exact specs. Sounds like an awful lot of effort for 3dB channel separation ... :-). Regards, Andor
Andor wrote:
> ingresman wrote: > > Hi Guys > > > > Hope you guys can help. > > > > I'm just getting into DSP (indirectly really). I'm trying to create a > > quadraphonic SQ decoder in software. To do this I need to shift the > > enitre audio range through +90 or -90 degrees. I belive after a lot of > > reading and an immense amount of confusion I need a hilbert transform > > implemeted via a FIR filter. > > After reading this > > http://en.wikipedia.org/wiki/Quadraphonic > > it seems like you are correct: each channel has to be passed through a > Hilbert transformer with a frequency range of 20 Hz - 20 kHz. If you > denote the input signal by x[n] then the N-th order FIR filter output > signal y[n] can be calculated as > > y[n] = sum_{k=0}^{N} a_k x[n-k], > > where the a_k are your N+1 Hilbert FIR filter coefficients. The order N > is determined by the deviation from the theoretical response that you > allow. Jerry's guess of N = 600 sounds sensible. You can get the filter > coefficients from a filter design program, or perhaps, if you ask very > nicely, somebody here will do it for you if you post the exact specs. > > Sounds like an awful lot of effort for 3dB channel separation ... :-). > > Regards, > Andor
If someone could do the coefficients for me that woud be great, please ask away on any question. How do you know 3db of seperation ?? have you any backgroud in quad ??
ingresman wrote:

> Andor wrote: > > ingresman wrote: > > > Hi Guys > > > > > > Hope you guys can help. > > > > > > I'm just getting into DSP (indirectly really). I'm trying to create a > > > quadraphonic SQ decoder in software. To do this I need to shift the > > > enitre audio range through +90 or -90 degrees. I belive after a lot of > > > reading and an immense amount of confusion I need a hilbert transform > > > implemeted via a FIR filter. > > > > After reading this > > > > http://en.wikipedia.org/wiki/Quadraphonic > > > > it seems like you are correct: each channel has to be passed through a > > Hilbert transformer with a frequency range of 20 Hz - 20 kHz. If you > > denote the input signal by x[n] then the N-th order FIR filter output > > signal y[n] can be calculated as > > > > y[n] = sum_{k=0}^{N} a_k x[n-k], > > > > where the a_k are your N+1 Hilbert FIR filter coefficients. The order N > > is determined by the deviation from the theoretical response that you > > allow. Jerry's guess of N = 600 sounds sensible. You can get the filter > > coefficients from a filter design program, or perhaps, if you ask very > > nicely, somebody here will do it for you if you post the exact specs. > > > > Sounds like an awful lot of effort for 3dB channel separation ... :-). > > > > Regards, > > Andor > > If someone could do the coefficients for me that woud be great, please > ask away on any question.
It might be interesting to look at the original encoding circuit, maybe there is a better way (= better inverse filter) than to use the Hilbert transformer.
> How do you know 3db of seperation ?? have you any backgroud in quad ??
I have no quad background, I just read an article about SQ quad (quoting Wikipedia on Quadrophonic): " The early days of SQ were marred by the fact that early SQ decoders couldn't produce more than 3 db of separation from front to back. By the time "Logic" circuits had been introduced to enhance separation, quad had already been considered a failure. "
On 12 Jun 2006 12:33:58 -0700, "ingresman" <ingresman1961@hotmail.co.uk>
wrote:

>If someone could do the coefficients for me that woud be great,
Oppenheim & Shafer: Figure 7.10 (original orange book); Figure 10.6 (later gray book). Greg
Thanks guys I'll track down that book.

As for the encoding Wendy Carlos has a great deal of info on her site.
You might remember switched on Back. The link is
http://www.wendycarlos.com/surround/surround4.html#matrix


Greg Berchin wrote:
> On 12 Jun 2006 12:33:58 -0700, "ingresman" <ingresman1961@hotmail.co.uk> > wrote: > > >If someone could do the coefficients for me that woud be great, > > Oppenheim & Shafer: Figure 7.10 (original orange book); Figure 10.6 > (later gray book). > > Greg
ingresman wrote:
> Thanks guys I'll track down that book.
I just saw an online page which computes the coefficients and the C code for you: http://www-users.cs.york.ac.uk/~fisher/mkfilter/hilbert.html Regards, Andor
Thanks for the link Andor, I found it in an earlier post but to be
honest the hilbert looks a bit odd. It just asks for sample rate and
the impulse length. The sample rate has no impact on the ouput
generated so I'm still a little confused. I've got a really busy
weekend but I'm going to try and fit in some tests. I've also now got a
book (Introductory Digital Signal Processing with Computer Applications
 by Paul A lynn). Looks heavy going but its got code sampes which is
where I'm most cosy with,although putting real samples in looks like it
might need a little work. As I say the challenge is now to understand
the output from the hilbert code, i was expecting the parameters to
contain at least frequency rate.
It was sad to see that the man who did the code passed away some years
ago but york universty have kept his page going.
Anyhow, hopefully I can report back with some positive news soon !
Regards
Kevin


Andor wrote:
> ingresman wrote: > > Thanks guys I'll track down that book. > > I just saw an online page which computes the coefficients and the C > code for you: > > http://www-users.cs.york.ac.uk/~fisher/mkfilter/hilbert.html > > Regards, > Andor
ingresman wrote:
> Thanks for the link Andor, I found it in an earlier post but to be > honest the hilbert looks a bit odd. It just asks for sample rate and > the impulse length. The sample rate has no impact on the ouput > generated so I'm still a little confused. ...
The sample rate is a standard question that is needed for all the filters _but_ the HT. It is there only as a vestige. Put in whatever value will make the frequency axis of output plot "pretty". Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;