Changeset 66fb3ea


Ignore:
Timestamp:
Dec 4, 2009, 1:33:06 AM (14 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:
0b9a02a
Parents:
c7860af
Message:

modified cvec to be mono

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/cvec.c

    rc7860af r66fb3ea  
    2222#include "cvec.h"
    2323
    24 cvec_t * new_cvec( uint_t length, uint_t channels) {
     24cvec_t * new_cvec( uint_t length) {
    2525  cvec_t * s = AUBIO_NEW(cvec_t);
    26   uint_t i,j;
    27   s->channels = channels;
     26  uint_t j;
    2827  s->length = length/2 + 1;
    29   s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
    30   s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
    31   for (i=0; i< s->channels; i++) {
    32     s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
    33     s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
    34     for (j=0; j< s->length; j++) {
    35       s->norm[i][j]=0.;
    36       s->phas[i][j]=0.;
    37     }
     28  s->norm = AUBIO_ARRAY(smpl_t,s->length);
     29  s->phas = AUBIO_ARRAY(smpl_t,s->length);
     30  for (j=0; j< s->length; j++) {
     31    s->norm[j]=0.;
     32    s->phas[j]=0.;
    3833  }
    3934  return s;
     
    4136
    4237void del_cvec(cvec_t *s) {
    43   uint_t i;
    44   for (i=0; i<s->channels; i++) {
    45     AUBIO_FREE(s->norm[i]);
    46     AUBIO_FREE(s->phas[i]);
    47   }
    4838  AUBIO_FREE(s->norm);
    4939  AUBIO_FREE(s->phas);
     
    5141}
    5242
    53 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    54   s->norm[channel][position] = data;
     43void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
     44  s->norm[position] = data;
    5545}
    56 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    57   s->phas[channel][position] = data;
     46void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
     47  s->phas[position] = data;
    5848}
    59 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
    60   return s->norm[channel][position];
     49smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
     50  return s->norm[position];
    6151}
    62 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
    63   return s->phas[channel][position];
     52smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
     53  return s->phas[position];
    6454}
    65 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
    66   s->norm[channel] = data;
    67 }
    68 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
    69   s->phas[channel] = data;
    70 }
    71 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
    72   return s->norm[channel];
    73 }
    74 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
    75   return s->phas[channel];
    76 }
    77 smpl_t ** cvec_get_norm(cvec_t *s) {
     55smpl_t * cvec_get_norm(cvec_t *s) {
    7856  return s->norm;
    7957}
    80 smpl_t ** cvec_get_phas(cvec_t *s) {
     58smpl_t * cvec_get_phas(cvec_t *s) {
    8159  return s->phas;
    8260}
     
    8563
    8664void cvec_print(cvec_t *s) {
    87   uint_t i,j;
    88   for (i=0; i< s->channels; i++) {
    89     AUBIO_MSG("norm: ");
    90     for (j=0; j< s->length; j++) {
    91       AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]);
    92     }
    93     AUBIO_MSG("\n");
    94     AUBIO_MSG("phas: ");
    95     for (j=0; j< s->length; j++) {
    96       AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]);
    97     }
    98     AUBIO_MSG("\n");
     65  uint_t j;
     66  AUBIO_MSG("norm: ");
     67  for (j=0; j< s->length; j++) {
     68    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]);
    9969  }
     70  AUBIO_MSG("\n");
     71  AUBIO_MSG("phas: ");
     72  for (j=0; j< s->length; j++) {
     73    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]);
     74  }
     75  AUBIO_MSG("\n");
    10076}
    10177
    10278void cvec_set(cvec_t *s, smpl_t val) {
    103   uint_t i,j;
    104   for (i=0; i< s->channels; i++) {
    105     for (j=0; j< s->length; j++) {
    106       s->norm[i][j] = val;
    107     }
     79  uint_t j;
     80  for (j=0; j< s->length; j++) {
     81    s->norm[j] = val;
    10882  }
    10983}
  • src/cvec.h

    rc7860af r66fb3ea  
    3939typedef struct {
    4040  uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
    41   uint_t channels; /**< number of channels */
    42   smpl_t **norm;   /**< norm array of size [length] * [channels] */
    43   smpl_t **phas;   /**< phase array of size [length] * [channels] */
     41  smpl_t *norm;   /**< norm array of size [length] */
     42  smpl_t *phas;   /**< phase array of size [length] */
    4443} cvec_t;
    4544
     
    4746
    4847  This function creates a cvec_t structure holding two arrays of size
    49   [length/2+1] * channels, corresponding to the norm and phase values of the
     48  [length/2+1], corresponding to the norm and phase values of the
    5049  spectral frame. The length stored in the structure is the actual size of both
    5150  arrays, not the length of the complex and symetrical vector, specified as
     
    5352
    5453  \param length the length of the buffer to create
    55   \param channels the number of channels in the buffer
    5654
    5755*/
    58 cvec_t * new_cvec(uint_t length, uint_t channels);
     56cvec_t * new_cvec(uint_t length);
    5957/** cvec_t buffer deletion function
    6058
     
    6664
    6765  Note that this function is not used in the aubio library, since the same
    68   result can be obtained by assigning vec->norm[channel][position]. Its purpose
     66  result can be obtained by assigning vec->norm[position]. Its purpose
    6967  is to access these values from wrappers, as created by swig.
    7068
    7169  \param s vector to write to
    72   \param data norm value to write in s->norm[channel][position]
    73   \param channel channel to write to
     70  \param data norm value to write in s->norm[position]
    7471  \param position sample position to write to
    7572
    7673*/
    77 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
     74void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
    7875/** write phase value in a complex buffer
    7976
    8077  Note that this function is not used in the aubio library, since the same
    81   result can be obtained by assigning vec->phas[channel][position]. Its purpose
     78  result can be obtained by assigning vec->phas[position]. Its purpose
    8279  is to access these values from wrappers, as created by swig.
    8380
    8481  \param s vector to write to
    85   \param data phase value to write in s->phas[channel][position]
    86   \param channel channel to write to
     82  \param data phase value to write in s->phas[position]
    8783  \param position sample position to write to
    8884
    8985*/
    90 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
     86void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
    9187/** read norm value from a complex buffer
    9288
    9389  Note that this function is not used in the aubio library, since the same
    94   result can be obtained with vec->norm[channel][position]. Its purpose is to
     90  result can be obtained with vec->norm[position]. Its purpose is to
    9591  access these values from wrappers, as created by swig.
    9692
    9793  \param s vector to read from
    98   \param channel channel to read from
    9994  \param position sample position to read from
    10095
    10196*/
    102 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
     97smpl_t cvec_read_norm(cvec_t *s, uint_t position);
    10398/** read phase value from a complex buffer
    10499
    105100  Note that this function is not used in the aubio library, since the same
    106   result can be obtained with vec->phas[channel][position]. Its purpose is to
     101  result can be obtained with vec->phas[position]. Its purpose is to
    107102  access these values from wrappers, as created by swig.
    108103
    109104  \param s vector to read from
    110   \param channel channel to read from
    111105  \param position sample position to read from
    112106
    113107*/
    114 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
    115 /** write norm channel in a complex buffer
    116 
    117   Note that this function is not used in the aubio library, since the same
    118   result can be obtained by assigning vec->norm[channel]. Its purpose is to
    119   access these values from wrappers, as created by swig.
    120 
    121   \param s vector to write to
    122   \param data norm vector of [length] samples to write in s->norm[channel]
    123   \param channel channel to write to
    124 
    125 */
    126 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
    127 /** write phase channel in a complex buffer
    128 
    129   Note that this function is not used in the aubio library, since the same
    130   result can be obtained by assigning vec->phas[channel]. Its purpose is to
    131   access these values from wrappers, as created by swig.
    132 
    133   \param s vector to write to
    134   \param data phase vector of [length] samples to write in s->phas[channel]
    135   \param channel channel to write to
    136 
    137 */
    138 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
    139 /** read norm channel from a complex buffer
    140 
    141   Note that this function is not used in the aubio library, since the same
    142   result can be obtained with vec->norm[channel]. Its purpose is to access
    143   these values from wrappers, as created by swig.
    144 
    145   \param s vector to read from
    146   \param channel channel to read from
    147 
    148 */
    149 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
    150 /** write phase channel in a complex buffer
    151 
    152   Note that this function is not used in the aubio library, since the same
    153   result can be obtained with vec->phas[channel]. Its purpose is to access
    154   these values from wrappers, as created by swig.
    155 
    156   \param s vector to read from
    157   \param channel channel to read from
    158 
    159 */
    160 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
     108smpl_t cvec_read_phas(cvec_t *s, uint_t position);
    161109/** read norm data from a complex buffer
    162110
     
    168116
    169117*/
    170 smpl_t ** cvec_get_norm(cvec_t *s);
     118smpl_t * cvec_get_norm(cvec_t *s);
    171119/** read phase data from a complex buffer
    172120
     
    178126
    179127*/
    180 smpl_t ** cvec_get_phas(cvec_t *s);
     128smpl_t * cvec_get_phas(cvec_t *s);
    181129
    182130/** print out cvec data
Note: See TracChangeset for help on using the changeset viewer.