Changeset f1b6aad


Ignore:
Timestamp:
Oct 16, 2009, 4:02:01 AM (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:
6338636
Parents:
28c162c
Message:

src/spectral/tss.c: simplify new_ method, add setters for threshold, alpha, and beta

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/puredata/aubiotss~.c

    r28c162c rf1b6aad  
    2121        t_object x_obj;
    2222        t_float thres; 
    23         t_float alpha; 
    24         t_float beta;   
    2523        t_int pos; /*frames%dspblocksize*/
    2624        t_int bufsize;
     
    5553                        //if (!aubio_silence_detection(x->vec, x->threshold2))
    5654                        aubio_pvoc_do  (x->pv,  x->vec, x->fftgrain);
    57                         aubio_tss_set_thres( x->tss, x->thres);
     55                        aubio_tss_set_threshold ( x->tss, x->thres);
    5856                        aubio_tss_do   (x->tss, x->fftgrain, x->ctrans, x->cstead);
    5957                        aubio_pvoc_rdo (x->pvt, x->ctrans, x->trans);
     
    9492        x->bufsize  = 1024; //(bufsize < 64) ? 1024: (bufsize > 16385) ? 16385: bufsize;
    9593        x->hopsize  = x->bufsize / 4;
    96         x->alpha    = 3.;
    97         x->beta     = 4.;
    9894
    9995        x->vec = (fvec_t *)new_fvec(x->hopsize,1);
     
    110106        x->pvs = (aubio_pvoc_t *)new_aubio_pvoc(x->bufsize, x->hopsize, 1);
    111107
    112         x->tss = (aubio_tss_t *)new_aubio_tss(x->thres, x->alpha, x->beta,
    113                         x->bufsize, x->hopsize, 1);
     108        x->tss = (aubio_tss_t *)new_aubio_tss(x->bufsize, x->hopsize, 1);
    114109
    115110        floatinlet_new (&x->x_obj, &x->thres);
  • src/spectral/tss.c

    r28c162c rf1b6aad  
    1818*/
    1919
    20 /* default values : alfa=4, beta=3, threshold=0.25 */
     20/* default values : alpha=4, beta=3, threshold=0.25 */
    2121
    2222#include "aubio_priv.h"
     
    2626#include "spectral/tss.h"
    2727
    28 struct _aubio_tss_t 
     28struct _aubio_tss_t
    2929{
    30   smpl_t thrs;
    31   smpl_t alfa;
     30  smpl_t threshold;
     31  smpl_t alpha;
    3232  smpl_t beta;
    3333  smpl_t parm;
     
    4444{
    4545  uint_t i,j;
    46   uint_t test; 
     46  uint_t test;
    4747  uint_t nbins     = input->length;
    4848  uint_t channels  = input->channels;
    49   smpl_t alfa      = o->alfa;
     49  smpl_t alpha     = o->alpha;
    5050  smpl_t beta      = o->beta;
    5151  smpl_t parm      = o->parm;
     
    8383      oft2[i][j]  = test;
    8484      test = (trans->norm[i][j]>0.);
    85       oft1[i][j] += alfa*test;
     85      oft1[i][j] += alpha*test;
    8686      test = (stead->norm[i][j]>0.);
    87       oft2[i][j] += alfa*test;
     87      oft2[i][j] += alpha*test;
    8888      test = (oft1[i][j]>1. && trans->norm[i][j]>0.);
    8989      oft1[i][j] += beta*test;
     
    9494}
    9595
    96 void aubio_tss_set_thres(aubio_tss_t *o, smpl_t thrs){
    97         o->thrs = thrs;
    98         o->parm = thrs*o->thrsfact;
     96uint_t aubio_tss_set_threshold(aubio_tss_t *o, smpl_t threshold){
     97  o->threshold = threshold;
     98  o->parm = o->threshold * o->thrsfact;
     99  return AUBIO_OK;
    99100}
    100101
    101 aubio_tss_t * new_aubio_tss(smpl_t thrs, smpl_t alfa, smpl_t beta,
    102     uint_t size, uint_t overlap,uint_t channels)
     102aubio_tss_t * new_aubio_tss(uint_t buf_size, uint_t hop_size, uint_t channels)
    103103{
    104104  aubio_tss_t * o = AUBIO_NEW(aubio_tss_t);
    105   uint_t rsize = size/2+1;
    106   o->thrs = thrs;
    107   o->thrsfact = TWO_PI*overlap/rsize;
    108   o->alfa = alfa;       
    109   o->beta = beta;       
    110   o->parm = thrs*o->thrsfact;
     105  uint_t rsize = buf_size/2+1;
     106  o->threshold = 0.25;
     107  o->thrsfact = TWO_PI*hop_size/rsize;
     108  o->alpha = 3.;
     109  o->beta = 4.;
     110  o->parm = o->threshold*o->thrsfact;
    111111  o->theta1 = new_fvec(rsize,channels);
    112112  o->theta2 = new_fvec(rsize,channels);
     
    127127}
    128128
     129uint_t aubio_tss_set_alpha(aubio_tss_t *o, smpl_t alpha){
     130  o->alpha = alpha;
     131  return AUBIO_OK;
     132}
     133
     134uint_t aubio_tss_set_beta(aubio_tss_t *o, smpl_t beta){
     135  o->beta = beta;
     136  return AUBIO_OK;
     137}
     138
  • src/spectral/tss.h

    r28c162c rf1b6aad  
    2828  transient information in musical audio using multiresolution analysis
    2929  techniques. In Proceedings of the Digital Audio Effects Conference, DAFx-01,
    30   pages 1­5, Limerick, Ireland, 2001.
     30  pages 1--5, Limerick, Ireland, 2001.
     31
     32  Available at http://www.csis.ul.ie/dafx01/proceedings/papers/duxbury.pdf
    3133
    3234*/
     
    3941#endif
    4042
    41 /** TSS object */
     43/** Transient / Steady-state Separation object */
    4244typedef struct _aubio_tss_t aubio_tss_t;
    4345
    4446/** create tss object
    4547
    46   \param thrs separation threshold
    47   \param alfa alfa parameter
    48   \param beta beta parameter
    49   \param size buffer size
    50   \param overlap step size
     48  \param win_s buffer size
     49  \param hop_s step size
    5150  \param channels number of input channels
    5251
    5352*/
    54 aubio_tss_t * new_aubio_tss(smpl_t thrs, smpl_t alfa, smpl_t beta,
    55     uint_t win_s, uint_t hop_s, uint_t channels);
     53aubio_tss_t *new_aubio_tss (uint_t win_s, uint_t hop_s, uint_t channels);
     54
    5655/** delete tss object
    5756
    58   \param s tss object as returned by new_aubio_tss
     57  \param o tss object as returned by new_aubio_tss()
    5958
    6059*/
    61 void del_aubio_tss(aubio_tss_t *s);
     60void del_aubio_tss (aubio_tss_t * o);
    6261
    63 /** set transient / steady state separation threshold
    64  
    65   \param tss tss object as returned by new_aubio_tss
    66   \param thrs new threshold value
    67 
    68 */
    69 void aubio_tss_set_thres(aubio_tss_t *tss, smpl_t thrs);
    7062/** split input into transient and steady states components
    7163 
    72   \param s tss object as returned by new_aubio_tss
     64  \param o tss object as returned by new_aubio_tss()
    7365  \param input input spectral frame
    7466  \param trans output transient components
     
    7668
    7769*/
    78 void aubio_tss_do(aubio_tss_t *s, cvec_t * input, cvec_t * trans, cvec_t * stead);
     70void aubio_tss_do (aubio_tss_t * o, cvec_t * input, cvec_t * trans,
     71    cvec_t * stead);
     72
     73/** set transient / steady state separation threshold
     74 
     75  \param o tss object as returned by new_aubio_tss()
     76  \param thrs new threshold value
     77
     78*/
     79uint_t aubio_tss_set_threshold (aubio_tss_t * o, smpl_t thrs);
     80
     81/** set parameter a, defaults to 3
     82 
     83  \param o tss object as returned by new_aubio_tss()
     84  \param alpha new value for alpha parameter
     85
     86*/
     87uint_t aubio_tss_set_alpha (aubio_tss_t * o, smpl_t alpha);
     88
     89/** set parameter b, defaults to 3
     90 
     91  \param o tss object as returned by new_aubio_tss()
     92  \param beta new value for beta parameter
     93
     94*/
     95uint_t aubio_tss_set_beta (aubio_tss_t * o, smpl_t beta);
    7996
    8097#ifdef __cplusplus
  • tests/src/test-tss.c

    r28c162c rf1b6aad  
    2626        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels);
    2727
    28         aubio_tss_t *  tss = new_aubio_tss(0.01,3.,4.,win_s,hop_s,channels);
     28        aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s,channels);
    2929        /* fill input with some data */
    3030        printf("initialised\n");
Note: See TracChangeset for help on using the changeset viewer.