Ignore:
Timestamp:
Nov 4, 2009, 10:39:45 PM (15 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:
b9c3cd2
Parents:
554e286
Message:

src/onset/peakpick.c: indent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/onset/peakpick.c

    r554e286 r349e455  
    2929/* peak picking parameters, default values in brackets
    3030 *
    31  *         [<----post----|--pre-->]
    32  *      .................|.............
    33  *      time->           ^now
     31 *     [<----post----|--pre-->]
     32 *  .................|.............
     33 *  time->           ^now
    3434 */
    35 struct _aubio_peakpicker_t {
    36         /** thresh: offset threshold [0.033 or 0.01] */
    37         smpl_t threshold;       
    38         /** win_post: median filter window length (causal part) [8] */
    39         uint_t  win_post;                       
    40         /** pre: median filter window (anti-causal part) [post-1] */
    41         uint_t  win_pre;                               
    42         /** threshfn: name or handle of fn for computing adaptive threshold [median]  */
    43         aubio_thresholdfn_t thresholdfn;
    44         /** picker: name or handle of fn for picking event times [peakpick] */
    45         aubio_pickerfn_t pickerfn;
     35struct _aubio_peakpicker_t
     36{
     37        /** thresh: offset threshold [0.033 or 0.01] */
     38  smpl_t threshold;
     39        /** win_post: median filter window length (causal part) [8] */
     40  uint_t win_post;
     41        /** pre: median filter window (anti-causal part) [post-1] */
     42  uint_t win_pre;
     43        /** threshfn: name or handle of fn for computing adaptive threshold [median]  */
     44  aubio_thresholdfn_t thresholdfn;
     45        /** picker: name or handle of fn for picking event times [peakpick] */
     46  aubio_pickerfn_t pickerfn;
    4647
    47         /** biquad lowpass filter */
    48         aubio_filter_t * biquad;
    49         /** original onsets */
    50         fvec_t * onset_keep;
    51         /** modified onsets */
    52         fvec_t * onset_proc;
    53         /** peak picked window [3] */
    54         fvec_t * onset_peek;
    55         /** scratch pad for biquad and median */
    56         fvec_t * scratch;
     48        /** biquad lowpass filter */
     49  aubio_filter_t *biquad;
     50        /** original onsets */
     51  fvec_t *onset_keep;
     52        /** modified onsets */
     53  fvec_t *onset_proc;
     54        /** peak picked window [3] */
     55  fvec_t *onset_peek;
     56        /** scratch pad for biquad and median */
     57  fvec_t *scratch;
    5758
    5859  /** number of channels to analyse */
    5960  uint_t channels;
    6061
    61         /** \bug should be used to calculate filter coefficients */
    62         /* cutoff: low-pass filter cutoff [0.34, 1] */
    63         /* smpl_t cutoff; */
     62        /** \bug should be used to calculate filter coefficients */
     63  /* cutoff: low-pass filter cutoff [0.34, 1] */
     64  /* smpl_t cutoff; */
    6465
    65         /* not used anymore */
    66         /* time precision [512/44100  winlength/samplerate, fs/buffer_size */
    67         /* smpl_t tau; */
    68         /* alpha: normalisation exponent [9] */
    69         /* smpl_t alpha; */
     66  /* not used anymore */
     67  /* time precision [512/44100  winlength/samplerate, fs/buffer_size */
     68  /* smpl_t tau; */
     69  /* alpha: normalisation exponent [9] */
     70  /* smpl_t alpha; */
    7071};
    7172
     
    124125 * after smoothing
    125126 */
    126 smpl_t aubio_peakpicker_get_thresholded_input(aubio_peakpicker_t * p)
     127smpl_t
     128aubio_peakpicker_get_thresholded_input (aubio_peakpicker_t * p)
    127129{
    128         return p->onset_peek->data[0][1];
     130  return p->onset_peek->data[0][1];
    129131}
    130132
    131 uint_t aubio_peakpicker_set_threshold(aubio_peakpicker_t * p, smpl_t threshold) {
    132     p->threshold = threshold;
    133         return AUBIO_OK;
     133uint_t
     134aubio_peakpicker_set_threshold (aubio_peakpicker_t * p, smpl_t threshold)
     135{
     136  p->threshold = threshold;
     137  return AUBIO_OK;
    134138}
    135139
    136 smpl_t aubio_peakpicker_get_threshold(aubio_peakpicker_t * p) {
    137         return p->threshold;
     140smpl_t
     141aubio_peakpicker_get_threshold (aubio_peakpicker_t * p)
     142{
     143  return p->threshold;
    138144}
    139145
    140 uint_t aubio_peakpicker_set_thresholdfn(aubio_peakpicker_t * p, aubio_thresholdfn_t thresholdfn) {
    141         p->thresholdfn = thresholdfn;
    142         return AUBIO_OK;
     146uint_t
     147aubio_peakpicker_set_thresholdfn (aubio_peakpicker_t * p,
     148    aubio_thresholdfn_t thresholdfn)
     149{
     150  p->thresholdfn = thresholdfn;
     151  return AUBIO_OK;
    143152}
    144153
    145 aubio_thresholdfn_t aubio_peakpicker_get_thresholdfn(aubio_peakpicker_t * p) {
    146         return (aubio_thresholdfn_t) (p->thresholdfn);
     154aubio_thresholdfn_t
     155aubio_peakpicker_get_thresholdfn (aubio_peakpicker_t * p)
     156{
     157  return (aubio_thresholdfn_t) (p->thresholdfn);
    147158}
    148159
    149 aubio_peakpicker_t * new_aubio_peakpicker(uint_t channels) {
    150         aubio_peakpicker_t * t = AUBIO_NEW(aubio_peakpicker_t);
    151         t->threshold = 0.1; /* 0.0668; 0.33; 0.082; 0.033; */
    152         t->win_post  = 5;
    153         t->win_pre   = 1;
     160aubio_peakpicker_t *
     161new_aubio_peakpicker (uint_t channels)
     162{
     163  aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t);
     164  t->threshold = 0.1;           /* 0.0668; 0.33; 0.082; 0.033; */
     165  t->win_post = 5;
     166  t->win_pre = 1;
    154167  //channels = 1;
    155168  t->channels = channels;
    156169
    157         t->thresholdfn = (aubio_thresholdfn_t)(fvec_median_channel); /* (fvec_mean); */
    158         t->pickerfn = (aubio_pickerfn_t)(fvec_peakpick);
     170  t->thresholdfn = (aubio_thresholdfn_t) (fvec_median_channel); /* (fvec_mean); */
     171  t->pickerfn = (aubio_pickerfn_t) (fvec_peakpick);
    159172
    160         t->scratch = new_fvec(t->win_post+t->win_pre+1, channels);
    161         t->onset_keep = new_fvec(t->win_post+t->win_pre+1, channels);
    162         t->onset_proc = new_fvec(t->win_post+t->win_pre+1, channels);
    163         t->onset_peek = new_fvec(3, channels);
     173  t->scratch = new_fvec (t->win_post + t->win_pre + 1, channels);
     174  t->onset_keep = new_fvec (t->win_post + t->win_pre + 1, channels);
     175  t->onset_proc = new_fvec (t->win_post + t->win_pre + 1, channels);
     176  t->onset_peek = new_fvec (3, channels);
    164177
    165         /* cutoff: low-pass filter with cutoff reduced frequency at 0.34
    166    generated with octave butter function: [b,a] = butter(2, 0.34);
     178  /* cutoff: low-pass filter with cutoff reduced frequency at 0.34
     179     generated with octave butter function: [b,a] = butter(2, 0.34);
    167180   */
    168181  t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789,
    169     -0.59488894, 0.23484048, channels);
     182      -0.59488894, 0.23484048, channels);
    170183
    171         return t;
     184  return t;
    172185}
    173186
    174 void del_aubio_peakpicker(aubio_peakpicker_t * p) {
    175         del_aubio_filter(p->biquad);
    176         del_fvec(p->onset_keep);
    177         del_fvec(p->onset_proc);
    178         del_fvec(p->onset_peek);
    179         del_fvec(p->scratch);
    180         AUBIO_FREE(p);
     187void
     188del_aubio_peakpicker (aubio_peakpicker_t * p)
     189{
     190  del_aubio_filter (p->biquad);
     191  del_fvec (p->onset_keep);
     192  del_fvec (p->onset_proc);
     193  del_fvec (p->onset_peek);
     194  del_fvec (p->scratch);
     195  AUBIO_FREE (p);
    181196}
Note: See TracChangeset for help on using the changeset viewer.