Changeset 8c3f717 for src/pitch


Ignore:
Timestamp:
Apr 10, 2013, 6:43:02 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
e8bc8e9
Parents:
2693655
Message:

src/pitch/pitch.{c,h}: add silence gate, default at -50dB

Location:
src/pitch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    r2693655 r8c3f717  
    3636#include "pitch/pitch.h"
    3737
     38#define DEFAULT_PITCH_SILENCE -50.
     39
    3840/** pitch detection algorithms */
    3941typedef enum
     
    8385  aubio_pitch_convert_t conv_cb;  /**< callback to convert it to the desired unit */
    8486  aubio_pitch_get_conf_t conf_cb; /**< pointer to the current confidence callback */
     87  smpl_t silence;                 /**< silence threshold */
    8588};
    8689
     
    131134  aubio_pitch_set_unit (p, "default");
    132135  p->bufsize = bufsize;
     136  p->silence = DEFAULT_PITCH_SILENCE;
    133137  p->conf_cb = NULL;
    134138  switch (p->type) {
     
    281285}
    282286
     287uint_t
     288aubio_pitch_set_silence (aubio_pitch_t * p, smpl_t silence)
     289{
     290  if (silence < 0 && silence > -200) {
     291    p->silence = silence;
     292    return AUBIO_OK;
     293  } else {
     294    AUBIO_ERR("pitch: could do set silence to %.2f", silence);
     295    return AUBIO_FAIL;
     296  }
     297}
     298
     299smpl_t
     300aubio_pitch_get_silence (aubio_pitch_t * p)
     301{
     302  return p->silence;
     303}
     304
    283305
    284306/* do method, calling the detection callback, then the conversion callback */
     
    287309{
    288310  p->detect_cb (p, ibuf, obuf);
     311  if (aubio_silence_detection(ibuf, p->silence) == 1) {
     312    obuf->data[0] = 0.;
     313  }
    289314  obuf->data[0] = p->conv_cb (obuf->data[0], p->samplerate, p->bufsize);
    290315}
  • src/pitch/pitch.h

    r2693655 r8c3f717  
    8383uint_t aubio_pitch_set_unit (aubio_pitch_t * o, char_t * mode);
    8484
     85/** set the silence threshold of the pitch detection object
     86
     87  \param o pitch detection object as returned by new_aubio_pitch()
     88  \param silence level threshold under which pitch should be ignored, in dB
     89
     90*/
     91uint_t aubio_pitch_set_silence (aubio_pitch_t * o, smpl_t silence);
     92
     93/** set the silence threshold of the pitch detection object
     94
     95  \param o pitch detection object as returned by new_aubio_pitch()
     96
     97  \param return level threshold under which pitch should be ignored, in dB
     98
     99*/
     100smpl_t aubio_pitch_get_silence (aubio_pitch_t * o);
     101
    85102/** get the current confidence
    86103
Note: See TracChangeset for help on using the changeset viewer.