Peak-to-peak detection problem

T

tee_huipeng

Hi:

i need to detect peak-to-peak signal in a sound waveform. The
waveform is periodic. When the microphone collects the sound waveform
which will be digitised at sampling rate 20KHz and kept in an array of
samples.

My purpose is to get the time length between the two successive peaks
by using command like: if...else, for....etc. i need the algorithm
work on the waveform.

i try to figure out an algorithm in order to get the two successive
peaks' period, but i just fail to do it.

Can anyone show me the algorithm that maybe useful or just give me
some hint to continue my work.

Thanks in advance.

D'nise
 
G

Gianni Mariani

Hi:

i need to detect peak-to-peak signal in a sound waveform. The
waveform is periodic. When the microphone collects the sound waveform
which will be digitised at sampling rate 20KHz and kept in an array of
samples.

My purpose is to get the time length between the two successive peaks
by using command like: if...else, for....etc. i need the algorithm
work on the waveform.

i try to figure out an algorithm in order to get the two successive
peaks' period, but i just fail to do it.

Can anyone show me the algorithm that maybe useful or just give me
some hint to continue my work.

This is not a C++ problem and so would be off-topic here. This is a
digital signal processing problem so you'll get much better answers from
a DSP related group.

One hint for you is derivatives. Peaks happen when the derivative is
zero. The other hint is noise. If your signal has noise, you will get
false readings unless you filter your input.

Since it's been a very long time since the last time I did any real DSP
work I'm not really qualified to say much more than that.
 
T

tee_huipeng

This is not a C++ problem and so would be off-topic here. This is a
digital signal processing problem so you'll get much better answers from
a DSP related group.

One hint for you is derivatives. Peaks happen when the derivative is
zero. The other hint is noise. If your signal has noise, you will get
false readings unless you filter your input.

Since it's been a very long time since the last time I did any real DSP
work I'm not really qualified to say much more than that.- Hide quoted text -

- Show quoted text -

How if i change my question into this way...

for a digitised sinusoidal waveform, without noise, just one pure
sinusoid, how can i detect the two successive peaks's period by using
if...else, for, while,....etc...these simple command?

thank you.

D'nise
 
G

Gianni Mariani

....
for a digitised sinusoidal waveform, without noise, just one pure
sinusoid, how can i detect the two successive peaks's period by using
if...else, for, while,....etc...these simple command?

Compute the derivative and where the derivative crosses zero, you have a
minimum or maximum.

So, what does your API look like ?
 
T

Tristan Wibberley

How if i change my question into this way...

for a digitised sinusoidal waveform, without noise, just one pure
sinusoid, how can i detect the two successive peaks's period by using
if...else, for, while,....etc...these simple command?

If it is digitised you will not have a pure sinusoid so depending on how
accurately you sample it and how precisely you store your samples the
method you choose to detect the peaks may or may not work. C++ usage
advice cannot help you at this early stage of your solution and you need
help from signal processing gurus.

C++ usage advice can only help you with how to implement your chosen
algorithm using C++ since C++ doesn't have an algorithm built in to do
what you want.

Hint though: Logically, you have a hypothesis for what the signal looks
like (sinusoid) and you want to test that hypothesis for a variety of
wavelengths until you can spot the most likely match. There happens to
be a standard technique for doing this very rapidly on a computer and it
is called an fft.

--
Tristan Wibberley

Any opinion expressed is mine (or else I'm playing devils advocate for
the sake of a good argument). My employer had nothing to do with this
communication.
 
G

Gianni Mariani

Tristan Wibberley wrote:
....
Hint though: Logically, you have a hypothesis for what the signal looks
like (sinusoid) and you want to test that hypothesis for a variety of
wavelengths until you can spot the most likely match. There happens to
be a standard technique for doing this very rapidly on a computer and it
is called an fft.

FFT might be a bit of overkill though. But it's a good idea to check
the spectrum.

I posted some FFT code a while back.
http://groups.google.com/group/comp.lang.c++/msg/49bed9ef02f1ec9f?
 
R

red floyd

How if i change my question into this way...

for a digitised sinusoidal waveform, without noise, just one pure
sinusoid, how can i detect the two successive peaks's period by using
if...else, for, while,....etc...these simple command?


Still OT.

Ask yourself the following question:

"Would the answer be essentially the same if I used a different language?"

If so, then you're OT here.
 
T

tee_huipeng

Tristan Wibberley wrote:

...


FFT might be a bit of overkill though. But it's a good idea to check
the spectrum.

I posted some FFT code a while back.http://groups.google.com/group/comp.lang.c++/msg/49bed9ef02f1ec9f

Appreciation is expressed to those gave me the suggestion.. Give me
some times to digest and figure it out what would be the best
solution..and i will come back here again.

i think i should process my signal first by using certain algorithm
maybe autocorrelation, FFT, cepstral analysis and so on, then only can
i find my desired two successive peaks' period.

Thank you so much.

D'nise
 
T

tee_huipeng

Compute the derivative and where the derivative crosses zero, you have a
minimum or maximum.

So, what does your API look like ?


Hi:

im back. after discussing with my lecturer, i think i'll start from
the most simple and basic way to start doing my project which is just
do analysis on my raw signal waveform without doing any signal
processing firs, since im new in every related field: C++, VC++ and
sound waveform.

so can u go to this website to see what is my waveform look like?
http://www.voiceandspeechsystems.com/voiceaware.html

under the "visual representation of voice" u can see a sound waveform
there. i repeat my question again which is i m trying to look for the
period(number of samples) between two successive peaks.

do u think the derivative methods u suggested before is still work for
this waveform? if so, can u elaborate more about the derivative
method.
what would be the equivalent C++ command for derivatives. For example,
to find sum, i can use 'for' loop. So how about derivative?

i tried to figure out some methods to find the period, but it seem
like can't work properly!

so, can u help by giving more explaination and also ur opinion?

Thank you so much... so much.. for your guidance..sincerely..

D'nise
 
M

Michael DOUBEZ

(e-mail address removed) a écrit :
Hi:

im back. after discussing with my lecturer, i think i'll start from
the most simple and basic way to start doing my project which is just
do analysis on my raw signal waveform without doing any signal
processing firs, since im new in every related field: C++, VC++ and
sound waveform.

so can u go to this website to see what is my waveform look like?
http://www.voiceandspeechsystems.com/voiceaware.html

Concerning voice, I suggest the "Roy Hart Center" in Mallerargues
(FRANCE). It is really great.
under the "visual representation of voice" u can see a sound waveform
there. i repeat my question again which is i m trying to look for the
period(number of samples) between two successive peaks.

do u think the derivative methods u suggested before is still work for
this waveform? if so, can u elaborate more about the derivative
method.

Google for Fermat's theorem for the mathematical background although
that suppose your signal is derivable.

Another method would be to work in the frequency space (using FFT by
example) and then use mathematic to compute theoretical extremas.
what would be the equivalent C++ command for derivatives. For example,
to find sum, i can use 'for' loop. So how about derivative?

This has nothing to do with C++. It is a pure numerical analysis issue.
i tried to figure out some methods to find the period, but it seem
like can't work properly!

Finding the period is another issue, related to pattern matching but
here again fourrier transforms may help. Ask in the relevant group.

so, can u help by giving more explaination and also ur opinion?

You are welcome and my advice is to ask in a group specialised in DSP or
numerical analysis.

C++ may not be your best choice I you want to experiment algorithm ;
perhaps Matlab (or SciLab) would be better for exploring the field.

Michael
 
G

Gianni Mariani

Hi:

im back. after discussing with my lecturer, i think i'll start from
the most simple and basic way to start doing my project which is just
do analysis on my raw signal waveform without doing any signal
processing firs, since im new in every related field: C++, VC++ and
sound waveform.

so can u go to this website to see what is my waveform look like?
http://www.voiceandspeechsystems.com/voiceaware.html

under the "visual representation of voice" u can see a sound waveform
there. i repeat my question again which is i m trying to look for the
period(number of samples) between two successive peaks.

do u think the derivative methods u suggested before is still work for
this waveform? if so, can u elaborate more about the derivative
method.
what would be the equivalent C++ command for derivatives. For example,
to find sum, i can use 'for' loop. So how about derivative?

Derivative is a "rate of change". The most simplistic method is
subtracting successive sample (S-S[i-1]). When it crosses zero (goes
from a positive to a negative or a negative to a positive, you will find
a local maximum or minimum respectively). Since your input is not
sinusoidal, you'll have to do some more work to match peaks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top