I have a audio signal from 1000Hz to 1250Hz with samplerate of 8000Hz. But i want translate the signal to the range: 0-250 Hz. Then i could resampling to 1000Hz, for example, with a low pass filter (antialiasing) with Fc=500Hz. ¿How can i translate frecuency from 1000Hz to 0Hz?

# Frecuency shift and resample

Started by ●September 13, 2009

Reply by ●September 13, 20092009-09-13

>I have a audio signal from 1000Hz to 1250Hz with samplerate of 8000Hz. > >But i want translate the signal to the range: 0-250 Hz. > >Then i could resampling to 1000Hz, for example, with a low pass filter >(antialiasing) with Fc=500Hz. > >¿How can i translate frecuency from 1000Hz to 0Hz? > > >For this case, you can use a method called "integer-band decimation" to reduce the sample rate to 500 Hz. The steps are: 1. Apply a bandpass filter between 1000 and 1250 Hz. 2. Keep every 16th sample of the filter output. (Something to watch out for - if your signal was between 1250 and 1500 Hz for example, a third step would be required: multiply every second sample by -1.) Another option is to demodulate the signal down to 0 Hz (multiply by cos(2 * pi * 1000 * n/ 8000 )), apply a lowpass from 0 to 250 Hz, and then take every 16th sample of the output. I would suggest finding a good book on multirate signal processing, or see what you can find on the web on this subject. Shawn Stevenson DSP and Embedded Systems Engineer info: http://www.linkedin.com/in/sestevenson blog: http://sestevenson.wordpress.com/

Reply by ●September 13, 20092009-09-13

>>I have a audio signal from 1000Hz to 1250Hz with samplerate of 8000Hz. >> >>But i want translate the signal to the range: 0-250 Hz. >> >>Then i could resampling to 1000Hz, for example, with a low pass filter >>(antialiasing) with Fc=500Hz. >> >>¿How can i translate frecuency from 1000Hz to 0Hz? >> >> >> > >For this case, you can use a method called "integer-band decimation" to >reduce the sample rate to 500 Hz. The steps are: >1. Apply a bandpass filter between 1000 and 1250 Hz. >2. Keep every 16th sample of the filter output. > >(Something to watch out for - if your signal was between 1250 and 1500Hz>for example, a third step would be required: multiply every secondsample>by -1.) > >Another option is to demodulate the signal down to 0 Hz (multiply bycos(2>* pi * 1000 * n/ 8000 )), apply a lowpass from 0 to 250 Hz, and thentake>every 16th sample of the output. > >I would suggest finding a good book on multirate signal processing, orsee>what you can find on the web on this subject. > >Shawn Stevenson >DSP and Embedded Systems Engineer >info: http://www.linkedin.com/in/sestevenson >blog: http://sestevenson.wordpress.com/ > >I have done this: Stream input: InputSound.Re (samples sound card) InputSound.Im ( 0 ) Then i multiply by complex exponencial: InputSound.Re = InputSound.Re * Cos(2 * Pi * 1000 * n / 8000) InputSound.Im = InputSound.Re * -Sin(2 * Pi * 1000 * n / 8000) Now, i could apply lowpass filter and decimate (but i have no done decimating yet). And finally, i apply FFT to process the signal. My problem is: With FFT magnitude operations, for example the energy: qrt((FFT(k).re*FFT(k).Re+FFT(k).Im*FFT(k).Im)) i have no problems, and results are the same than without multiply by the complex exponencial and the application run very well. But when i want use phase information, for example: atan((FFT(k).Im / FFT(k).Re)) i have bigs problems. Now phase is always zero, i dont know why. I have seen similars applications and look like that it use a Hilbert Filter before multiply by cos and sin. why ??????????? Also, i could try the first option you have told me: bandpass filter and keep every 16th sample of the filter output, but i dont know what will happen with phase information. ????? I expect yours opinions, thanks

Reply by ●September 14, 20092009-09-14

>I have done this: > >Stream input: InputSound.Re (samples sound card) > InputSound.Im ( 0 ) > >Then i multiply by complex exponencial: > >InputSound.Re = InputSound.Re * Cos(2 * Pi * 1000 * n / 8000) >InputSound.Im = InputSound.Re * -Sin(2 * Pi * 1000 * n / 8000) > >Now, i could apply lowpass filter and decimate (but i have no done >decimating yet). > >And finally, i apply FFT to process the signal. > >My problem is: > >With FFT magnitude operations, for example the energy: >qrt((FFT(k).re*FFT(k).Re+FFT(k).Im*FFT(k).Im)) i have no problems, and >results are the same than without multiply by the complex exponencialand>the application run very well. > >But when i want use phase information, for example: atan((FFT(k).Im / >FFT(k).Re)) i have bigs problems. Now phase is always zero, i dont know >why. > >I have seen similars applications and look like that it use a Hilbert >Filter before multiply by cos and sin. why ??????????? > >Also, i could try the first option you have told me: bandpass filter and >keep every 16th sample of the filter output, but i dont know what will >happen with phase information. ????? > >I expect yours opinions, >thanks > >I think your problem is that you are multiplying by a complex exponential to shift the spectrum instead of by a (real) cosine function. Your original signal (no imaginary part) will have power at -1250 Hz to -1000 Hz and 1000 Hz to 1250 Hz, plus the same pattern repeated at every integer multiple of 8000 Hz (6750 Hz to 7000 Hz and 9000 Hz to 9250 Hz, and on, and on). Once you multiply by the complex exponential and lowpass, the signal components will be at -250 Hz to 0 Hz (and all the replicates at multiples of 8000 Hz). You have ended up with a single-sided spectrum and lost the positive frequencies between 0 and 250 Hz. Are you trying to generate an analytic signal to get phase measurements? Its a bit confusing because it seems like you are trying to do three things at once (spectrum shift, resample, phase measure) but I'm not sure if you really want to do all three. -Shawn

Reply by ●September 14, 20092009-09-14

>Are you trying to generate an analytic signal to get phase measurements?>Its a bit confusing because it seems like you are trying to do threethings>at once (spectrum shift, resample, phase measure) but I'm not sure ifyou>really want to do all three. > >-Shawn > >OK, i will try to explain better. I have a signal from 1000 to 1250 Hz (OFDM carriers). But, because of doppler effect, signal received is from 1003 to 1253Hz. With FFT phase measure i estimate that frecuency desviation is 3Hz. Then i need shift the spectrum by 3 Hz. (Frecuency syncronization is fundamental for my applycation, and 2 or 3 Hz is a important desviation). Next, i estimate frecuency desviation again and so on. Apart from this, i would like work in the range 0-250 hz, instead of 1000-1250Hz. But that is not basic in this moment.

Reply by ●September 15, 20092009-09-15

On Sep 13, 8:33�pm, "JAlbertoDJ" <nietoro...@yahoo.es> wrote:> >>I have a audio signal from 1000Hz to 1250Hz with samplerate of 8000Hz. > > >>But i want translate the signal to the range: 0-250 Hz. > > >>Then i could resampling to 1000Hz, for example, with a low pass filter > >>(antialiasing) with Fc=500Hz. >...> I have done this: > > Stream input: InputSound.Re (samples sound card) > � � � � � � � InputSound.Im ( 0 ) >you need to compute the Hilbert transform (or something approximating it) and stick that into the imaginary part, rather than 0.> Then i multiply by complex exponencial: > > InputSound.Re = InputSound.Re * Cos(2 * Pi * 1000 * n / 8000) > InputSound.Im = InputSound.Re * -Sin(2 * Pi * 1000 * n / 8000) >and with a non-zero imaginary part, there will be cross-product terms that exist in both the real and imaginary part.> Now, i could apply lowpass filter and decimate (but i have no done > decimating yet). >...> I have seen similars applications and look like that it use a Hilbert > Filter before multiply by cos and sin. why ???????????because that's how frequency shifting is done. x(t) --.---->[delay]--------> u(t) = x(t-T) | | | '---->[delayed HT]---> v(t) = Hilbert{ x(t-T) } the frequency-shifted signal is: w(t) = (u(t) + j*v(t))/2 * exp(+j*2*pi*f0*t) + (u(t) - j*v(t))/2 * exp(-j*2*pi*f0*t) where f0 is the positive amount of frequency shift. your f0 would be -1000 Hz. the first term is the positive frequencies being shift by f0 and the second term is the negative frequencies getting shifted by - f0. if you do some very simple fanagalling with the math, you will see that (assuming x(t) is real), the expression above is purely real and equal to w(t) = u(t)* cos(2*pi*f0*t) - v(t)*sin(2*pi*f0*t) note there is no "j" in that expression. but you need to have v(t) and u(t) be a Hilbert pair. it turns out that since you have little or no energy in the bottom 1 kHz or above 1.25 kHz, the computational burden of the needed Hilbert transform will be low. strictly speaking, the Hilbert transformer magnitude frequency response should be pretty flat all the way down to nearly 0 Hz (where it crosses over through the origin), but you can be pretty sloppy with your Hilbert transformer. if you have MATLAB or access to it, you can design a pretty good HT that will have few taps because you can be sloppy with the bottom 1/4 of the frequency spectrum. also, because you're not worried about the top 1000 Hz either, you can take advantage of "half-band symmetry" and every other tap in your HT is zero which will cut the cost in half. but you need a Hilbert transformer that is flat from 1000 Hz to 1250 Hz (not a hard one to do) and then perform the real equation above, and you're shifted and ready to resample. r b-j

Reply by ●September 15, 20092009-09-15

>On Sep 13, 8:33=A0pm, "JAlbertoDJ" <nietoro...@yahoo.es> wrote: >> >>I have a audio signal from 1000Hz to 1250Hz with samplerate of8000Hz.>> >> >>But i want translate the signal to the range: 0-250 Hz. >> >> >>Then i could resampling to 1000Hz, for example, with a low passfilter>> >>(antialiasing) with Fc=3D500Hz. >> >... >> I have done this: >> >> Stream input: InputSound.Re (samples sound card) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 InputSound.Im ( 0 ) >> > >you need to compute the Hilbert transform (or something approximating >it) and stick that into the imaginary part, rather than 0. > >> Then i multiply by complex exponencial: >> >> InputSound.Re =3D InputSound.Re * Cos(2 * Pi * 1000 * n / 8000) >> InputSound.Im =3D InputSound.Re * -Sin(2 * Pi * 1000 * n / 8000) >> > >and with a non-zero imaginary part, there will be cross-product terms >that exist in both the real and imaginary part. > >> Now, i could apply lowpass filter and decimate (but i have no done >> decimating yet). >> >... > >> I have seen similars applications and look like that it use a Hilbert >> Filter before multiply by cos and sin. why ??????????? > >because that's how frequency shifting is done. > > > x(t) --.---->[delay]--------> u(t) =3D x(t-T) > | > | > | > '---->[delayed HT]---> v(t) =3D Hilbert{ x(t-T) } > > >the frequency-shifted signal is: > > > w(t) =3D (u(t) + j*v(t))/2 * exp(+j*2*pi*f0*t) > > + (u(t) - j*v(t))/2 * exp(-j*2*pi*f0*t) > >where f0 is the positive amount of frequency shift. your f0 would be >-1000 Hz. the first term is the positive frequencies being shift by >f0 and the second term is the negative frequencies getting shifted by - >f0. if you do some very simple fanagalling with the math, you will >see that (assuming x(t) is real), the expression above is purely real >and equal to > > > > > w(t) =3D u(t)* cos(2*pi*f0*t) - v(t)*sin(2*pi*f0*t) > >note there is no "j" in that expression. but you need to have v(t) >and u(t) be a Hilbert pair. > >it turns out that since you have little or no energy in the bottom 1 >kHz or above 1.25 kHz, the computational burden of the needed Hilbert >transform will be low. strictly speaking, the Hilbert transformer >magnitude frequency response should be pretty flat all the way down to >nearly 0 Hz (where it crosses over through the origin), but you can be >pretty sloppy with your Hilbert transformer. if you have MATLAB or >access to it, you can design a pretty good HT that will have few taps >because you can be sloppy with the bottom 1/4 of the frequency >spectrum. also, because you're not worried about the top 1000 Hz >either, you can take advantage of "half-band symmetry" and every other >tap in your HT is zero which will cut the cost in half. > >but you need a Hilbert transformer that is flat from 1000 Hz to 1250 >Hz (not a hard one to do) and then perform the real equation above, >and you're shifted and ready to resample. > >r b-j >I am confused because i have seen an application that not use u(t), only he do: w(t)=v(t)*(cos+jsen) Something like this: w(t).Re = v(t).Re * cos(2*pi*f0*t) - v(t).Im * sin(2*pi*f0*t) w(t).Im = v(t).Re * sin(2*pi*f0*t) + v(t).Im * cos(2*pi*f0*t) After, w(t).Re and w(t).Im are inserted in the FFT algorithm. Is this form correct or equivalent?

Reply by ●September 15, 20092009-09-15

On Sep 15, 7:47�am, "JAlbertoDJ" <nietoro...@yahoo.es> wrote:> >On Sep 13, 8:33=A0pm, "JAlbertoDJ" <nietoro...@yahoo.es> wrote: > >> >>I have a audio signal from 1000Hz to 1250Hz with samplerate of > 8000Hz. > > >> >>But i want translate the signal to the range: 0-250 Hz. > > >> >>Then i could resampling to 1000Hz, for example, with a low pass > filter > >> >>(antialiasing) with Fc=3D500Hz. > > >... > >> I have done this: > > >> Stream input: InputSound.Re (samples sound card) > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 InputSound.Im ( 0 ) > > >you need to compute the Hilbert transform (or something approximating > >it) and stick that into the imaginary part, rather than 0. > > >> Then i multiply by complex exponencial: > > >> InputSound.Re =3D InputSound.Re * Cos(2 * Pi * 1000 * n / 8000) > >> InputSound.Im =3D InputSound.Re * -Sin(2 * Pi * 1000 * n / 8000) > > >and with a non-zero imaginary part, there will be cross-product terms > >that exist in both the real and imaginary part. > > >> Now, i could apply lowpass filter and decimate (but i have no done > >> decimating yet). > > >... > > >> I have seen similars applications and look like that it use a Hilbert > >> Filter before multiply by cos and sin. why ??????????? > > >because that's how frequency shifting is done. > > > � x(t) --.---->[delay]--------> u(t) =3D x(t-T) > > � � � � �| > > � � � � �| > > � � � � �| > > � � � � �'---->[delayed HT]---> v(t) =3D Hilbert{ x(t-T) } > > >the frequency-shifted signal is: > > > � �w(t) =3D (u(t) + j*v(t))/2 * exp(+j*2*pi*f0*t) > > > � � � � � �+ (u(t) - j*v(t))/2 * exp(-j*2*pi*f0*t) > > >where f0 is the positive amount of frequency shift. �your f0 would be > >-1000 Hz. �the first term is the positive frequencies being shift by > >f0 and the second term is the negative frequencies getting shifted by - > >f0. �if you do some very simple fanagalling with the math, you will > >see that (assuming x(t) is real), the expression above is purely real > >and equal to > > > � �w(t) =3D u(t)* cos(2*pi*f0*t) - v(t)*sin(2*pi*f0*t) > > >note there is no "j" in that expression. �but you need to have v(t) > >and u(t) be a Hilbert pair. > > >it turns out that since you have little or no energy in the bottom 1 > >kHz or above 1.25 kHz, the computational burden of the needed Hilbert > >transform will be low. �strictly speaking, the Hilbert transformer > >magnitude frequency response should be pretty flat all the way down to > >nearly 0 Hz (where it crosses over through the origin), but you can be > >pretty sloppy with your Hilbert transformer. �if you have MATLAB or > >access to it, you can design a pretty good HT that will have few taps > >because you can be sloppy with the bottom 1/4 of the frequency > >spectrum. �also, because you're not worried about the top 1000 Hz > >either, you can take advantage of "half-band symmetry" and every other > >tap in your HT is zero which will cut the cost in half. > > >but you need a Hilbert transformer that is flat from 1000 Hz to 1250 > >Hz (not a hard one to do) and then perform the real equation above, > >and you're shifted and ready to resample. > > >r b-j > > I am confused because i have seen an application that not use u(t), only > he do: > � � � � � � � � � � � � �w(t)=v(t)*(cos+jsen) > > � Something like this: > > � � w(t).Re = v(t).Re * cos(2*pi*f0*t) - v(t).Im * sin(2*pi*f0*t) > � � w(t).Im = v(t).Re * sin(2*pi*f0*t) + v(t).Im * cos(2*pi*f0*t) > > �After, w(t).Re and w(t).Im are inserted in the FFT algorithm. > > �Is this form correct or equivalent?it's not equivalent. your form above deals only with shifting the spectrum, both positive and negative frequencies in one direction (and leaves a complex result, you need a real result). my form splits the positive and negative frequency halves, moves on up by f0 and the other down by f0. r b-j

Reply by ●September 15, 20092009-09-15

> >it's not equivalent. your form above deals only with shifting the >spectrum, both positive and negative frequencies in one direction (and >leaves a complex result, you need a real result). my form splits the >positive and negative frequency halves, moves on up by f0 and the >other down by f0. > >r b-j > >OK, it's true. I am seeing it is done like you are described because he does two channels, one in phase and the other in quadrature (Hilbert). After he multiply by (cos+jsen). I have run it and now the Automatic Frecuency Control converge very well. Before, with my method did not converge. Thank you very much.

Reply by ●September 16, 20092009-09-16

On Sep 15, 7:54�pm, "JAlbertoDJ" <nietoro...@yahoo.es> wrote:> >it's not equivalent. �your form above deals only with shifting the > >spectrum, both positive and negative frequencies in one direction (and > >leaves a complex result, you need a real result). �my form splits the > >positive and negative frequency halves, moves one up by f0 and the > >other down by f0. > > > OK, it's true. I am seeing it is done like you are described because he > does two channels, one in phase and the other in quadrature (Hilbert). > After he multiply by (cos+jsen). > > I have run it and now the Automatic Frecuency Control converge very well. > Before, with my method did not converge. > > Thank you very much.cool. how're you doing your Hilbert Transform? a simple FIR? and you're delaying your in-phase signal by the same amount of delay you have in your causal HT? just curious. r b-j