Changes in / [714d05e:bab24a0]


Ignore:
Files:
4 added
2 deleted
73 edited

Legend:

Unmodified
Added
Removed
  • src/aubio.h

    r714d05e rbab24a0  
    160160#include "fmat.h"
    161161#include "musicutils.h"
     162#include "vecutils.h"
    162163#include "temporal/resampler.h"
    163164#include "temporal/filter.h"
     
    171172#include "spectral/mfcc.h"
    172173#include "spectral/specdesc.h"
     174#include "spectral/tss.h"
    173175#include "pitch/pitch.h"
    174176#include "onset/onset.h"
    175 #include "onset/peakpicker.h"
    176177#include "tempo/tempo.h"
    177 #include "io/sndfileio.h"
    178178#include "io/source.h"
     179#include "io/sink.h"
     180
     181#if AUBIO_UNSTABLE
     182#include "mathutils.h"
    179183#include "io/source_sndfile.h"
    180184#include "io/source_apple_audio.h"
    181 #include "io/sink.h"
    182185#include "io/sink_sndfile.h"
    183186#include "io/sink_apple_audio.h"
    184 
    185 #if AUBIO_UNSTABLE
    186 #include "vecutils.h"
    187 #include "mathutils.h"
    188 #include "utils/scale.h"
    189 #include "utils/hist.h"
    190 #include "spectral/tss.h"
     187#include "io/sndfileio.h"
     188#include "onset/peakpicker.h"
    191189#include "pitch/pitchmcomb.h"
    192190#include "pitch/pitchyin.h"
     
    195193#include "pitch/pitchfcomb.h"
    196194#include "tempo/beattracking.h"
     195#include "utils/scale.h"
     196#include "utils/hist.h"
    197197#endif
    198198
  • src/aubio_priv.h

    r714d05e rbab24a0  
    123123#define AUBIO_MSG(format, args...)   fprintf(stdout, format , ##args)
    124124#define AUBIO_DBG(format, args...)   fprintf(stderr, format , ##args)
    125 #define AUBIO_WRN(...)               fprintf(stderr, "AUBIO WARNING: " format, ##args)
     125#define AUBIO_WRN(format, args...)   fprintf(stderr, "AUBIO WARNING: " format, ##args)
    126126#endif
    127127
  • src/cvec.h

    r714d05e rbab24a0  
    2828/** \file
    2929
    30   Complex buffers
     30  Vector of complex-valued data
    3131
    32   This file specifies the cvec_t buffer type, which is used throughout aubio to
    33   store complex data. Complex values are stored in terms of phase and
    34   norm, within size/2+1 long vectors.
     32  This file specifies the ::cvec_t buffer type, which is used throughout aubio
     33  to store complex data. Complex values are stored in terms of ::cvec_t.phas
     34  and norm, within size/2+1 long vectors of ::smpl_t.
     35
     36  \example test-cvec.c
    3537
    3638*/
    3739
    38 /** Buffer for complex data */
     40/** Buffer for complex data
     41
     42  \code
     43
     44  uint_t buffer_size = 1024;
     45
     46  // create a complex vector of 512 values
     47  cvec_t * input = new_cvec (buffer_size);
     48
     49  // set some values of the vector
     50  input->norm[23] = 2.;
     51  input->phas[23] = M_PI;
     52  // ..
     53
     54  // compute the mean of the vector
     55  mean = cvec_mean(input);
     56
     57  // destroy the vector
     58  del_cvec (input);
     59
     60  \endcode
     61
     62 */
    3963typedef struct {
    40   uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
    41   smpl_t *norm;   /**< norm array of size [length] */
    42   smpl_t *phas;   /**< phase array of size [length] */
     64  uint_t length;  /**< length of buffer = (requested length)/2 + 1 */
     65  smpl_t *norm;   /**< norm array of size ::cvec_t.length */
     66  smpl_t *phas;   /**< phase array of size ::cvec_t.length */
    4367} cvec_t;
    4468
     
    4872  [length/2+1], corresponding to the norm and phase values of the
    4973  spectral frame. The length stored in the structure is the actual size of both
    50   arrays, not the length of the complex and symetrical vector, specified as
     74  arrays, not the length of the complex and symmetrical vector, specified as
    5175  creation argument.
    5276
     
    6791  is to access these values from wrappers, as created by swig.
    6892
    69   \param s vector to write to 
     93  \param s vector to write to
    7094  \param data norm value to write in s->norm[position]
    7195  \param position sample position to write to
     
    128152smpl_t * cvec_get_phas(cvec_t *s);
    129153
    130 /** print out cvec data 
     154/** print out cvec data
    131155
    132   \param s vector to print out 
     156  \param s vector to print out
    133157
    134158*/
     
    143167void cvec_set(cvec_t *s, smpl_t val);
    144168
    145 /** set all elements to zero 
     169/** set all elements to zero
    146170
    147171  \param s vector to modify
     
    150174void cvec_zeros(cvec_t *s);
    151175
    152 /** set all elements to ones 
     176/** set all elements to ones
    153177
    154178  \param s vector to modify
  • src/fmat.h

    r714d05e rbab24a0  
    2828/** \file
    2929
    30   Real buffers
     30  Matrix of real valued data
    3131
    32   This file specifies the fmat_t type, which is used in aubio to store real
    33   valued arrays.
     32  This file specifies the fmat_t type, which is used in aubio to store arrays
     33  of floating point values.
     34
     35  \example test-fmat.c
    3436
    3537*/
     
    3739/** Buffer for real data */
    3840typedef struct {
    39   uint_t length;   /**< length of buffer */
    40   uint_t height; /**< number of channels */
    41   smpl_t **data;   /**< data array of size [length] * [channels] */
     41  uint_t length; /**< length of matrix */
     42  uint_t height; /**< height of matrix */
     43  smpl_t **data; /**< data array of size [length] * [height] */
    4244} fmat_t;
    4345
  • src/fvec.h

    r714d05e rbab24a0  
    2828/** \file
    2929
    30   Real buffers
     30  Vector of real-valued data
    3131
    32   This file specifies the fvec_t buffer type, which is used throughout aubio to
    33   store real data.
     32  This file specifies the ::fvec_t buffer type, which is used throughout aubio
     33  to store vector of real-valued ::smpl_t.
     34
     35  \example test-fvec.c
    3436
    3537*/
    3638
    37 /** Buffer for real data */
     39/** Buffer for real data
     40
     41  Vector of real-valued data
     42
     43  ::fvec_t is is the structure used to store vector of real-valued data, ::smpl_t .
     44
     45  \code
     46
     47  uint_t buffer_size = 1024;
     48
     49  // create a vector of 512 values
     50  fvec_t * input = new_fvec (buffer_size);
     51
     52  // set some values of the vector
     53  input->data[23] = 2.;
     54  // ..
     55
     56  // compute the mean of the vector
     57  mean = fvec_mean(a_vector);
     58
     59  // destroy the vector
     60  del_fvec(a_vector);
     61
     62  \endcode
     63
     64  See `examples/` and `tests/src` directories for more examples.
     65
     66 */
    3867typedef struct {
    39   uint_t length;   /**< length of buffer */
    40   smpl_t *data;   /**< data array of size [length] */
     68  uint_t length;  /**< length of buffer */
     69  smpl_t *data;   /**< data vector of length ::fvec_t.length */
    4170} fvec_t;
    4271
  • src/io/sink.h

    r714d05e rbab24a0  
    3030  Media sink
    3131
     32  \example io/test-sink.c
     33
    3234*/
    3335
  • src/io/sndfileio.h

    r714d05e rbab24a0  
    7070 */
    7171uint_t aubio_sndfile_channels(aubio_sndfile_t * file);
     72/**
     73 * Return samplerate of a file (Hz)
     74 */
    7275uint_t aubio_sndfile_samplerate(aubio_sndfile_t * file);
    7376
  • src/lvec.h

    r714d05e rbab24a0  
    2828/** \file
    2929
    30   Real buffers
     30  Vector of real-valued data in double precision
    3131
    32   This file specifies the lvec_t buffer type, which is used in aubio to store
    33   double precision real data. Note that the lvec_t data type is mostly used for
    34   IIR filters (see temporal/filter.h).
     32  This file specifies the ::lvec_t buffer type, which is used in some places in
     33  aubio to store a vector of ::lsmp_t.
     34
     35  Note: the lvec_t data type is required in some algorithms such as IIR filters
     36  (see temporal/filter.h).
     37
     38  \example test-lvec.c
    3539
    3640*/
     
    3842/** Buffer for real data in double precision */
    3943typedef struct {
    40   uint_t length;   /**< length of buffer */
    41   lsmp_t *data;   /**< data array of size [length] */
     44  uint_t length; /**< length of buffer */
     45  lsmp_t *data;  /**< data array of size [length] */
    4246} lvec_t;
    4347
  • src/mathutils.c

    r714d05e rbab24a0  
    4444
    4545fvec_t *
    46 new_aubio_window (char_t * window_type, uint_t size)
    47 {
    48   fvec_t * win = new_fvec (size);
     46new_aubio_window (char_t * window_type, uint_t length)
     47{
     48  fvec_t * win = new_fvec (length);
     49  fvec_set_window (win, window_type);
     50  return win;
     51}
     52
     53uint_t fvec_set_window (fvec_t *win, char_t *window_type) {
    4954  smpl_t * w = win->data;
    50   uint_t i;
     55  uint_t i, size = win->length;
    5156  aubio_window_type wintype;
    52   if (strcmp (window_type, "rectangle") == 0)
     57  if (window_type == NULL) {
     58      AUBIO_ERR ("window type can not be null.\n");
     59      return 1;
     60  } else if (strcmp (window_type, "rectangle") == 0)
    5361      wintype = aubio_win_rectangle;
    5462  else if (strcmp (window_type, "hamming") == 0)
     
    7179      wintype = aubio_win_default;
    7280  else {
    73       AUBIO_ERR ("unknown window type %s, using default.\n", window_type);
    74       wintype = aubio_win_default;
     81      AUBIO_ERR ("unknown window type `%s`.\n", window_type);
     82      return 1;
    7583  }
    7684  switch(wintype) {
     
    105113      break;
    106114    case aubio_win_gaussian:
    107       for (i=0;i<size;i++)
    108         w[i] = EXP(- 1.0 / SQR(size) * SQR(2.0*i-size));
     115      {
     116        lsmp_t a, b, c = 0.5;
     117        uint_t n;
     118        for (n = 0; n < size; n++)
     119        {
     120          a = (n-c*(size-1))/(SQR(c)*(size-1));
     121          b = -c*SQR(a);
     122          w[n] = EXP(b);
     123        }
     124      }
    109125      break;
    110126    case aubio_win_welch:
    111127      for (i=0;i<size;i++)
    112         w[i] = 1.0 - SQR((2*i-size)/(size+1.0));
     128        w[i] = 1.0 - SQR((2.*i-size)/(size+1.0));
    113129      break;
    114130    case aubio_win_parzen:
    115131      for (i=0;i<size;i++)
    116         w[i] = 1.0 - ABS((2*i-size)/(size+1.0));
     132        w[i] = 1.0 - ABS((2.*i-size)/(size+1.0));
    117133      break;
    118134    default:
    119135      break;
    120136  }
    121   return win;
     137  return 0;
    122138}
    123139
  • src/mathutils.h

    r714d05e rbab24a0  
    1919*/
    2020
    21 /** @file
    22  *  various math functions
     21/** \file
     22
     23  Various math functions
     24
     25  \example test-mathutils.c
     26  \example test-mathutils-window.c
     27
    2328 */
    2429
     
    180185void fvec_min_removal (fvec_t * v);
    181186
    182 /** compute moving median theshold of a vector
     187/** compute moving median threshold of a vector
    183188
    184189  This function computes the moving median threshold value of at the given
    185 position of a vector, taking the median amongs post elements before and up to
     190position of a vector, taking the median among post elements before and up to
    186191pre elements after pos.
    187192 
  • src/musicutils.h

    r714d05e rbab24a0  
    4545*/
    4646fvec_t *new_aubio_window (char_t * window_type, uint_t size);
     47
     48/** set elements of a vector to window coefficients
     49
     50 */
     51uint_t fvec_set_window (fvec_t * window, char_t * window_type);
    4752
    4853/** compute the principal argument
  • src/onset/onset.h

    r714d05e rbab24a0  
    2121/** \file
    2222 
    23   Onset detection driver
     23  Onset detection object
    2424
    2525  The following routines compute the onset detection function and detect peaks
    2626  in these functions. When onsets are found above a given silence threshold,
    2727  and after a minimum inter-onset interval, the output vector returned by
    28   aubio_onset_do is filled with 1. Otherwise, the output vector remains 0.
     28  ::aubio_onset_do is filled with `1`. Otherwise, the output vector remains
     29  `0`.
    2930
    3031  The peak-picking threshold, the silence threshold, and the minimum
    3132  inter-onset interval can be adjusted during the execution of the
    3233  aubio_onset_do routine using the corresponding functions.
     34
     35  \example onset/test-onset.c
    3336
    3437*/
  • src/onset/peakpicker.h

    r714d05e rbab24a0  
    2222 
    2323  Peak picking utilities function
     24
     25  \example onset/test-peakpicker.c
    2426 
    2527*/
  • src/pitch/pitch.c

    r714d05e rbab24a0  
    3535#include "pitch/pitch.h"
    3636
    37 /** pitch detection algorithm */
     37/** pitch detection algorithms */
    3838typedef enum
    3939{
    40   aubio_pitcht_yin,     /**< YIN algorithm */
    41   aubio_pitcht_mcomb,   /**< Multi-comb filter */
    42   aubio_pitcht_schmitt, /**< Schmitt trigger */
    43   aubio_pitcht_fcomb,   /**< Fast comb filter */
    44   aubio_pitcht_yinfft,   /**< Spectral YIN */
    45   aubio_pitcht_default = aubio_pitcht_yinfft, /**< the one used when "default" is asked */
     40  aubio_pitcht_yin,        /**< `yin`, YIN algorithm */
     41  aubio_pitcht_mcomb,      /**< `mcomb`, Multi-comb filter */
     42  aubio_pitcht_schmitt,    /**< `schmitt`, Schmitt trigger */
     43  aubio_pitcht_fcomb,      /**< `fcomb`, Fast comb filter */
     44  aubio_pitcht_yinfft,     /**< `yinfft`, Spectral YIN */
     45  aubio_pitcht_default
     46    = aubio_pitcht_yinfft, /**< `default` */
    4647} aubio_pitch_type;
    4748
    48 /** pitch detection output mode */
     49/** pitch detection output modes */
    4950typedef enum
    5051{
  • src/pitch/pitch.h

    r714d05e rbab24a0  
    3232  This file creates the objects required for the computation of the selected
    3333  pitch detection algorithm and output the results, in midi note or Hz.
     34
     35  \example pitch/test-pitch.c
    3436
    3537*/
  • src/pitch/pitchfcomb.h

    r714d05e rbab24a0  
    2828   This file was derived from the tuneit project, written by Mario Lang to
    2929   detect the fundamental frequency of a sound.
    30    
    31    see http://delysid.org/tuneit.html
     30
     31   See http://delysid.org/tuneit.html
     32
     33   \example pitch/test-pitchfcomb.c
    3234
    3335*/
     
    4345typedef struct _aubio_pitchfcomb_t aubio_pitchfcomb_t;
    4446
    45 /** execute pitch detection on an input buffer 
    46  
     47/** execute pitch detection on an input buffer
     48
    4749  \param p pitch detection object as returned by new_aubio_pitchfcomb
    48   \param input input signal window (length as specified at creation time) 
     50  \param input input signal window (length as specified at creation time)
    4951  \param output pitch candidates in bins
    50  
     52
    5153*/
    5254void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input,
     
    5456
    5557/** creation of the pitch detection object
    56  
    57   \param buf_size size of the input buffer to analyse 
    58   \param hop_size step size between two consecutive analysis instant 
    59  
     58
     59  \param buf_size size of the input buffer to analyse
     60  \param hop_size step size between two consecutive analysis instant
     61
    6062*/
    6163aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t buf_size, uint_t hop_size);
    6264
    6365/** deletion of the pitch detection object
    64  
     66
    6567  \param p pitch detection object as returned by new_aubio_pitchfcomb
    66  
     68
    6769*/
    6870void del_aubio_pitchfcomb (aubio_pitchfcomb_t * p);
  • src/pitch/pitchmcomb.h

    r714d05e rbab24a0  
    2424
    2525  This fundamental frequency estimation algorithm implements spectral
    26   flattening, multi-comb filtering and peak histogramming. 
     26  flattening, multi-comb filtering and peak histogramming.
    2727
    2828  This method was designed by Juan P. Bello and described in:
     
    3131  Music''.  PhD thesis, Centre for Digital Music, Queen Mary University of
    3232  London, London, UK, 2003.
     33
     34  \example pitch/test-pitchmcomb.c
    3335
    3436*/
     
    4547
    4648/** execute pitch detection on an input spectral frame
    47  
     49
    4850  \param p pitch detection object as returned by new_aubio_pitchmcomb
    49   \param fftgrain input signal spectrum as computed by aubio_pvoc_do
    50  
     51  \param in_fftgrain input signal spectrum as computed by aubio_pvoc_do
     52  \param out_cands pitch candidate frequenciess, in bins
     53
    5154*/
    52 void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain,
    53     fvec_t * output);
     55void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * in_fftgrain,
     56    fvec_t * out_cands);
    5457
    5558/** creation of the pitch detection object
    56  
    57   \param buf_size size of the input buffer to analyse
    58   \param hop_size step size between two consecutive analysis instant
    59   \param samplerate sampling rate of the signal
    60  
     59
     60  \param buf_size size of the input buffer to analyse
     61  \param hop_size step size between two consecutive analysis instant
     62
    6163*/
    6264aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t buf_size, uint_t hop_size);
    6365
    6466/** deletion of the pitch detection object
    65  
     67
    6668  \param p pitch detection object as returned by new_aubio_pitchfcomb
    67  
     69
    6870*/
    6971void del_aubio_pitchmcomb (aubio_pitchmcomb_t * p);
     
    7375#endif
    7476
    75 #endif/*PITCHMCOMB_H*/
     77#endif /* PITCHMCOMB_H */
  • src/pitch/pitchschmitt.h

    r714d05e rbab24a0  
    1919*/
    2020
    21 /** \file 
     21/** \file
    2222
    23    Pitch detection using a Schmitt trigger 
    24  
     23   Pitch detection using a Schmitt trigger
     24
    2525   This pitch extraction method implements a Schmitt trigger to estimate the
    2626   period of a signal.
     
    2828   This file was derived from the tuneit project, written by Mario Lang to
    2929   detect the fundamental frequency of a sound.
    30    
    31    see http://delysid.org/tuneit.html
     30
     31   See http://delysid.org/tuneit.html
     32
     33   \example pitch/test-pitchschmitt.c
    3234
    3335*/
     
    4345typedef struct _aubio_pitchschmitt_t aubio_pitchschmitt_t;
    4446
    45 /** execute pitch detection on an input buffer 
    46  
    47   \param p pitch detection object as returned by new_aubio_pitchschmitt 
    48   \param input input signal window (length as specified at creation time)
    49   \param output pitch period estimates, in samples
    50  
     47/** execute pitch detection on an input buffer
     48
     49  \param p pitch detection object as returned by new_aubio_pitchschmitt
     50  \param samples_in input signal vector (length as specified at creation time)
     51  \param cands_out pitch period estimates, in samples
     52
    5153*/
    52 void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * in,
    53     fvec_t * out);
     54void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * samples_in,
     55    fvec_t * cands_out);
    5456
    5557/** creation of the pitch detection object
    56  
    57   \param buf_size size of the input buffer to analyse 
    58  
     58
     59  \param buf_size size of the input buffer to analyse
     60
    5961*/
    6062aubio_pitchschmitt_t *new_aubio_pitchschmitt (uint_t buf_size);
    6163
    6264/** deletion of the pitch detection object
    63  
    64   \param p pitch detection object as returned by new_aubio_pitchschmitt 
    65  
     65
     66  \param p pitch detection object as returned by new_aubio_pitchschmitt
     67
    6668*/
    6769void del_aubio_pitchschmitt (aubio_pitchschmitt_t * p);
  • src/pitch/pitchyin.h

    r714d05e rbab24a0  
    1919*/
    2020
    21 /** \file 
    22  
     21/** \file
     22
    2323  Pitch detection using the YIN algorithm
    24  
     24
    2525  This algorithm was developped by A. de Cheveigne and H. Kawahara and
    2626  published in:
    27  
     27
    2828  De Cheveigné, A., Kawahara, H. (2002) "YIN, a fundamental frequency
    29   estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930. 
    30  
     29  estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930.
     30
    3131  see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html
     32
     33  \example pitch/test-pitchyin.c
    3234
    3335*/
     
    4446
    4547/** creation of the pitch detection object
    46  
    47   \param buf_size size of the input buffer to analyse 
    48  
     48
     49  \param buf_size size of the input buffer to analyse
     50
    4951*/
    5052aubio_pitchyin_t *new_aubio_pitchyin (uint_t buf_size);
    5153
    5254/** deletion of the pitch detection object
    53  
    54   \param p pitch detection object as returned by new_aubio_pitchyin()
    55  
     55
     56  \param o pitch detection object as returned by new_aubio_pitchyin()
     57
    5658*/
    5759void del_aubio_pitchyin (aubio_pitchyin_t * o);
    5860
    59 /** execute pitch detection on an input buffer
    60  
    61   \param p pitch detection object as returned by new_aubio_pitchyin()
    62   \param input input signal window (length as specified at creation time)
    63   \param tol tolerance parameter for minima selection [default 0.85]
    64  
     61/** execute pitch detection an input buffer
     62
     63  \param o pitch detection object as returned by new_aubio_pitchyin()
     64  \param samples_in input signal vector (length as specified at creation time)
     65  \param cands_out pitch period candidates, in samples
     66
    6567*/
    66 void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * in, fvec_t * out);
     68void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * samples_in, fvec_t * cands_out);
    6769
    6870
    69 /** set tolerance parameter for YIN algorithm 
    70  
    71   \param o YIN pitch detection object 
     71/** set tolerance parameter for YIN algorithm
     72
     73  \param o YIN pitch detection object
    7274  \param tol tolerance parameter for minima selection [default 0.15]
    7375
     
    7577uint_t aubio_pitchyin_set_tolerance (aubio_pitchyin_t * o, smpl_t tol);
    7678
    77 /** get tolerance parameter for YIN algorithm 
    78  
    79   \param o YIN pitch detection object 
     79/** get tolerance parameter for YIN algorithm
     80
     81  \param o YIN pitch detection object
    8082  \return tolerance parameter for minima selection [default 0.15]
    8183
     
    8789#endif
    8890
    89 #endif /*PITCHYIN_H*/ 
     91#endif /*PITCHYIN_H*/
  • src/pitch/pitchyinfft.h

    r714d05e rbab24a0  
    3232  Queen Mary University of London, London, UK, 2006.
    3333
     34  \example pitch/test-pitchyinfft.c
     35
    3436*/
    3537
     
    4648/** execute pitch detection on an input buffer
    4749 
    48   \param p pitch detection object as returned by new_aubio_pitchyinfft
    49   \param input input signal window (length as specified at creation time)
    50   \param output pitch period candidates, in samples
     50  \param o pitch detection object as returned by new_aubio_pitchyinfft
     51  \param samples_in input signal vector (length as specified at creation time)
     52  \param cands_out pitch period candidates, in samples
    5153 
    5254*/
    53 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * in, fvec_t * out);
     55void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, fvec_t * samples_in, fvec_t * cands_out);
    5456/** creation of the pitch detection object
    5557 
     
    6062/** deletion of the pitch detection object
    6163 
    62   \param p pitch detection object as returned by new_aubio_pitchyinfft()
     64  \param o pitch detection object as returned by new_aubio_pitchyinfft()
    6365 
    6466*/
    65 void del_aubio_pitchyinfft (aubio_pitchyinfft_t * p);
     67void del_aubio_pitchyinfft (aubio_pitchyinfft_t * o);
    6668
    6769/** get tolerance parameter for YIN algorithm
     
    7274
    7375*/
    74 smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p);
     76smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * o);
    7577
    7678/** set tolerance parameter for YIN algorithm
     
    8082
    8183*/
    82 uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol);
     84uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * o, smpl_t tol);
    8385
    8486#ifdef __cplusplus
  • src/spectral/fft.h

    r714d05e rbab24a0  
    2222
    2323  Fast Fourier Transform object
     24
     25  \example src/spectral/test-fft.c
    2426
    2527*/
  • src/spectral/filterbank.c

    r714d05e rbab24a0  
    7070  /* for each filter */
    7171  for (fn = 0; fn < max_filters; fn++) {
    72 
    7372    /* for each sample */
    7473    for (j = 0; j < max_length; j++) {
  • src/spectral/filterbank.h

    r714d05e rbab24a0  
    2626  General-purpose spectral filterbank object.
    2727
     28  \example spectral/test-filterbank.c
     29
    2830*/
    2931
     
    3638#endif
    3739
    38 /** filterbank object */
     40/** filterbank object
     41
     42  This object stores a matrix of spectral filter coefficients.
     43
     44 */
    3945typedef struct _aubio_filterbank_t aubio_filterbank_t;
    4046
  • src/spectral/filterbank_mel.h

    r714d05e rbab24a0  
    2222/** \file
    2323
    24   Mel frequency filter bankd coefficients
     24  Filterbank object coefficients initialization
    2525
    26   Set filter bank coefficients to Mel frequency bands.
     26  Functions to create set the ::aubio_filterbank_t coefficients to
     27    - ::aubio_filterbank_set_triangle_bands: overlapping triangular bands,
     28    - ::aubio_filterbank_set_mel_coeffs_slaney: Mel frequency bands.
    2729
    28   The filter coefficients are built according to Malcolm Slaney's Auditory
    29   Toolbox available at http://cobweb.ecn.purdue.edu/~malcolm/interval/1998-010/
    30   (see the file mfcc.m).
     30  \example spectral/test-filterbank_mel.c
    3131
    3232*/
     
    5858  \param samplerate audio sampling rate
    5959
    60   This function fills the filterbank coefficients according to Malcolm Slaney.
     60  The filter coefficients are built according to Malcolm Slaney's Auditory
     61  Toolbox, available at http://cobweb.ecn.purdue.edu/~malcolm/interval/1998-010/
     62  (see file mfcc.m).
    6163
    6264*/
     
    6870#endif
    6971
    70 #endif                          // FILTERBANK_MEL_H
     72#endif // FILTERBANK_MEL_H
  • src/spectral/mfcc.h

    r714d05e rbab24a0  
    2323
    2424  Mel-frequency cepstrum coefficients object
     25
     26  \example spectral/test-mfcc.c
    2527
    2628*/
  • src/spectral/phasevoc.h

    r714d05e rbab24a0  
    2727  phase relationships across frames. The window sizes and overlap are specified
    2828  at creation time.
     29
     30  \example spectral/test-phasevoc.c
    2931
    3032*/
  • src/spectral/specdesc.h

    r714d05e rbab24a0  
    2727  buffer (stored in a vector of size [1]).
    2828 
     29  \section specdesc Spectral description functions
     30
    2931  A list of the spectral description methods currently available follows.
    3032
    31   \section onsetdesc Onset detection functions
     33  \subsection onsetdesc Onset detection functions
    3234
    3335  These functions are designed to raise at notes attacks in music signals.
     
    8284  Canada, 2006.
    8385
    84   \section shapedesc Spectral shape descriptors
     86  \subsection shapedesc Spectral shape descriptors
    8587
    8688  The following descriptors are described in:
     
    139141  is found.
    140142
     143  \example spectral/test-specdesc.c
     144
    141145*/
    142146
     
    169173  \param buf_size length of the input spectrum frame
    170174
     175  The parameter \p method is a string that can be any of:
     176
     177    - `energy`, `hfc`, `complex`, `phase`, `specdiff`, `kl`, `mkl`, `specflux`
     178    - `centroid`, `spread`, `skewness`, `kurtosis`, `slope`, `decrease`, `rolloff`
     179
    171180*/
    172181aubio_specdesc_t *new_aubio_specdesc (char_t * method, uint_t buf_size);
  • src/spectral/tss.h

    r714d05e rbab24a0  
    3232
    3333  Available at http://www.csis.ul.ie/dafx01/proceedings/papers/duxbury.pdf
     34
     35  \example spectral/test-tss.c
    3436
    3537*/
  • src/tempo/beattracking.h

    r714d05e rbab24a0  
    3333  towards automatic musical accompaniment. In Proceedings of the Audio
    3434  Engeeniring Society 118th Convention, Barcelona, Spain, May 2005.
     35
     36  \example tempo/test-beattracking.c
    3537 
    3638*/
  • src/tempo/tempo.h

    r714d05e rbab24a0  
    2525  This object stores all the memory required for tempo detection algorithm
    2626  and returns the estimated beat locations.
     27
     28  \example tempo/test-tempo.c
    2729
    2830*/
  • src/temporal/a_weighting.h

    r714d05e rbab24a0  
    5353  file sampling rates have been included for completeness.
    5454
     55  \example temporal/test-a_weighting.c
     56
    5557*/
    5658
  • src/temporal/biquad.h

    r714d05e rbab24a0  
    3636  biquad filter</a> on wikipedia.
    3737
     38  \example temporal/test-biquad.c
     39
    3840*/
    3941
     
    5557    lsmp_t b2, lsmp_t a1, lsmp_t a2);
    5658
    57 /** create new biquad filter
     59/** create biquad filter with `b0`, `b1`, `b2`, `a1`, `a2` coeffs
    5860
    5961  \param b0 forward filter coefficient
  • src/temporal/c_weighting.h

    r714d05e rbab24a0  
    5353  file sampling rates have been included for completeness.
    5454
     55  \example temporal/test-c_weighting.c
     56
    5557*/
    5658
  • src/temporal/filter.h

    r714d05e rbab24a0  
    5858    - new_aubio_filter_c_weighting() and aubio_filter_set_c_weighting().
    5959    - new_aubio_filter_biquad() and aubio_filter_set_biquad().
     60
     61  \example temporal/test-filter.c
    6062 
    6163*/
  • src/vecutils.h

    r714d05e rbab24a0  
    1919*/
    2020
    21 /** @file
    22  *  various utilities functions for fvec and cvec objects
    23  *
     21/** \file
     22
     23  Utility functions for ::fvec_t and ::cvec_t objects
     24
    2425 */
    2526
  • tests/src/io/test-sink.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
    3 #include "config.h"
     2#include "utils_tests.h"
    43
    5 char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    6 char_t *outpath = "/var/tmp/test.wav";
     4int main (int argc, char **argv)
     5{
     6  sint_t err = 0;
    77
    8 int main(){
    9   int err = 0;
     8  if (argc < 3) {
     9    err = 2;
     10    PRINT_ERR("not enough arguments\n");
     11    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     12    return err;
     13  }
     14
    1015  uint_t samplerate = 44100;
    1116  uint_t hop_size = 512;
    12   uint_t read = hop_size;
     17  uint_t n_frames = 0, read = 0;
     18
     19  char_t *source_path = argv[1];
     20  char_t *sink_path = argv[2];
     21  if ( argc == 4 ) samplerate = atoi(argv[3]);
     22
    1323  fvec_t *vec = new_fvec(hop_size);
    14   aubio_source_t * i = new_aubio_source(path, samplerate, hop_size);
    15   aubio_sink_t *   o = new_aubio_sink(outpath, samplerate);
     24  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
     25  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
     26  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
    1627
    17   if (!i || !o) { err = -1; goto beach; }
     28  if (!i || !o) { err = 1; goto beach; }
    1829
    19   while ( read == hop_size ) {
     30  do {
    2031    aubio_source_do(i, vec, &read);
    2132    aubio_sink_do(o, vec, read);
    22   }
     33    n_frames += read;
     34  } while ( read == hop_size );
     35
     36  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
     37      n_frames, source_path, sink_path, samplerate);
    2338
    2439beach:
     
    2843  return err;
    2944}
    30 
  • tests/src/io/test-sink_apple_audio_file.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
     1#define AUBIO_UNSTABLE 1
    22#include <aubio.h>
    3 #include "config.h"
     3#include "utils_tests.h"
    44
    5 char_t *path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    6 char_t *outpath = "/var/tmp/test.wav";
     5int main (int argc, char **argv)
     6{
     7  sint_t err = 0;
    78
    8 int main(){
    9   int err = 0;
     9  if (argc < 3) {
     10    err = 2;
     11    PRINT_ERR("not enough arguments\n");
     12    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     13    return err;
     14  }
     15
    1016#ifdef __APPLE__
    1117  uint_t samplerate = 44100;
    1218  uint_t hop_size = 512;
    13   uint_t read = hop_size;
     19  uint_t n_frames = 0, read = 0;
     20
     21  char_t *source_path = argv[1];
     22  char_t *sink_path = argv[2];
     23  if ( argc == 4 ) samplerate = atoi(argv[3]);
     24
    1425  fvec_t *vec = new_fvec(hop_size);
    15   aubio_source_apple_audio_t * i = new_aubio_source_apple_audio(path, samplerate, hop_size);
    16   aubio_sink_apple_audio_t *   o = new_aubio_sink_apple_audio(outpath, samplerate);
     26  aubio_source_apple_audio_t *i = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
     27  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(i);
     28  aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate);
    1729
    18   if (!i || !o) { err = -1; goto beach; }
     30  if (!i || !o) { err = 1; goto beach; }
    1931
    20   while ( read == hop_size ) {
     32  do {
    2133    aubio_source_apple_audio_do(i, vec, &read);
    2234    aubio_sink_apple_audio_do(o, vec, read);
    23   }
     35    n_frames += read;
     36  } while ( read == hop_size );
     37
     38  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
     39      n_frames, source_path, sink_path, samplerate);
    2440
    2541beach:
     
    2844  del_fvec(vec);
    2945#else
    30   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_apple_audio\n");
     46  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
     47  err = 3;
    3148#endif /* __APPLE__ */
    3249  return err;
    3350}
    34 
  • tests/src/io/test-sink_sndfile.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
    3 #include "config.h"
     2#include "utils_tests.h"
    43
    5 char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    6 char_t *outpath = "/var/tmp/test.wav";
     4int main (int argc, char **argv)
     5{
     6  sint_t err = 0;
    77
    8 int main(){
    9   int err = 0;
     8  if (argc < 3) {
     9    err = 2;
     10    PRINT_ERR("not enough arguments\n");
     11    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
     12    return err;
     13  }
     14
    1015#ifdef HAVE_SNDFILE
    1116  uint_t samplerate = 44100;
    1217  uint_t hop_size = 512;
    13   uint_t read = hop_size;
     18  uint_t n_frames = 0, read = 0;
     19
     20  char_t *source_path = argv[1];
     21  char_t *sink_path = argv[2];
     22  if ( argc == 4 ) samplerate = atoi(argv[3]);
     23
    1424  fvec_t *vec = new_fvec(hop_size);
    1525  aubio_source_sndfile_t * i = new_aubio_source_sndfile(path, samplerate, hop_size);
     26  if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(i);
    1627  aubio_sink_sndfile_t *   o = new_aubio_sink_sndfile(outpath, samplerate);
    1728
    18   if (!i || !o) { err = -1; goto beach; }
     29  if (!i || !o) { err = 1; goto beach; }
    1930
    20   while ( read == hop_size ) {
     31  do {
    2132    aubio_source_sndfile_do(i, vec, &read);
    2233    aubio_sink_sndfile_do(o, vec, read);
    23   }
     34    n_frames += read;
     35  } while ( read == hop_size );
     36
     37  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
     38      n_frames, source_path, sink_path, samplerate);
    2439
    2540beach:
     
    2843  del_fvec(vec);
    2944#else
    30   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
     45  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
     46  err = 3;
    3147#endif /* HAVE_SNDFILE */
    3248  return err;
    3349}
    34 
  • tests/src/io/test-source.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
     2#include "utils_tests.h"
    33
    4 char_t *path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    5 //char_t *path = "/Users/piem/Downloads/Keziah Jones - Where's Life.mp3";
    6 
    7 int main(){
    8   uint_t samplerate = 32000;
    9   uint_t hop_size = 1024;
    10   uint_t read = hop_size;
    11   fvec_t *vec = new_fvec(hop_size);
    12   aubio_source_t* s = new_aubio_source(path, samplerate, hop_size);
    13 
    14   if (!s) return -1;
    15 
    16   while ( read == hop_size ) {
    17     aubio_source_do(s, vec, &read);
    18     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
     4int main (int argc, char **argv)
     5{
     6  uint_t err = 0;
     7  if (argc < 2) {
     8    err = 2;
     9    PRINT_ERR("not enough arguments\n");
     10    PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
     11    return err;
    1912  }
    2013
    21   del_aubio_source(s);
     14  uint_t samplerate = 32000;
     15  uint_t hop_size = 256;
     16  uint_t n_frames = 0, read = 0;
     17  if ( argc == 3 ) samplerate = atoi(argv[2]);
    2218
    23   return 0;
     19  char_t *source_path = argv[1];
     20
     21  fvec_t *vec = new_fvec(hop_size);
     22  aubio_source_t* s = new_aubio_source(source_path, samplerate, hop_size);
     23  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(s);
     24
     25  if (!s) { err = 1; goto beach; }
     26
     27  do {
     28    aubio_source_do(s, vec, &read);
     29    // fvec_print (vec);
     30    n_frames += read;
     31  } while ( read == hop_size );
     32
     33beach:
     34  del_aubio_source (s);
     35  del_fvec (vec);
     36
     37  return err;
    2438}
    25 
  • tests/src/io/test-source_apple_audio_file.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
     1#define AUBIO_UNSTABLE 1
    22#include <aubio.h>
     3#include "utils_tests.h"
    34
    4 char_t *path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
    5 //char_t *path = "/Volumes/moving/moving/photos/gopro2/100GOPRO/GOPR4515.MP4";
    6 
    7 int main(){
    8 #ifdef __APPLE__
    9   uint_t samplerate = 32000;
    10   uint_t hop_size = 1024;
    11   uint_t read = hop_size;
    12   fvec_t *vec = new_fvec(hop_size);
    13   aubio_source_apple_audio_t * s = new_aubio_source_apple_audio(path, samplerate, hop_size);
    14 
    15   if (!s) return -1;
    16 
    17   while ( read == hop_size ) {
    18     aubio_source_apple_audio_do(s, vec, &read);
    19     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
     5int main (int argc, char **argv)
     6{
     7  uint_t err = 0;
     8  if (argc < 2) {
     9    err = 2;
     10    PRINT_ERR("not enough arguments\n");
     11    PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
     12    return err;
    2013  }
    2114
    22   del_aubio_source_apple_audio(s);
     15#if __APPLE__
     16  uint_t samplerate = 32000;
     17  uint_t hop_size = 256;
     18  uint_t n_frames = 0, read = 0;
     19  if ( argc == 3 ) samplerate = atoi(argv[2]);
     20
     21  char_t *source_path = argv[1];
     22
     23  fvec_t *vec = new_fvec(hop_size);
     24  aubio_source_apple_audio_t * s = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
     25  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(s);
     26
     27  if (!s) { err = 1; goto beach; }
     28
     29  do {
     30    aubio_source_apple_audio_do(s, vec, &read);
     31    // fvec_print (vec);
     32    n_frames += read;
     33  } while ( read == hop_size );
     34
     35beach:
     36  del_aubio_source_apple_audio (s);
     37  del_fvec (vec);
    2338#else
    24   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_apple_audio\n");
     39  err = 3;
     40  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
    2541#endif /* __APPLE__ */
    2642  return 0;
    2743}
    28 
  • tests/src/io/test-source_sndfile.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
    3 #include "config.h"
     2#include "utils_tests.h"
    43
    5 char_t *path = "/home/piem/archives/samples/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
     4int main (int argc, char **argv)
     5{
     6  uint_t err = 0;
     7  if (argc < 2) {
     8    err = 2;
     9    PRINT_ERR("not enough arguments\n");
     10    PRINT_MSG("usage: %s <source_path> [samplerate]\n", argv[0]);
     11    return err;
     12  }
    613
    7 int main(){
    8   int err = 0;
    914#ifdef HAVE_SNDFILE
    10   uint_t samplerate = 8000;
    11   uint_t hop_size = 512;
    12   uint_t read = hop_size;
     15  uint_t samplerate = 32000;
     16  uint_t hop_size = 256;
     17  uint_t n_frames = 0, read = 0;
     18  if ( argc == 3 ) samplerate = atoi(argv[2]);
     19
     20  char_t *source_path = argv[1];
     21
    1322  fvec_t *vec = new_fvec(hop_size);
    14   aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size);
     23  aubio_source_sndfile_t * s = new_aubio_source_sndfile(source_path, samplerate, hop_size);
     24  if (samplerate == 0 ) samplerate = aubio_source_sndfile_get_samplerate(s);
    1525
    1626  if (!s) { err = 1; goto beach; }
    1727
    18   while ( read == hop_size ) {
     28  do {
    1929    aubio_source_sndfile_do(s, vec, &read);
    20     if (read == 0) break;
    21     fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
    22   }
     30    // fvec_print (vec);
     31    n_frames += read;
     32  } while ( read == hop_size );
    2333
    2434beach:
    25   del_aubio_source_sndfile(s);
    26   del_fvec(vec);
     35  del_aubio_source_sndfile (s);
     36  del_fvec (vec);
    2737#else
    28   fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
     38  PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n");
    2939  err = 2;
    3040#endif /* HAVE_SNDFILE */
    3141  return err;
    3242}
    33 
  • tests/src/onset/test-onset.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int main(){
    4         /* allocate some memory */
    5         uint_t win_s      = 1024;                       /* window size */
    6         fvec_t * in       = new_fvec (win_s/4); /* input buffer */
    7         fvec_t * out      = new_fvec (2);     /* input buffer */
    8         aubio_onset_t * onset  = new_aubio_onset("complex", win_s, win_s/4, 44100.);
    9         uint_t i = 0;
     3int main ()
     4{
     5  // 1. allocate some memory
     6  uint_t n = 0; // frame counter
     7  uint_t win_s = 1024; // window size
     8  uint_t hop_s = win_s / 4; // hop size
     9  uint_t samplerate = 44100; // samplerate
     10  // create some vectors
     11  fvec_t * input = new_fvec (win_s/4); // input buffer
     12  fvec_t * out = new_fvec (2); // input buffer
     13  // create onset object
     14  aubio_onset_t * onset = new_aubio_onset("complex", win_s, hop_s, samplerate);
    1015
    11         while (i < 10) {
    12           aubio_onset_do (onset,in,out);
    13           i++;
    14         };
     16  // 2. do something with it
     17  while (n < 10) {
     18    // get `hop_s` new samples into `input`
     19    // ...
     20    // exectute onset detection
     21    aubio_onset_do (onset, input, out);
     22    // do something with output candidates
     23    // ...
     24    n++;
     25  };
    1526
    16         del_aubio_onset(onset);
    17         del_fvec(in);
    18         del_fvec(out);
    19         aubio_cleanup();
     27  // 3. clean up memory
     28  del_aubio_onset(onset);
     29  del_fvec(input);
     30  del_fvec(out);
     31  aubio_cleanup();
    2032
    21         return 0;
     33  return 0;
    2234}
  • tests/src/onset/test-peakpicker.c

    r714d05e rbab24a0  
    33#include <aubio.h>
    44
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         fvec_t * out      = new_fvec (1); /* input buffer */
    10         aubio_peakpicker_t * o = new_aubio_peakpicker();
    11         aubio_peakpicker_set_threshold (o, 0.3);
     5int main ()
     6{
     7  uint_t win_s = 1024; // window size
     8  fvec_t * in = new_fvec (win_s); // input buffer
     9  fvec_t * out = new_fvec (1); // input buffer
     10  aubio_peakpicker_t * o = new_aubio_peakpicker();
     11  aubio_peakpicker_set_threshold (o, 0.3);
    1212
    13         aubio_peakpicker_do(o, in, out);
    14         aubio_peakpicker_do(o, in, out);
    15         aubio_peakpicker_do(o, in, out);
    16         aubio_peakpicker_do(o, in, out);
     13  aubio_peakpicker_do(o, in, out);
     14  aubio_peakpicker_do(o, in, out);
     15  aubio_peakpicker_do(o, in, out);
     16  aubio_peakpicker_do(o, in, out);
    1717
    18         del_aubio_peakpicker(o);
    19         del_fvec(out);
    20         del_fvec(in);
    21         return 0;
     18  del_aubio_peakpicker(o);
     19  del_fvec(out);
     20  del_fvec(in);
     21  return 0;
    2222}
    2323
  • tests/src/pitch/test-pitch.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int
    4 main ()
     3int main ()
    54{
    6   /* allocate some memory */
    7   uint_t win_s = 1024;          /* window size */
    8   uint_t hop_s = win_s / 4;     /* hop size */
    9   uint_t samplerate = 44100;    /* samplerate */
    10   fvec_t *in = new_fvec (hop_s);      /* input buffer */
    11   fvec_t *out = new_fvec (1); /* input buffer */
    12   aubio_pitch_t *o =
    13       new_aubio_pitch ("default", win_s, hop_s, samplerate);
    14   uint_t i = 0;
     5  // 1. allocate some memory
     6  uint_t n = 0; // frame counter
     7  uint_t win_s = 1024; // window size
     8  uint_t hop_s = win_s / 4; // hop size
     9  uint_t samplerate = 44100; // samplerate
     10  // create some vectors
     11  fvec_t *input = new_fvec (hop_s); // input buffer
     12  fvec_t *out = new_fvec (1); // output candidates
     13  // create pitch object
     14  aubio_pitch_t *o = new_aubio_pitch ("default", win_s, hop_s, samplerate);
    1515
    16   while (i < 100) {
    17     aubio_pitch_do (o, in, out);
    18     i++;
     16  // 2. do something with it
     17  while (n < 100) {
     18    // get `hop_s` new samples into `input`
     19    // ...
     20    // exectute pitch
     21    aubio_pitch_do (o, input, out);
     22    // do something with output candidates
     23    // ...
     24    n++;
    1925  };
    2026
     27  // 3. clean up memory
    2128  del_aubio_pitch (o);
    2229  del_fvec (out);
    23   del_fvec (in);
     30  del_fvec (input);
    2431  aubio_cleanup ();
    2532
  • tests/src/pitch/test-pitchfcomb.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
     2
     3// this file uses the unstable aubio api, please use aubio_pitch instead
     4// see src/pitch/pitch.h and tests/src/pitch/test-pitch.c
    25
    36#include <aubio.h>
    47
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         uint_t hop_s      = win_s/4;                    /* hop size */
    9         fvec_t * in       = new_fvec (hop_s); /* input buffer */
    10         fvec_t * out      = new_fvec (1);
    11         aubio_pitchfcomb_t * o  = new_aubio_pitchfcomb (
    12           win_s, hop_s);
    13         uint_t i = 0;
     8int main ()
     9{
     10  uint_t i = 0;
     11  uint_t win_s = 1024; // window size
     12  uint_t hop_s = win_s/4; // hop size
     13  // create some vectors
     14  fvec_t * in = new_fvec (hop_s); // input buffer
     15  fvec_t * out = new_fvec (1); // output candidates
     16  // create pitch object
     17  aubio_pitchfcomb_t * o  = new_aubio_pitchfcomb ( win_s, hop_s);
    1418
    15         while (i < 2) {
    16           aubio_pitchfcomb_do (o,in, out);
    17           i++;
    18         };
     19  while (i < 10) {
     20    aubio_pitchfcomb_do (o,in, out);
     21    i++;
     22  };
    1923
    20         del_aubio_pitchfcomb(o);
    21         del_fvec(out);
    22         del_fvec(in);
    23         aubio_cleanup();
    24 
    25         return 0;
     24  del_aubio_pitchfcomb(o);
     25  del_fvec(out);
     26  del_fvec(in);
     27  aubio_cleanup();
     28  return 0;
    2629}
  • tests/src/pitch/test-pitchmcomb.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
     2
     3// this file uses the unstable aubio api, please use aubio_pitch instead
     4// see src/pitch/pitch.h and tests/src/pitch/test-pitch.c
    25
    36#include <aubio.h>
    47
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         uint_t hop_s      = win_s/4;                    /* hop size */
    9         cvec_t * in       = new_cvec (win_s); /* input buffer */
    10         fvec_t * out      = new_fvec (1); /* input buffer */
     8int main ()
     9{
     10  uint_t n = 10; // compute n times
     11  uint_t win_s = 1024; // window size
     12  uint_t hop_s = win_s/4; // hop size
     13  // create some vectors
     14  cvec_t * in_cvec = new_cvec (win_s); // input fftgrain
     15  fvec_t * out_cands = new_fvec (1); // pitch candidate
     16  // create pitch object
     17  aubio_pitchmcomb_t * mcomb = new_aubio_pitchmcomb(win_s, hop_s);
    1118
    12         aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s);
    13         uint_t i = 0;
     19  while ( n-- ) {
     20    aubio_pitchmcomb_do (mcomb, in_cvec, out_cands);
     21    // fvec_print(out_cands);
     22  };
    1423
    15         while (i < 1000) {
    16           aubio_pitchmcomb_do (o,in, out);
    17           i++;
    18         };
     24  // clean up before exiting
     25  del_aubio_pitchmcomb(mcomb);
     26  del_cvec(in_cvec);
     27  del_fvec(out_cands);
    1928
    20         del_aubio_pitchmcomb(o);
    21         del_cvec(in);
    22         del_fvec(out);
    23         aubio_cleanup();
     29  aubio_cleanup();
    2430
    25         return 0;
     31  return 0;
    2632}
  • tests/src/pitch/test-pitchschmitt.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
     2
     3// this file uses the unstable aubio api, please use aubio_pitch instead
     4// see src/pitch/pitch.h and tests/src/pitch/test-pitch.c
    25
    36#include <aubio.h>
    47
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         fvec_t * out = new_fvec (1); /* input buffer */
    10         aubio_pitchschmitt_t * o  = new_aubio_pitchschmitt(win_s);
    11         uint_t i = 0;
     8int main ()
     9{
     10  uint_t n = 10; // compute n times
     11  uint_t win_s = 1024; // window size
     12  // create some vectors
     13  fvec_t * in = new_fvec (win_s); // input buffer
     14  fvec_t * out = new_fvec (1); // input buffer
     15  // create pitch object
     16  aubio_pitchschmitt_t * o = new_aubio_pitchschmitt(win_s);
    1217
    13         while (i < 1000) {
    14           aubio_pitchschmitt_do (o,in, out);
    15           i++;
    16         };
     18  while ( n-- ) {
     19    aubio_pitchschmitt_do (o,in, out);
     20  };
    1721
    18         del_aubio_pitchschmitt(o);
    19         del_fvec(in);
    20         del_fvec(out);
    21         aubio_cleanup();
     22  del_aubio_pitchschmitt(o);
     23  del_fvec(in);
     24  del_fvec(out);
     25  aubio_cleanup();
    2226
    23         return 0;
     27  return 0;
    2428}
    2529
  • tests/src/pitch/test-pitchyin.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
     2
     3// this file uses the unstable aubio api, please use aubio_pitch instead
     4// see src/pitch/pitch.h and tests/src/pitch/test-pitch.c
    25
    36#include <aubio.h>
    47
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         fvec_t * out      = new_fvec (win_s/2); /* input buffer */
    10         aubio_pitchyin_t *p = new_aubio_pitchyin (win_s);
    11         uint_t i = 0;
     8int main ()
     9{
     10  uint_t n = 10; // compute n times
     11  uint_t win_s = 1024; // window size
     12  // create some vectors
     13  fvec_t * input_signal = new_fvec (win_s); // input signal
     14  fvec_t * output_cands = new_fvec (1); // output candidates
     15  // create pitch object
     16  aubio_pitchyin_t *p = new_aubio_pitchyin (win_s);
    1217
    13         while (i < 10) {
    14           aubio_pitchyin_do (p, in,out);
    15           i++;
    16         };
     18  while ( n-- ) {
     19    aubio_pitchyin_do (p, input_signal, output_cands);
     20  };
    1721
    18         del_fvec(in);
    19         del_fvec(out);
    20         del_aubio_pitchyin(p);
    21         aubio_cleanup();
     22  fvec_print(output_cands);
    2223
    23         return 0;
     24  del_fvec(input_signal);
     25  del_fvec(output_cands);
     26  del_aubio_pitchyin(p);
     27  aubio_cleanup();
     28
     29  return 0;
    2430}
  • tests/src/pitch/test-pitchyinfft.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
     2
     3// this file uses the unstable aubio api, please use aubio_pitch instead
     4// see src/pitch/pitch.h and tests/src/pitch/test-pitch.c
    25
    36#include <aubio.h>
    47
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         fvec_t * out      = new_fvec (1); /* output pitch periods */
    10         aubio_pitchyinfft_t * o  = new_aubio_pitchyinfft(win_s);
    11         aubio_pitchyinfft_set_tolerance (o, 0.2);
    12         uint_t i = 0;
     8int main ()
     9{
     10  uint_t n = 10; // compute n times
     11  uint_t win_s = 1024; // window size
     12  // create some vectors
     13  fvec_t * in = new_fvec (win_s); // input buffer
     14  fvec_t * out = new_fvec (1); // output candidates
     15  // create pitch object
     16  aubio_pitchyinfft_t *p  = new_aubio_pitchyinfft(win_s);
     17  aubio_pitchyinfft_set_tolerance (p, 0.2);
    1318
    14         while (i < 10) {
    15           aubio_pitchyinfft_do (o,in,out);
    16           i++;
    17         };
     19  while ( n-- ) {
     20    aubio_pitchyinfft_do (p, in,out);
     21  };
    1822
    19         del_aubio_pitchyinfft(o);
    20         del_fvec(in);
    21         del_fvec(out);
    22         aubio_cleanup();
     23  fvec_print(out);
    2324
    24         return 0;
     25  del_fvec(in);
     26  del_fvec(out);
     27  del_aubio_pitchyinfft(p);
     28  aubio_cleanup();
     29
     30  return 0;
    2531}
    26 
  • tests/src/spectral/test-fft.c

    r714d05e rbab24a0  
    1 
    21#include <aubio.h>
    32
    4 int main(){
    5         /* allocate some memory */
    6         uint_t win_s      = 8;                       /* window size        */
    7         fvec_t * in       = new_fvec (win_s); /* input buffer       */
    8         cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
    9         fvec_t * out      = new_fvec (win_s); /* output buffer      */
    10         in->data[0] = 1;
    11         in->data[1] = 2;
    12         in->data[2] = 3;
    13         in->data[3] = 4;
    14         in->data[4] = 5;
    15         in->data[5] = 6;
    16         in->data[6] = 5;
    17         in->data[7] = 6;
    18         /* allocate fft and other memory space */
    19         aubio_fft_t * fft = new_aubio_fft(win_s);
    20         /* fill input with some data */
    21         fvec_print(in);
    22         /* execute stft */
    23         aubio_fft_do (fft,in,fftgrain);
    24         cvec_print(fftgrain);
    25         /* execute inverse fourier transform */
    26         aubio_fft_rdo(fft,fftgrain,out);
    27         fvec_print(out);
    28         del_aubio_fft(fft);
    29         del_fvec(in);
    30         del_cvec(fftgrain);
    31         del_fvec(out);
    32         aubio_cleanup();
    33         return 0;
     3int main ()
     4{
     5  uint_t win_s = 8; // window size
     6  fvec_t * in = new_fvec (win_s); // input buffer
     7  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
     8  fvec_t * out = new_fvec (win_s); // output buffer
     9  // create fft object
     10  aubio_fft_t * fft = new_aubio_fft(win_s);
     11
     12  // fill input with some data
     13  in->data[0] = 1;
     14  in->data[1] = 2;
     15  in->data[2] = 3;
     16  in->data[3] = 4;
     17  in->data[4] = 5;
     18  in->data[5] = 6;
     19  in->data[6] = 5;
     20  in->data[7] = 6;
     21  fvec_print(in);
     22
     23  // execute stft
     24  aubio_fft_do (fft,in,fftgrain);
     25  cvec_print(fftgrain);
     26
     27  // execute inverse fourier transform
     28  aubio_fft_rdo(fft,fftgrain,out);
     29
     30  // cleam up
     31  fvec_print(out);
     32  del_aubio_fft(fft);
     33  del_fvec(in);
     34  del_cvec(fftgrain);
     35  del_fvec(out);
     36  aubio_cleanup();
     37  return 0;
    3438}
  • tests/src/spectral/test-filterbank.c

    r714d05e rbab24a0  
    1 #define AUBIO_UNSTABLE 1
    2 
    3 #include <stdio.h>
    41#include <aubio.h>
    52
    6 int
    7 main (void)
     3int main ()
    84{
    9   /* allocate some memory */
    10   uint_t win_s = 1024;          /* window size */
    11   uint_t n_filters = 13;        /* number of filters */
    12   cvec_t *in = new_cvec (win_s);      /* input buffer */
    13   fvec_t *out = new_fvec (win_s);     /* input buffer */
    14   fmat_t *coeffs = NULL;
     5  uint_t win_s = 1024; // window size
     6  uint_t n_filters = 13; // number of filters
    157
    16   /* allocate fft and other memory space */
     8  cvec_t *in_spec = new_cvec (win_s); // input vector of samples
     9  fvec_t *out_filters = new_fvec (n_filters); // per-band outputs
     10  fmat_t *coeffs; // pointer to the coefficients
     11
     12  // create filterbank object
    1713  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
    1814
    1915  coeffs = aubio_filterbank_get_coeffs (o);
    20   if (coeffs == NULL) {
    21     return -1;
    22   }
    2316
    24   /*
    25   if (fvec_max (coeffs) != 0.) {
    26     return -1;
    27   }
     17  aubio_filterbank_do (o, in_spec, out_filters);
    2818
    29   if (fvec_min (coeffs) != 0.) {
    30     return -1;
    31   }
    32   */
    33 
    34   fmat_print (coeffs);
    35 
    36   aubio_filterbank_do (o, in, out);
     19  // fmat_print (coeffs);
     20  // cvec_print(in_spec);
     21  // fvec_print(out_filters);
    3722
    3823  del_aubio_filterbank (o);
    39   del_cvec (in);
    40   del_fvec (out);
     24  del_cvec (in_spec);
     25  del_fvec (out_filters);
    4126  aubio_cleanup ();
    4227
  • tests/src/spectral/test-filterbank_mel.c

    r714d05e rbab24a0  
    1 #define AUBIO_UNSTABLE 1
    2 
    3 #include <stdio.h>
    41#include <aubio.h>
    52
    6 int
    7 main (void)
     3int main ()
    84{
    9   /* allocate some memory */
    10   uint_t win_s = 512;           /* fft size */
    11   uint_t n_filters = 40;        /* number of filters */
    12   cvec_t *in = new_cvec (win_s);      /* input buffer */
    13   fvec_t *out = new_fvec (win_s);     /* input buffer */
    14   fmat_t *coeffs = NULL;
    15   smpl_t samplerate = 16000.;
     5  uint_t samplerate = 16000; // samplerate of signal to filter
     6  uint_t win_s = 512; // fft size
     7  uint_t n_filters = 40; // number of filters
    168
    17   /* allocate fft and other memory space */
     9  cvec_t *in_spec = new_cvec (win_s); // input vector of samples
     10  fvec_t *out_filters = new_fvec (n_filters); // per-band outputs
     11  fmat_t *coeffs; // pointer to the coefficients
     12
     13  // create filterbank object
    1814  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
    1915
    20   /* assign Mel-frequency coefficients */
     16  // assign Mel-frequency coefficients
    2117  aubio_filterbank_set_mel_coeffs_slaney (o, samplerate);
    2218
    2319  coeffs = aubio_filterbank_get_coeffs (o);
    24   if (coeffs == NULL) {
    25     return -1;
    26   }
    2720
    28   //fmat_print (coeffs);
     21  aubio_filterbank_do (o, in_spec, out_filters);
    2922
    30   //fprintf(stderr, "%f\n", fvec_sum(coeffs));
    31 
    32   aubio_filterbank_do (o, in, out);
     23  // fmat_print (coeffs);
     24  // cvec_print(in_spec);
     25  // fvec_print(out_filters);
    3326
    3427  del_aubio_filterbank (o);
    35   del_cvec (in);
    36   del_fvec (out);
     28  del_cvec (in_spec);
     29  del_fvec (out_filters);
    3730  aubio_cleanup ();
    3831
  • tests/src/spectral/test-mfcc.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int
    4 main (void)
     3int main ()
    54{
    6   /* allocate some memory */
    7   uint_t win_s = 512;           /* fft size */
    8   uint_t n_filters = 40;        /* number of filters */
    9   uint_t n_coefs = 13;          /* number of coefficients */
    10   cvec_t *in = new_cvec (win_s);      /* input buffer */
    11   fvec_t *out = new_fvec (n_coefs);     /* input buffer */
    12   smpl_t samplerate = 16000.;
     5  uint_t win_s = 512; // fft size
     6  uint_t n_filters = 40; // number of filters
     7  uint_t n_coefs = 13; // number of coefficients
     8  smpl_t samplerate = 16000.; // samplerate
     9  cvec_t *in = new_cvec (win_s); // input buffer
     10  fvec_t *out = new_fvec (n_coefs); // output coefficients
    1311
    14   /* allocate fft and other memory space */
     12  // create mfcc object
    1513  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);
    1614
    1715  cvec_set (in, 1.);
    18 
    19   aubio_mfcc_do (o, in, out);
    20   fvec_print (out);
    2116  aubio_mfcc_do (o, in, out);
    2217  fvec_print (out);
    2318
     19  cvec_set (in, .5);
     20  aubio_mfcc_do (o, in, out);
     21  fvec_print (out);
     22
     23  // clean up
    2424  del_aubio_mfcc (o);
    2525  del_cvec (in);
  • tests/src/spectral/test-phasevoc-jack.c

    r714d05e rbab24a0  
    1515#endif /* HAVE_JACK */
    1616
    17 uint_t testing  = 0;  /* change this to 1 to listen        */
     17uint_t testing  = 0;  // change this to 1 to listen
    1818
    19 uint_t win_s    = 512;/* window size                       */
    20 uint_t hop_s    = 128;/* hop size                          */
    21 uint_t channels = 2;  /* number of audio channels          */
    22 uint_t midiin   = 4;  /* number of midi input channels     */
    23 uint_t midiout  = 2;  /* number of midi output channels    */
    24 uint_t pos      = 0;  /* frames%dspblocksize for jack loop */
     19uint_t win_s    = 512; // window size
     20uint_t hop_s    = 128; // hop size
     21uint_t channels = 2; // number of audio channels
     22uint_t midiin   = 4; // number of midi input channels
     23uint_t midiout  = 2; // number of midi output channels
     24uint_t pos      = 0; // frames%dspblocksize for jack loop
    2525
    2626fvec_t * in[2];
     
    3232int aubio_process(float **input, float **output, int nframes);
    3333
    34 int main(){
    35         /* allocate some memory */
     34int main ()
     35{
     36  /* allocate some memory */
    3637  uint_t i;
    37     for (i=0;i<channels;i++) {
    38         in[i]       = new_fvec (hop_s); /* input buffer       */
    39         fftgrain[i] = new_cvec (win_s); /* fft norm and phase */
    40         out[i]      = new_fvec (hop_s); /* output buffer      */
    41         /* allocate fft and other memory space */
    42         pv[i] = new_aubio_pvoc(win_s,hop_s);
    43     }
     38  for (i=0;i<channels;i++) {
     39    in[i]       = new_fvec (hop_s); /* input buffer       */
     40    fftgrain[i] = new_cvec (win_s); /* fft norm and phase */
     41    out[i]      = new_fvec (hop_s); /* output buffer      */
     42    /* allocate fft and other memory space */
     43    pv[i] = new_aubio_pvoc(win_s,hop_s);
     44  }
    4445
    4546#ifdef HAVE_JACK
    46         aubio_jack_t * jack_setup;
    47         jack_setup  = new_aubio_jack(channels, channels,
    48             midiin, midiout,
    49             (aubio_process_func_t)aubio_process);
    50         aubio_jack_activate(jack_setup);
    51         /* stay in main jack loop for 1 seconds only */
    52         do {
    53           sleep(1);
    54         } while(testing);
    55         aubio_jack_close(jack_setup);
     47  aubio_jack_t * jack_setup;
     48  jack_setup  = new_aubio_jack(channels, channels,
     49      midiin, midiout,
     50      (aubio_process_func_t)aubio_process);
     51  aubio_jack_activate(jack_setup);
     52  /* stay in main jack loop for 1 seconds only */
     53  do {
     54    sleep(1);
     55  } while(testing);
     56  aubio_jack_close(jack_setup);
    5657#else
    57         fprintf(stderr, "WARNING: no jack support\n");
     58  fprintf(stderr, "WARNING: no jack support\n");
    5859#endif
    59        
    60     for (i=0;i<channels;i++) {
    61         del_aubio_pvoc(pv[i]);
    62         del_cvec(fftgrain[i]);
    63         del_fvec(in[i]);
    64         del_fvec(out[i]);
    65     }
    66         aubio_cleanup();
    67         return 0;
     60
     61  for (i=0;i<channels;i++) {
     62    del_aubio_pvoc(pv[i]);
     63    del_cvec(fftgrain[i]);
     64    del_fvec(in[i]);
     65    del_fvec(out[i]);
     66  }
     67  aubio_cleanup();
     68  return 0;
    6869}
    6970
     
    8182    if (pos == hop_s-1) {
    8283      /* block loop */
    83     for (i=0;i<channels;i++) {
    84       aubio_pvoc_do (pv[i], in[i], fftgrain[i]);
    85       // zero phases of first channel
    86       for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.;
    87       // double phases of second channel
    88       for (i=0;i<fftgrain[i]->length;i++) {
    89         fftgrain[1]->phas[i] =
    90           aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.);
     84      for (i=0;i<channels;i++) {
     85        aubio_pvoc_do (pv[i], in[i], fftgrain[i]);
     86        // zero phases of first channel
     87        for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.;
     88        // double phases of second channel
     89        for (i=0;i<fftgrain[i]->length;i++) {
     90          fftgrain[1]->phas[i] =
     91            aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.);
     92        }
     93        // copy second channel to third one
     94        aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]);
     95        pos = -1;
    9196      }
    92       // copy second channel to third one
    93       aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]);
    94       pos = -1;
    95     }
    9697    }
    9798    pos++;
  • tests/src/spectral/test-phasevoc.c

    r714d05e rbab24a0  
    1 /* test sample for phase vocoder */
    2 
    3 #include <stdio.h>
    41#include <aubio.h>
    52
    6 int main(){
    7         uint_t win_s    = 1024; /* window size                       */
    8         uint_t hop_s    = 256;  /* hop size                          */
    9         /* allocate some memory */
    10         fvec_t * in       = new_fvec (hop_s); /* input buffer       */
    11         cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
    12         fvec_t * out      = new_fvec (hop_s); /* output buffer      */
    13         /* allocate fft and other memory space */
    14         aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
    15         /* fill input with some data */
    16         printf("initialised\n");
    17         /* execute stft */
    18         aubio_pvoc_do (pv,in,fftgrain);
    19         printf("computed forward\n");
    20         /* execute inverse fourier transform */
    21         aubio_pvoc_rdo(pv,fftgrain,out);
    22         printf("computed backard\n");
    23         del_aubio_pvoc(pv);
    24         del_fvec(in);
    25         del_cvec(fftgrain);
    26         del_fvec(out);
    27         aubio_cleanup();
    28         printf("memory freed\n");
    29         return 0;
     3int main ()
     4{
     5  uint_t n = 6; // compute n times
     6  uint_t win_s = 32; // window size
     7  uint_t hop_s = win_s / 4; // hop size
     8
     9  fvec_t * in = new_fvec (hop_s); // input buffer
     10  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
     11  fvec_t * out = new_fvec (hop_s); // output buffer
     12
     13  // allocate fft and other memory space
     14  aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);
     15
     16  // fill input with some data
     17  fvec_set (in, 1.);
     18  fvec_print (in);
     19
     20  while ( n-- ) {
     21    // get some fresh input data
     22    // ..
     23
     24    // execute phase vocoder
     25    aubio_pvoc_do (pv,in,fftgrain);
     26
     27    // do something with fftgrain
     28    // ...
     29    cvec_print (fftgrain);
     30
     31    // optionnaly rebuild the signa
     32    aubio_pvoc_rdo(pv,fftgrain,out);
     33
     34    // and do something with the result
     35    // ...
     36    fvec_print (out);
     37  }
     38
     39  // clean up
     40  del_fvec(in);
     41  del_cvec(fftgrain);
     42  del_fvec(out);
     43  del_aubio_pvoc(pv);
     44  aubio_cleanup();
     45
     46  return 0;
    3047}
  • tests/src/spectral/test-specdesc.c

    r714d05e rbab24a0  
    1 
    2 #define AUBIO_UNSTABLE 1
    3 
    41#include <aubio.h>
    52
    6 int
    7 main ()
     3int main ()
    84{
    9   uint_t win_s = 1024;          /* window size */
    10   cvec_t *in = new_cvec (win_s);      /* input buffer */
    11   fvec_t *out = new_fvec (1); /* input buffer */
     5  uint_t win_s = 1024; // window size
     6  cvec_t *in = new_cvec (win_s); // input buffer
     7  fvec_t *out = new_fvec (1); // output spectral descriptor
    128
    139  aubio_specdesc_t *o;
    14  
     10
    1511  o = new_aubio_specdesc ("energy", win_s);
    1612  aubio_specdesc_do (o, in, out);
  • tests/src/spectral/test-tss.c

    r714d05e rbab24a0  
    1 /* test sample for phase vocoder
    2  *
    3  * this program should start correctly using JACK_START_SERVER=true and
    4  * reconstruct each audio input frame perfectly on the corresponding input with
    5  * a delay equal to the window size, hop_s.
    6  */
    7 
    8 #include <stdio.h>
    9 #define AUBIO_UNSTABLE 1
    101#include <aubio.h>
    112
    12 int main(){
    13   int i;
    14   uint_t win_s    = 1024; /* window size                       */
    15   uint_t hop_s    = 256;  /* hop size                          */
     3int main ()
     4{
     5  uint_t n = 10; // compute n times
     6  uint_t win_s = 1024; // window size
     7  uint_t hop_s = 256;  // hop size
    168
    17   /* allocate some memory */
    18   fvec_t * in       = new_fvec (hop_s); /* input buffer       */
    19   cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
    20   cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
    21   cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
    22   fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
    23   fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
    24   /* allocate phase vocoders and transient steady-state separation */
     9  // create some vectors
     10  fvec_t * in       = new_fvec (hop_s); // input buffer
     11  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
     12  cvec_t * cstead   = new_cvec (win_s); // fft norm and phase
     13  cvec_t * ctrans   = new_cvec (win_s); // fft norm and phase
     14  fvec_t * stead    = new_fvec (hop_s); // output buffer
     15  fvec_t * trans    = new_fvec (hop_s); // output buffer
     16
     17  // create phase vocoder for analysis of input signal
    2518  aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
     19  // create transient/steady-state separation object
     20  aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
     21  // create phase vocoder objects for synthesis of output signals
    2622  aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
    2723  aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
    28   aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
    29 
    30   /* fill input with some data */
    31   printf("initialised\n");
    3224
    3325  /* execute stft */
    34   for (i = 0; i < 10; i++) {
    35     aubio_pvoc_do (pv,in,fftgrain);
    36     aubio_tss_do  (tss,fftgrain,ctrans,cstead);
    37     aubio_pvoc_rdo(pvt,cstead,stead);
    38     aubio_pvoc_rdo(pvs,ctrans,trans);
     26  while ( n-- ) {
     27    // fftgrain = pv(in)
     28    aubio_pvoc_do (pv, in, fftgrain);
     29    // ctrans, cstead = tss (fftgrain)
     30    aubio_tss_do (tss, fftgrain, ctrans, cstead);
     31    // stead = pvt_inverse (cstead)
     32    // trans = pvt_inverse (ctrans)
     33    aubio_pvoc_rdo (pvt, cstead, stead);
     34    aubio_pvoc_rdo (pvs, ctrans, trans);
    3935  }
    4036
     
    5046  del_fvec(stead);
    5147  del_fvec(trans);
     48
    5249  aubio_cleanup();
    53   printf("memory freed\n");
     50
    5451  return 0;
    5552}
  • tests/src/tempo/test-beattracking.c

    r714d05e rbab24a0  
    11#define AUBIO_UNSTABLE 1
    22
    3 #include <stdio.h>
    43#include <aubio.h>
    54
    6 int main(){
    7         /* allocate some memory */
    8         uint_t win_s      = 1024;                       /* window size */
    9         fvec_t * in       = new_fvec (win_s); /* input buffer */
    10         fvec_t * out      = new_fvec (win_s/4);     /* input buffer */
    11  
    12         /* allocate fft and other memory space */
    13         aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s);
     5int main ()
     6{
     7  uint_t i = 0;
     8  uint_t win_s = 1024; // window size
     9  fvec_t * in = new_fvec (win_s); // input buffer
     10  fvec_t * out = new_fvec (2); // output beat position
    1411
    15         uint_t i = 0;
     12  // create beattracking object
     13  aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s);
    1614
    17         smpl_t curtempo, curtempoconf;
     15  smpl_t bpm, confidence;
    1816
    19         while (i < 10) {
    20           aubio_beattracking_do(tempo,in,out);
    21           curtempo = aubio_beattracking_get_bpm(tempo);
    22           if (curtempo != 0.) {
    23             fprintf(stdout,"%f\n",curtempo);
    24             return 1;
    25           }
    26           curtempoconf = aubio_beattracking_get_confidence(tempo);
    27           if (curtempoconf != 0.) {
    28             fprintf(stdout,"%f\n",curtempo);
    29             return 1;
    30           }
    31           i++;
    32         };
     17  while (i < 10) {
     18    // put some fresh data in feature vector
     19    // ...
    3320
    34         del_aubio_beattracking(tempo);
    35         del_fvec(in);
    36         del_fvec(out);
    37         aubio_cleanup();
     21    aubio_beattracking_do(tempo,in,out);
     22    // do something  with the beats
     23    // ...
    3824
    39         return 0;
     25    // get bpm and confidence
     26    bpm = aubio_beattracking_get_bpm(tempo);
     27    confidence = aubio_beattracking_get_confidence(tempo);
     28    i++;
     29  };
     30
     31  del_aubio_beattracking(tempo);
     32  del_fvec(in);
     33  del_fvec(out);
     34  aubio_cleanup();
     35
     36  return 0;
    4037}
    4138
  • tests/src/tempo/test-tempo.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
    32
    4 int main(){
    5         /* allocate some memory */
    6         uint_t win_s      = 1024;                       /* window size */
    7         fvec_t * in       = new_fvec (win_s); /* input buffer */
    8         fvec_t * out      = new_fvec (2);     /* input buffer */
    9         aubio_tempo_t * o  = new_aubio_tempo("complex", win_s, win_s/4, 44100.);
    10         uint_t i = 0;
     3int main ()
     4{
     5  uint_t i = 0;
     6  uint_t win_s = 1024; // window size
     7  fvec_t * in = new_fvec (win_s); // input vector
     8  fvec_t * out = new_fvec (2); // output beat position
    119
    12         smpl_t curtempo, curtempoconf;
     10  // create tempo object
     11  aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.);
    1312
    14         while (i < 1000) {
    15           aubio_tempo_do(o,in,out);
    16           curtempo = aubio_tempo_get_bpm(o);
    17           if (curtempo != 0.) {
    18             fprintf(stdout,"%f\n",curtempo);
    19             return 1;
    20           }
    21           curtempoconf = aubio_tempo_get_confidence(o);
    22           if (curtempoconf != 0.) {
    23             fprintf(stdout,"%f\n",curtempo);
    24             return 1;
    25           }
    26           i++;
    27         };
     13  smpl_t bpm, confidence;
    2814
    29         del_aubio_tempo(o);
    30         del_fvec(in);
    31         del_fvec(out);
    32         aubio_cleanup();
     15  while (i < 1000) {
     16    // put some fresh data in input vector
     17    // ...
    3318
    34         return 0;
     19    // execute tempo
     20    aubio_tempo_do(o,in,out);
     21    // do something with the beats
     22    // ...
     23
     24    // get bpm and confidence
     25    bpm = aubio_tempo_get_bpm(o);
     26    confidence = aubio_tempo_get_confidence(o);
     27
     28    i++;
     29  };
     30
     31  del_aubio_tempo(o);
     32  del_fvec(in);
     33  del_fvec(out);
     34  aubio_cleanup();
     35
     36  return 0;
    3537}
  • tests/src/temporal/test-a_weighting.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int main(){
     3int main ()
     4{
    45 
    56  aubio_filter_t * f;
  • tests/src/temporal/test-biquad.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int main(){
    4         /* allocate some memory */
    5         uint_t win_s      = 1024;                       /* window size */
    6         fvec_t * in       = new_fvec (win_s); /* input buffer */
    7         aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3);
     3int main ()
     4{
     5  uint_t win_s = 64; // window size
    86
    9         aubio_filter_do_filtfilt(o,in,in);
    10         aubio_filter_do(o,in);
     7  // create biquad filter with `b0`, `b1`, `b2`, `a1`, `a2`
     8  aubio_filter_t * o = new_aubio_filter_biquad(0.3,0.2,0.1,0.2,0.3);
    119
    12         del_aubio_filter(o);
    13         del_fvec(in);
    14         return 0;
     10  fvec_t * in_vec  = new_fvec (win_s); // input buffer
     11  fvec_t * tmp_vec = new_fvec (win_s); // temporary buffer
     12  fvec_t * out_vec = new_fvec (win_s); // output buffer
     13
     14  uint_t times = 100;
     15  while ( times-- ) {
     16    // copy to out, then filter out
     17    aubio_filter_do_outplace(o, in_vec, out_vec);
     18    // in-place filtering
     19    aubio_filter_do(o, in_vec);
     20    // in-place filtering
     21    aubio_filter_do_filtfilt(o, in_vec, out_vec);
     22    fvec_print(in_vec);
     23  }
     24
     25  // memory clean-up, one for each new
     26  del_aubio_filter(o);
     27  del_fvec(in_vec);
     28  del_fvec(tmp_vec);
     29  del_fvec(out_vec);
     30
     31  return 0;
    1532}
  • tests/src/temporal/test-c_weighting.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int main(){
    4  
     3int main ()
     4{
    55  aubio_filter_t * f;
    66
  • tests/src/temporal/test-filter.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int
    4 main (void)
     3int main ()
    54{
    6   /* allocate some memory */
    7   uint_t win_s = 32;            /* window size */
    8   fvec_t *in = new_fvec (win_s);      /* input buffer */
    9   fvec_t *out = new_fvec (win_s);     /* input buffer */
    10 
     5  uint_t win_s = 32; // window size
     6  fvec_t *in = new_fvec (win_s); // input buffer
     7  fvec_t *out = new_fvec (win_s); // input buffer
    118
    129  aubio_filter_t *o = new_aubio_filter_c_weighting (44100);
     
    1714  del_aubio_filter (o);
    1815
    19   o = new_aubio_filter_c_weighting (44100);
     16  o = new_aubio_filter_a_weighting (32000);
    2017  in->data[12] = 0.5;
    2118  fvec_print (in);
    2219  aubio_filter_do_outplace (o, in, out);
    2320  fvec_print (out);
    24   del_aubio_filter (o);
    2521
    26   o = new_aubio_filter_c_weighting (44100);
     22  aubio_filter_set_a_weighting (o, 32000);
    2723  in->data[12] = 0.5;
    2824  fvec_print (in);
    2925  aubio_filter_do_filtfilt (o, in, out);
    3026  fvec_print (out);
    31   del_aubio_filter (o);
    3227
    3328  del_fvec (in);
    3429  del_fvec (out);
     30  del_aubio_filter (o);
    3531  aubio_cleanup ();
    3632
  • tests/src/temporal/test-resampler.c

    r714d05e rbab24a0  
    1 #include <stdio.h>
    21#include <aubio.h>
    32
    4 int
    5 main ()
     3int main ()
    64{
    7   /* allocate some memory */
    8   uint_t win_s = 1024;          /* window size */
     5  uint_t win_s = 1024; // window size
    96  smpl_t ratio = 0.5;
    10   fvec_t *in = new_fvec (win_s);      /* input buffer */
    11   fvec_t *out = new_fvec ((uint_t) (win_s * ratio));  /* input buffer */
     7  fvec_t *in = new_fvec (win_s); // input buffer
     8  fvec_t *out = new_fvec ((uint_t) (win_s * ratio)); // output buffer
    129  aubio_resampler_t *o = new_aubio_resampler (0.5, 0);
    1310  uint_t i = 0;
  • tests/src/test-cvec.c

    r714d05e rbab24a0  
    11#include <aubio.h>
     2#include "utils_tests.h"
    23
    3 int main(){
    4         /* allocate some memory */
    5         uint_t win_s      = 1024;                       /* window size */
    6         cvec_t * sp       = new_cvec (win_s); /* input buffer */
    7         del_cvec(sp);
     4int main ()
     5{
     6  uint_t i, window_size = 16; // window size
     7  utils_init_random();
     8  cvec_t * complex_vector = new_cvec (window_size); // input buffer
     9  uint_t rand_times = 4;
    810
    9         return 0;
     11  while (rand_times -- ) {
     12    // fill with random phas and norm
     13    for ( i = 0; i < complex_vector->length; i++ ) {
     14      complex_vector->norm[i] = ( 2. / RAND_MAX * random() - 1. );
     15      complex_vector->phas[i] = ( 2. / RAND_MAX * random() - 1. ) * M_PI;
     16    }
     17    // print the vector
     18    cvec_print(complex_vector);
     19  }
     20
     21  // set all vector elements to `0`
     22  cvec_zeros(complex_vector);
     23  for ( i = 0; i < complex_vector->length; i++ ) {
     24    assert( complex_vector->norm[i] == 0. );
     25    // assert( complex_vector->phas[i] == 0 );
     26  }
     27  cvec_print(complex_vector);
     28
     29  // set all vector elements to `1`
     30  cvec_ones(complex_vector);
     31  for ( i = 0; i < complex_vector->length; i++ ) {
     32    assert( complex_vector->norm[i] == 1. );
     33    // assert( complex_vector->phas[i] == 0 );
     34  }
     35  cvec_print(complex_vector);
     36  // destroy it
     37  del_cvec(complex_vector);
     38  return 0;
    1039}
    11 
  • tests/src/test-fmat.c

    r714d05e rbab24a0  
    11#include <aubio.h>
     2#include <assert.h>
    23
    3 int main(){
    4         uint_t length = 1024;                     /* length */
    5         uint_t height = 1024;                     /* height */
    6         fmat_t * mat = new_fmat (length, height); /* input buffer */
    7         fmat_print(mat);
    8         del_fmat(mat);
    9         return 0;
     4// create a new matrix and fill it with i * 1. + j * .1, where i is the row,
     5// and j the column.
     6
     7int main ()
     8{
     9  uint_t height = 3, length = 9, i, j;
     10  // create fmat_t object
     11  fmat_t * mat = new_fmat (length, height);
     12  for ( i = 0; i < mat->height; i++ ) {
     13    for ( j = 0; j < mat->length; j++ ) {
     14      // all elements are already initialized to 0.
     15      assert(mat->data[i][j] == 0);
     16      // setting element of row i, column j
     17      mat->data[i][j] = i * 1. + j *.1;
     18    }
     19  }
     20  // print out matrix
     21  fmat_print(mat);
     22  // destroy it
     23  del_fmat(mat);
     24  return 0;
    1025}
    1126
  • tests/src/test-fvec.c

    r714d05e rbab24a0  
    22#include <assert.h>
    33
    4 int main(){
    5   uint_t buffer_size = 1024;
    6   fvec_t * in = new_fvec (buffer_size);
     4int main ()
     5{
     6  uint_t vec_size = 10, i;
     7  fvec_t * vec = new_fvec (vec_size);
    78
    8   assert( in->length                == buffer_size);
     9  // vec->length matches requested size
     10  assert(vec->length == vec_size);
    911
    10   assert( in->data[0]               == 0);
    11   assert( in->data[buffer_size / 2] == 0);
    12   assert( in->data[buffer_size - 1] == 0);
     12  // all elements are initialized to `0.`
     13  for ( i = 0; i < vec->length; i++ ) {
     14    assert(vec->data[i] == 0.);
     15  }
    1316
    14   in->data[buffer_size -1 ] = 1;
    15   assert( in->data[buffer_size - 1] == 1);
     17  // all elements can be set to `0.`
     18  fvec_zeros(vec);
     19  for ( i = 0; i < vec->length; i++ ) {
     20    assert(vec->data[i] == 0.);
     21  }
     22  fvec_print(vec);
    1623
    17   del_fvec(in);
     24  // all elements can be set to `1.`
     25  fvec_ones(vec);
     26  for ( i = 0; i < vec->length; i++ ) {
     27    assert(vec->data[i] == 1.);
     28  }
     29  fvec_print(vec);
     30
     31  // each element can be accessed directly
     32  for ( i = 0; i < vec->length; i++ ) {
     33    vec->data[i] = i;
     34    assert(vec->data[i] == i);
     35  }
     36  fvec_print(vec);
     37
     38  // now destroys the vector
     39  del_fvec(vec);
    1840
    1941  return 0;
  • tests/src/test-lvec.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    22
    3 int main(){
    4         /* allocate some memory */
    5         uint_t win_s      = 1024;                       /* window size */
    6         lvec_t * sp       = new_lvec (win_s); /* input buffer */
    7         del_lvec(sp);
    8 
    9         return 0;
     3int main()
     4{
     5  uint_t win_s = 1024; // window size
     6  lvec_t * sp = new_lvec (win_s); // input buffer
     7  del_lvec(sp);
     8  return 0;
    109}
    1110
  • tests/src/test-mathutils-window.c

    r714d05e rbab24a0  
    11#include <aubio.h>
    2 #include <stdlib.h>
     2#include <math.h>
     3#include <stdio.h>
    34
    4 int main( )
     5int main ()
    56{
    6   uint_t length;
    7   for (length = 2; length <= 5; length++)
    8   {
    9     fvec_t *t = new_aubio_window("rectangle", length);
    10     del_fvec(t);
    11     t = new_aubio_window("hamming", length);
    12     fvec_print(t);
    13     del_fvec(t);
    14     t = new_aubio_window("hanning", length);
    15     fvec_print(t);
    16     del_fvec(t);
    17     t = new_aubio_window("hanningz", length);
    18     fvec_print(t);
    19     del_fvec(t);
    20     t = new_aubio_window("blackman", length);
    21     fvec_print(t);
    22     del_fvec(t);
    23     t = new_aubio_window("blackman_harris", length);
    24     fvec_print(t);
    25     del_fvec(t);
    26     t = new_aubio_window("gaussian", length);
    27     fvec_print(t);
    28     del_fvec(t);
    29     t = new_aubio_window("welch", length);
    30     fvec_print(t);
    31     del_fvec(t);
    32     t = new_aubio_window("parzen", length);
    33     fvec_print(t);
    34     del_fvec(t);
    35     t = new_aubio_window("default", length);
    36     fvec_print(t);
    37     del_fvec(t);
     7  uint_t length = 0;
     8  uint_t n_length = 4, n_types = 10, i, t;
     9  uint_t lengths[4] = { 8, 10, 15, 16 };
     10  char *method = "default";
     11  char *window_types[10] = { "default",
     12    "rectangle", "hamming", "hanning", "hanningz",
     13    "blackman", "blackman_harris", "gaussian", "welch", "parzen"};
     14
     15  for ( t = 0; t < n_types; t ++ ) {
     16    for ( i = 0; i < n_length; i++)
     17    {
     18      length = lengths[i];
     19      method = window_types[t];
     20
     21      fvec_t * window = new_aubio_window(method, length);
     22
     23      fvec_set_window(window, method);
     24      fprintf(stdout, "length: %d, method: %s, window:, ", length, method);
     25      fvec_print(window);
     26
     27      del_fvec(window);
     28    }
    3829  }
    3930  return 0;
  • tests/src/test-mathutils.c

    r714d05e rbab24a0  
    44#include <aubio.h>
    55
    6 int main(){
     6int test_next_power_of_two()
     7{
    78  uint_t a, b;
     9  a = 15; b = aubio_next_power_of_two(a); assert(b == 16);
     10  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
    811
    9   a = 31; b = aubio_next_power_of_two(a);
    10   fprintf(stdout, "next_power_of_two of %d is %d\n", a, b);
    11   assert(b == 32);
     12  a = 17; b = aubio_next_power_of_two(a); assert(b == 32);
     13  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
    1214
    13   a = 32; b = aubio_next_power_of_two(a);
    14   fprintf(stdout, "next_power_of_two of %d is %d\n", a, b);
    15   assert(b == 32);
     15  a = 31; b = aubio_next_power_of_two(a); assert(b == 32);
     16  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
    1617
    17   a = 33; b = aubio_next_power_of_two(a);
    18   fprintf(stdout, "next_power_of_two of %d is %d\n", a, b);
    19   assert(b == 64);
     18  a = 32; b = aubio_next_power_of_two(a); assert(b == 32);
     19  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
     20
     21  a = 33; b = aubio_next_power_of_two(a); assert(b == 64);
     22  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
    2023
    2124  return 0;
    2225}
    2326
     27int test_miditofreq()
     28{
     29  smpl_t midi, freq;
     30  for ( midi = 0; midi < 128; midi += 3 ) {
     31    freq = aubio_miditofreq(midi);
     32    fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     33  }
     34  midi = 69.5;
     35  freq = aubio_miditofreq(midi);
     36  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     37  midi = -69.5;
     38  freq = aubio_miditofreq(midi);
     39  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     40  midi = -169.5;
     41  freq = aubio_miditofreq(midi);
     42  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     43  midi = 140.;
     44  freq = aubio_miditofreq(midi);
     45  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     46  midi = 0;
     47  freq = aubio_miditofreq(midi);
     48  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     49  midi = 8.2e10;
     50  freq = aubio_miditofreq(midi);
     51  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     52  midi = -5.e10;
     53  freq = aubio_miditofreq(midi);
     54  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
     55  return 0;
     56}
     57
     58int test_freqtomidi()
     59{
     60  smpl_t midi, freq;
     61  for ( freq = 0.; freq < 30000.; freq += 440. ) {
     62    midi = aubio_freqtomidi(freq);
     63    fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     64  }
     65  freq = 69.5;
     66  midi = aubio_freqtomidi(freq);
     67  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     68  freq = -69.5;
     69  midi = aubio_freqtomidi(freq);
     70  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     71  freq = -169.5;
     72  midi = aubio_freqtomidi(freq);
     73  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     74  freq = 140.;
     75  midi = aubio_freqtomidi(freq);
     76  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     77  freq = 0;
     78  midi = aubio_freqtomidi(freq);
     79  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     80  freq = 8.2e10;
     81  midi = aubio_freqtomidi(freq);
     82  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     83  freq = -5.;
     84  midi = aubio_freqtomidi(freq);
     85  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
     86  return 0;
     87}
     88
     89int test_aubio_window()
     90{
     91  uint_t window_size = 16;
     92  fvec_t * window = new_aubio_window("default", window_size);
     93  del_fvec(window);
     94
     95  window = new_fvec(window_size);
     96  fvec_set_window(window, "rectangle");
     97  fvec_print(window);
     98
     99  window_size /= 2.;
     100  window = new_aubio_window("triangle", window_size);
     101  fvec_print(window);
     102  del_fvec(window);
     103
     104  window = new_aubio_window("rectangle", 16);
     105  del_fvec (window);
     106  return 0;
     107}
     108
     109int main ()
     110{
     111  test_next_power_of_two();
     112  test_miditofreq();
     113  test_freqtomidi();
     114  return 0;
     115}
  • tests/src/utils/test-hist.c

    r714d05e rbab24a0  
    22
    33#include <aubio.h>
    4 #include <stdlib.h>
    54
    6 int main( )
     5int main ()
    76{
    87  uint_t length;
  • tests/src/utils/test-scale.c

    r714d05e rbab24a0  
    33#include <aubio.h>
    44
    5 int main(){
    6         /* allocate some memory */
    7         uint_t win_s      = 1024;                       /* window size */
    8         fvec_t * in       = new_fvec (win_s); /* input buffer */
    9         aubio_scale_t * o = new_aubio_scale(0,1,2,3);
    10         aubio_scale_set_limits (o,0,1,2,3);
    11         uint_t i = 0;
     5int main ()
     6{
     7  uint_t n = 0;
     8  uint_t win_s = 1024; // window size
     9  fvec_t * in = new_fvec (win_s); // input buffer
     10  aubio_scale_t * o = new_aubio_scale(0,1,2,3);
     11  aubio_scale_set_limits (o,0,1,2,3);
    1212
    13         while (i < 1000) {
    14           aubio_scale_do(o,in);
    15           i++;
    16         };
     13  while (n < 1000) {
     14    aubio_scale_do(o,in);
     15    n++;
     16  };
    1717
    18         del_aubio_scale(o);
    19         del_fvec(in);
     18  del_aubio_scale(o);
     19  del_fvec(in);
    2020
    21         return 0;
     21  return 0;
    2222}
  • tests/wscript_build

    r714d05e rbab24a0  
    33for target_name in ctx.path.ant_glob('src/**/*.c'):
    44  uselib = []
    5   includes = ['../src']
     5  includes = ['../src', '.']
    66  extra_source = []
    77  if str(target_name).endswith('-jack.c') and ctx.env['JACK']:
Note: See TracChangeset for help on using the changeset viewer.