Bob Cain <arcane@arcanemethods.com> writes:> Maurice Givens wrote: > > > y = y(:); > > F = F(:); > > > > > > Thanks, Maurice. What do the above two lines do?If it's matlab, they turn y and F into column vectors. e.g. if y is N x M, then y(:) is NM x 1. Ciao, Peter K. -- Peter J. Kootsookos "I will ignore all ideas for new works [..], the invention of which has reached its limits and for whose improvement I see no further hope." - Julius Frontinus, c. AD 84
Simple question regarding frequency detection
Started by ●February 20, 2004
Reply by ●February 22, 20042004-02-22
Reply by ●February 23, 20042004-02-23
Peter J. Kootsookos wrote:> Bob Cain <arcane@arcanemethods.com> writes: > > >>Maurice Givens wrote: >> >> >>>y = y(:); >>>F = F(:); >>> >>> >> >>Thanks, Maurice. What do the above two lines do? > > > If it's matlab, they turn y and F into column vectors. e.g. if y is > N x M, then y(:) is NM x 1.Ah, what APL calls the ravel operation. I've wondered for years how to do that in Matlab and was sorta hoping that's what it meant when I saw it. Thanks, Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein
Reply by ●February 23, 20042004-02-23
Atri Mandal <mandala@ics.uci.edu> wrote in message news:<40381039.7751AD38@ics.uci.edu>...> Hi Maurice, > Thanks for the code for Goertzel algorithm. It's amazing !!!! > But I could not make out why this algo should work .. if you have time > can you please give me a brief explanation as to how this thing works ? > > Thanks, > Atri. > >It's based on the computation of the kth coefficient of the DFT using a 2nd-order filter. I suggest a Google search. Mauricxe Givens
Reply by ●February 23, 20042004-02-23
It wasn't clear in the original post if Atri was trying to detect any signal which contains some energy at 4.5KHz or a signal which is contains only (or mostly) energy at 4.5 KHz. A lot of music (and perhaps some speech) will contain some energy at 4.5Khz, even loud white noise will contain energy at 4.5KHz, if you are trying to detect a signal that is mostly or entirely a 4.5KHz tone and nothing else you will also need to observe the energy in the rest of the spectra. The goertzl algorithm is an excellent choice for this problem, but the detection logic may need to use similar things done in the DTMF decoders in order to not be fooled by normal signals encountered. A simple approach is to compare the energy of the goertzl output to the energy of the entire signal. In a signal that is mostly a tone, these will be similar. -Shawn Steenhagen "Maurice Givens" <maurice.givens@ieee.org> wrote in message news:eb93cce8.0402200828.3529a9fd@posting.google.com...> Atri Mandal <mandala@ics.uci.edu> wrote in messagenews:<40359D7A.12B15FED@ics.uci.edu>...> > Hi, > > I am writing an application to detect a particular frequency(viz. 4.5 > > Khz) in an input audio signal. I have written the code to capture the > > sound using a microphone; but I have to properly design a digital filter > > which will return TRUE as soon as it detects sound of this frequency in > > the input signal. Also my project demands that I have to detect the > > signal by looking at a very small number of samples e.g. 44. So I will > > apply the digital filter on a window of 44 samples of the input signal > > repeatedly till I get a high response indicating that I have got the > > reqd. frequency. > > > > I know DFT/FFT is an option but are there any better algorithms I can > > use for my project. Please suggest the best algorithm that will do my > > work. I am writing the code in C++ so if anyone can point me to existing > > code on the net that will be really helpful. > > > > Thanks, > > Atri. > > > Here is Matlab code for the Goertzel algm if you just need a > TRUE/FLASE indication. Set a threshold, and if y is greater than the > threshold, then the frequency is detected. > > x = input vector > f = frequency desired > N = number of samples to test over > Fs = sample frequency > > function y = goert(x,f,N,Fs) > > k = fix(0.5 + N*f/Fs); > w = (2*pi/N)*k; > coeff = 2 * cos(w); > Q1 = 0; > Q2 = 0; > for j = 1:N > Q0 = coeff * Q1 - Q2 + x(j); > Q2 = Q1; > Q1 = Q0; > end > y = sqrt(Q1^2 + Q2^2 - Q1 * Q2 * coeff); > > > > Here is code to test the alghm. Plot F aganist y to see the detector > output as a function of frequency. > > fdet is the frequency desired > N = number of samples to test over > Fs = sample frequency > > > function [F,y] = testgoert(fdet,N,Fs) > > t = 0:1/Fs:((1/Fs)*N - (1/Fs)); > k = 1; > for f = fix(fdet/2:(fdet/2)/15:fdet*2) > x = sin(2*pi*f*t); > y(k) = goert(x,fdet,N,Fs); > F(k) = f; > k = k + 1; > end > y = y(:); > F = F(:); > > > Maurice Givens