Changeset 66fb3ea for src/cvec.c


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

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.