Changeset 5d10ac1


Ignore:
Timestamp:
Dec 17, 2013, 5:11:35 PM (10 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
c34336e
Parents:
b0ab6ef
Message:

src/cvec.h: clean up cvec api

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/cvec.c

    rb0ab6ef r5d10ac1  
    3939}
    4040
    41 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
     41void cvec_norm_set_sample (cvec_t *s, smpl_t data, uint_t position) {
    4242  s->norm[position] = data;
    4343}
    44 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
     44
     45void cvec_phas_set_sample (cvec_t *s, smpl_t data, uint_t position) {
    4546  s->phas[position] = data;
    4647}
    47 smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
     48
     49smpl_t cvec_norm_get_sample (cvec_t *s, uint_t position) {
    4850  return s->norm[position];
    4951}
    50 smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
     52
     53smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position) {
    5154  return s->phas[position];
    5255}
    53 smpl_t * cvec_get_norm(cvec_t *s) {
     56
     57smpl_t * cvec_norm_get_data (cvec_t *s) {
    5458  return s->norm;
    5559}
    56 smpl_t * cvec_get_phas(cvec_t *s) {
     60
     61smpl_t * cvec_phas_get_data (cvec_t *s) {
    5762  return s->phas;
    5863}
     
    9297}
    9398
    94 void cvec_set_all_norm(cvec_t *s, smpl_t val) {
     99void cvec_norm_set_all (cvec_t *s, smpl_t val) {
    95100  uint_t j;
    96101  for (j=0; j< s->length; j++) {
     
    99104}
    100105
    101 void cvec_zeros_norm(cvec_t *s) {
     106void cvec_norm_zeros(cvec_t *s) {
    102107#if HAVE_MEMCPY_HACKS
    103108  memset(s->norm, 0, s->length * sizeof(smpl_t));
    104109#else
    105   cvec_set_all_norm(s, 0.);
     110  cvec_norm_set_all (s, 0.);
    106111#endif
    107112}
    108113
    109 void cvec_ones_norm(cvec_t *s) {
    110   cvec_set_all_norm(s, 1.);
     114void cvec_norm_ones(cvec_t *s) {
     115  cvec_norm_set_all (s, 1.);
    111116}
    112117
    113 void cvec_set_all_phas(cvec_t *s, smpl_t val) {
     118void cvec_phas_set_all (cvec_t *s, smpl_t val) {
    114119  uint_t j;
    115120  for (j=0; j< s->length; j++) {
     
    118123}
    119124
    120 void cvec_zeros_phas(cvec_t *s) {
     125void cvec_phas_zeros(cvec_t *s) {
    121126#if HAVE_MEMCPY_HACKS
    122127  memset(s->phas, 0, s->length * sizeof(smpl_t));
    123128#else
    124   cvec_set_all_phas(s, 0.);
     129  cvec_phas_set_all (s, 0.);
    125130#endif
    126131}
    127132
    128 void cvec_ones_phas(cvec_t *s) {
    129   cvec_set_all_phas(s, 1.);
     133void cvec_phas_ones(cvec_t *s) {
     134  cvec_phas_set_all (s, 1.);
    130135}
    131136
    132137void cvec_zeros(cvec_t *s) {
    133   cvec_zeros_norm(s);
    134   cvec_zeros_phas(s);
     138  cvec_norm_zeros(s);
     139  cvec_phas_zeros(s);
    135140}
  • src/cvec.h

    rb0ab6ef r5d10ac1  
    2828/** \file
    2929
    30   Vector of complex-valued data
     30  Vector of complex-valued data, stored in polar coordinates
    3131
    3232  This file specifies the ::cvec_t buffer type, which is used throughout aubio
    3333  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.
     34  and norm, within 2 vectors of ::smpl_t of size (size/2+1) each.
    3535
    3636  \example test-cvec.c
     
    3838*/
    3939
    40 /** Buffer for complex data
     40/** Vector of real-valued phase and spectrum data
    4141
    4242  \code
     
    7979*/
    8080cvec_t * new_cvec(uint_t length);
     81
    8182/** cvec_t buffer deletion function
    8283
     
    8586*/
    8687void del_cvec(cvec_t *s);
     88
    8789/** write norm value in a complex buffer
    8890
    89   Note that this function is not used in the aubio library, since the same
    90   result can be obtained by assigning vec->norm[position]. Its purpose
    91   is to access these values from wrappers, as created by swig.
     91  This is equivalent to:
     92  \code
     93  s->norm[position] = val;
     94  \endcode
    9295
    9396  \param s vector to write to
    94   \param data norm value to write in s->norm[position]
     97  \param val norm value to write in s->norm[position]
    9598  \param position sample position to write to
    9699
    97100*/
    98 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
     101void cvec_norm_set_sample (cvec_t *s, smpl_t val, uint_t position);
     102
    99103/** write phase value in a complex buffer
    100104
    101   Note that this function is not used in the aubio library, since the same
    102   result can be obtained by assigning vec->phas[position]. Its purpose
    103   is to access these values from wrappers, as created by swig.
     105  This is equivalent to:
     106  \code
     107  s->phas[position] = val;
     108  \endcode
    104109
    105110  \param s vector to write to
    106   \param data phase value to write in s->phas[position]
     111  \param val phase value to write in s->phas[position]
    107112  \param position sample position to write to
    108113
    109114*/
    110 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
     115void cvec_phas_set_sample (cvec_t *s, smpl_t val, uint_t position);
     116
    111117/** read norm value from a complex buffer
    112118
    113   Note that this function is not used in the aubio library, since the same
    114   result can be obtained with vec->norm[position]. Its purpose is to
    115   access these values from wrappers, as created by swig.
     119  This is equivalent to:
     120  \code
     121  smpl_t foo = s->norm[position];
     122  \endcode
    116123
    117124  \param s vector to read from
     
    119126
    120127*/
    121 smpl_t cvec_read_norm(cvec_t *s, uint_t position);
     128smpl_t cvec_norm_get_sample (cvec_t *s, uint_t position);
     129
    122130/** read phase value from a complex buffer
    123131
    124   Note that this function is not used in the aubio library, since the same
    125   result can be obtained with vec->phas[position]. Its purpose is to
    126   access these values from wrappers, as created by swig.
     132  This is equivalent to:
     133  \code
     134  smpl_t foo = s->phas[position];
     135  \endcode
    127136
    128137  \param s vector to read from
    129138  \param position sample position to read from
    130 
    131 */
    132 smpl_t cvec_read_phas(cvec_t *s, uint_t position);
     139  \returns the value of the sample at position
     140
     141*/
     142smpl_t cvec_phas_get_sample (cvec_t *s, uint_t position);
     143
    133144/** read norm data from a complex buffer
    134145
    135   Note that this function is not used in the aubio library, since the same
    136   result can be obtained with vec->norm. Its purpose is to access these values
    137   from wrappers, as created by swig.
    138 
    139   \param s vector to read from
    140 
    141 */
    142 smpl_t * cvec_get_norm(cvec_t *s);
     146  \code
     147  smpl_t *data = s->norm;
     148  \endcode
     149
     150  \param s vector to read from
     151
     152*/
     153smpl_t * cvec_norm_get_data (cvec_t *s);
     154
    143155/** read phase data from a complex buffer
    144156
    145   Note that this function is not used in the aubio library, since the same
    146   result can be obtained with vec->phas. Its purpose is to access these values
    147   from wrappers, as created by swig.
    148 
    149   \param s vector to read from
    150 
    151 */
    152 smpl_t * cvec_get_phas(cvec_t *s);
     157  This is equivalent to:
     158  \code
     159  smpl_t *data = s->phas;
     160  \endcode
     161
     162  \param s vector to read from
     163
     164*/
     165smpl_t * cvec_phas_get_data (cvec_t *s);
    153166
    154167/** print out cvec data
     
    173186
    174187*/
    175 void cvec_set_all_norm(cvec_t *s, smpl_t val);
     188void cvec_norm_set_all (cvec_t *s, smpl_t val);
    176189
    177190/** set all norm elements to zero
     
    180193
    181194*/
    182 void cvec_zeros_norm(cvec_t *s);
     195void cvec_norm_zeros(cvec_t *s);
    183196
    184197/** set all norm elements to one
     
    187200
    188201*/
    189 void cvec_ones_norm(cvec_t *s);
     202void cvec_norm_ones(cvec_t *s);
    190203
    191204/** set all phase elements to a given value
     
    195208
    196209*/
    197 void cvec_set_all_phas(cvec_t *s, smpl_t val);
     210void cvec_phas_set_all (cvec_t *s, smpl_t val);
    198211
    199212/** set all phase elements to zero
     
    202215
    203216*/
    204 void cvec_zeros_phas(cvec_t *s);
     217void cvec_phas_zeros(cvec_t *s);
    205218
    206219/** set all phase elements to one
     
    209222
    210223*/
    211 void cvec_ones_phas(cvec_t *s);
     224void cvec_phas_ones(cvec_t *s);
    212225
    213226/** set all norm and phas elements to zero
  • tests/src/spectral/test-mfcc.c

    rb0ab6ef r5d10ac1  
    1313  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);
    1414
    15   cvec_set_all_norm (in, 1.);
     15  cvec_norm_set_all (in, 1.);
    1616  aubio_mfcc_do (o, in, out);
    1717  fvec_print (out);
    1818
    19   cvec_set_all_norm (in, .5);
     19  cvec_norm_set_all (in, .5);
    2020  aubio_mfcc_do (o, in, out);
    2121  fvec_print (out);
  • tests/src/test-cvec.c

    rb0ab6ef r5d10ac1  
    2020
    2121  // set all vector elements to `0`
    22   cvec_zeros_norm(complex_vector);
     22  cvec_norm_zeros(complex_vector);
    2323  for ( i = 0; i < complex_vector->length; i++ ) {
    2424    assert( complex_vector->norm[i] == 0. );
     
    2828
    2929  // set all vector elements to `1`
    30   cvec_ones_norm(complex_vector);
     30  cvec_norm_ones(complex_vector);
    3131  for ( i = 0; i < complex_vector->length; i++ ) {
    3232    assert( complex_vector->norm[i] == 1. );
     
    3636
    3737  cvec_zeros(complex_vector);
    38   cvec_zeros_phas(complex_vector);
    39   cvec_zeros_norm(complex_vector);
    40   cvec_ones_norm(complex_vector);
    41   cvec_ones_phas(complex_vector);
     38  cvec_phas_zeros(complex_vector);
     39  cvec_norm_zeros(complex_vector);
     40  cvec_norm_ones(complex_vector);
     41  cvec_phas_ones(complex_vector);
    4242  cvec_copy(complex_vector, complex_vector);
    4343
Note: See TracChangeset for help on using the changeset viewer.