Peak-to-peak detection problem

Discussion in 'C++' started by tee_huipeng@yahoo.com.sg, Sep 9, 2007.

  1. Guest

    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
    , Sep 9, 2007
    #1
    1. Advertising

  2. wrote:
    > 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.
    Gianni Mariani, Sep 9, 2007
    #2
    1. Advertising

  3. Guest

    On Sep 9, 4:35 pm, Gianni Mariani <> wrote:
    > wrote:
    > > 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.- 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
    , Sep 9, 2007
    #3
  4. wrote:
    > On Sep 9, 4:35 pm, Gianni Mariani <> wrote:
    >> wrote:

    ....
    > 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 ?
    Gianni Mariani, Sep 9, 2007
    #4
  5. On Sun, 2007-09-09 at 01:53 -0700, wrote:

    > 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.
    Tristan Wibberley, Sep 9, 2007
    #5
  6. 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?
    Gianni Mariani, Sep 9, 2007
    #6
  7. red floyd Guest

    wrote:

    > 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.
    red floyd, Sep 9, 2007
    #7
  8. Guest

    On Sep 9, 9:54 pm, Gianni Mariani <> wrote:
    > 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


    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
    , Sep 10, 2007
    #8
  9. Guest

    On Sep 9, 5:29 pm, Gianni Mariani <> wrote:
    > wrote:
    > > On Sep 9, 4:35 pm, Gianni Mariani <> wrote:
    > >> wrote:

    > ...
    > > 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 ?



    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
    , Sep 11, 2007
    #9
  10. a écrit :
    > On Sep 9, 5:29 pm, Gianni Mariani <> wrote:
    >> wrote:
    >>> On Sep 9, 4:35 pm, Gianni Mariani <> wrote:
    >>>> wrote:

    >> ...
    >>> 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 ?

    >
    >
    > 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
    Michael DOUBEZ, Sep 11, 2007
    #10
  11. wrote:
    > On Sep 9, 5:29 pm, Gianni Mariani <> wrote:
    >> wrote:
    >>> On Sep 9, 4:35 pm, Gianni Mariani <> wrote:
    >>>> wrote:

    >> ...
    >>> 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 ?

    >
    >
    > 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.
    Gianni Mariani, Sep 11, 2007
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alessandro Crugnola *sephiroth*

    peak levels from mp3

    Alessandro Crugnola *sephiroth*, Feb 21, 2004, in forum: Python
    Replies:
    0
    Views:
    275
    Alessandro Crugnola *sephiroth*
    Feb 21, 2004
  2. Using Parts of PEAK

    , Apr 27, 2006, in forum: Python
    Replies:
    1
    Views:
    249
    Ben Finney
    Apr 28, 2006
  3. Xiangliang Meng
    Replies:
    3
    Views:
    270
    Default User
    Jul 13, 2004
  4. Replies:
    1
    Views:
    778
    Michael DOUBEZ
    Sep 17, 2007
  5. Tzury Bar Yochay

    To PEAK or not to PEAK

    Tzury Bar Yochay, Feb 24, 2008, in forum: Python
    Replies:
    1
    Views:
    263
Loading...

Share This Page