[SciPy-User] finding frequency of wav
David Baddeley
david_baddeley at yahoo.com.au
Thu May 27 17:12:12 EDT 2010
Hi Linda,
I probably wouldn't divide the signal up into chunks before procesing, and also suspect that the FFT might be the wrong tool for the job (I'd certainly take the fft of the whole signal just to check that you have the right frequencies in it though).
The problem with dividing into chunks and processing each separately is that you don't necessarily know where each bit start and stops - your chunks are thus, more likely than not, going to be misaligned.
I'd probably tackle the problem with a strategy directly analogous to that used in analogue circuitry for decoding PSK - I'd either mix the carrier out & do I-Q detection (multiply with a complex exponential and then look at the low pass filtered real & imaginary parts of the result), or just look for the two frequency components separately by multiplying with a complex exponential at each frequency & low pass filtering the amplitude (I'd probably use a boxcar filter the same length as your symbols/frames).
After doing this you can then start to decide where your frame boundaries are. If you've filtered as described, you should just be able to start at some offset and then take every 18th value.
hope this gives you some ideas,
David
________________________________
From: Linda <linda.polman at gmail.com>
To: SciPy Users List <scipy-user at scipy.org>
Sent: Fri, 28 May, 2010 2:42:05 AM
Subject: Re: [SciPy-User] finding frequency of wav
Thanks for your reply. The explanation on fftfreq already made a few puzzle pieces fall into place.
The signal I am trying to decode is a DSC transmission that is recorded in a wav file. (Digital Selective Calling, used in marine radio)
It is a phase modulated digital signal: '1' is 2100Hz, '0' is 1300 Hz and there's a carrier at 1700Hz. That should be all frequencies involved (apart from noise). Currently I am used generated, clean signals. But probably I should get a clean '10101010'-signal first to try my work on.
Since the bitrate is set at 1200bits/sec, the bit length would be samplerate/1200 = 18.4 samples at 22050.
I can double the samplerate to 44100, but that still leaves me at only 36.8 samples per chunk.
If I understand what you say correctly, I would need at least 55 (64) samples in each chunk?
I'm not sure what chunk[3] would have been, I should have used a dotting-signal instead of an unknown message to try this on. I will try this again with more useful data this afternoon.
cheers,
Linda
On Thu, May 27, 2010 at 15:28, Fabrice Silva <silva at lma.cnrs-mrs.fr> wrote:
Le jeudi 27 mai 2010 à 10:09 +0200, Linda a écrit :
>
>> Hello all,
>
>>> I have a digital signal where the bits in it are encoded with
>>> frequencies 1300 and 2100 Hz. The message is sent as a wav-file with a
>>> samplerate of 22050.
>>> My goal is to find the bits again so I can decode the message in it,
>>> for that I have chopped the wav up in pieces of 18 samples, which
>>> would be the bitlength (at 1200 Bit/s > 22050/1200=18.375). So I have
>>> a list of chunks of length 18. I thought I could just fft each chunks
>>> and find the max of the chunk-spectrum, to find out the bitfrequency
>>> in the chunk (and thus the bitvalue)
>
>Correct me if I am wrong. You are cutting your signal into chunks that
>>you expect to contain at least one period of the lower coding frequency.
>>You then perform a fft on a very small signal (18 samples) which gives
>>you (without zero padding) an estimation of the Fourier transform of
>>your chunk computed on only 18 frequencies, i.e. with a really bad
>>frequential resolution. It is possible if your coding frequencies are
>>not too close. A raw Rayleight criteria leads to cut your signal into at
>>least N=2*Fe/df_min where df_min is the minimal spacing between two
>>coding frequencies df_min=2100-1300 here thus N=55 (so 64 to have a
>>power of 2).
>
>>
>>> But somehow I am stuck in the numbers, I was hopeing you could give me
>>> a hint. here is what I have:
>
>>> chunks[3] #this is one of the wavchunks, there should be a bit hidden in here
>>> Out[98]:
>>> array([ 2, -1, 1, -2, 2, -2, 2, -1, 0, 0, 0, 1, -2, 2, -1, 0, 0, 0], dtype=int16)
>>> test = fft(chunks[3]) # spectrum of the chunk, the peak should give me the value of the bitfrequency 1300 of 2100 Hz?
>>> test
>>> Out[100]:
>>> array([ 1.00000000 +0.00000000e+00j, 1.00000000 +2.37564698e-01j,
>>> 1.46791111 +4.90375770e-01j, 2.50000000 +8.66025404e-01j,
>>> 2.65270364 -7.37891832e-01j, 1.00000000 +3.01762603e+00j,
>>> -0.50000000 -2.59807621e+00j, 1.00000000 -2.41609109e+00j,
>>> 4.87938524 +1.43601897e+01j, 7.00000000 -6.88706904e-15j,
>>> 4.87938524 -1.43601897e+01j, 1.00000000 +2.41609109e+00j,
>>> -0.50000000 +2.59807621e+00j, 1.00000000 -3.01762603e+00j,
>>> 2.65270364 +7.37891832e-01j, 2.50000000 -8.66025404e-01j,
>>> 1.46791111 -4.90375770e-01j, 1.00000000 -2.37564698e-01j])
>>>
>>>
>>> I am unsure how to proceed from here, so I would really appreciate any
>>> tips.. I found fftfreq, but I am not sure how to use it? I read
>>> fftfreq? but I don't see how the example even uses the 'fourier'
>>> variable in the fftfreq there?
>>>
>Fftfreq is a function that constructs the frequency vector associated to
>>the data computed by the fft algorithm. It is aware of how fft orders
>>the frequency bins, and transform it in a more convenient way (it
>>'anti-aliases', centering the results on zero frequency).
>
>>import numpy as np
>>import matplotlib.pyplot as plt
>>chunks[3]=....
>>test = np.fft.fft(chunks[3])
>>frequencies = np.fft.fftfreq(len(test), d=1./22050.) # d is the sampling period
>>plt.plot(frequencies, np.abs(test), 'o')
>>plt.show()
>
>>but you won't see any things on this fft. I am suspicious due to the
>>fact that the signal to noise ratio seems rather low leading to strong
>>peak at Fe/2
>>In chunk[3], what do you expect to be the bit?
>
>>Fabricio
>
>>_______________________________________________
>>SciPy-User mailing list
>SciPy-User at scipy.org
>http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100527/9883b761/attachment.html>
More information about the SciPy-User
mailing list