Changeset d1ec8cb


Ignore:
Timestamp:
Nov 1, 2007, 2:29:08 PM (13 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
cea30b8
Parents:
9f9f63f
Message:

splitted sample.c into fvec.c and cvec.c, kept sample.h for convenience

Location:
src
Files:
3 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    r9f9f63f rd1ec8cb  
    66        fft.h \
    77        sample.h \
     8        fvec.h \
     9        cvec.h \
    810        hist.h \
    911        scale.h \
     
    3436        fft.c \
    3537        fft.h \
    36         sample.c \
    37         sample.h \
     38        fvec.c \
     39        fvec.h \
     40        cvec.c \
     41        cvec.h \
    3842        hist.c \
    3943        hist.h \
  • src/cvec.c

    r9f9f63f rd1ec8cb  
    11/*
    2    Copyright (C) 2003 Paul Brossier
     2   Copyright (C) 2003-2007 Paul Brossier <piem@piem.org>
    33
    44   This program is free software; you can redistribute it and/or modify
     
    1919
    2020#include "aubio_priv.h"
    21 #include "sample.h"
    22 
    23 fvec_t * new_fvec( uint_t length, uint_t channels) {
    24   fvec_t * s = AUBIO_NEW(fvec_t);
    25   uint_t i,j;
    26   s->channels = channels;
    27   s->length = length;
    28   s->data = AUBIO_ARRAY(smpl_t*,s->channels);
    29   for (i=0; i< s->channels; i++) {
    30     s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
    31     for (j=0; j< s->length; j++) {
    32       s->data[i][j]=0.;
    33     }
    34   }
    35   return s;
    36 }
    37 
    38 void del_fvec(fvec_t *s) {
    39   uint_t i;
    40   for (i=0; i<s->channels; i++) {
    41     AUBIO_FREE(s->data[i]);
    42   }
    43   AUBIO_FREE(s->data);
    44   AUBIO_FREE(s);
    45 }
    46 
    47 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
    48   s->data[channel][position] = data;
    49 }
    50 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
    51   return s->data[channel][position];
    52 }
    53 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
    54   s->data[channel] = data;
    55 }
    56 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
    57   return s->data[channel];
    58 }
    59 
    60 smpl_t ** fvec_get_data(fvec_t *s) {
    61   return s->data;
    62 }
     21#include "cvec.h"
    6322
    6423cvec_t * new_cvec( uint_t length, uint_t channels) {
     
    12180  return s->phas;
    12281}
     82
  • src/sample.h

    r9f9f63f rd1ec8cb  
    11/*
    2    Copyright (C) 2003 Paul Brossier
     2   Copyright (C) 2003-2007 Paul Brossier <piem@piem.org>
    33
    44   This program is free software; you can redistribute it and/or modify
     
    2121#define _SAMPLE_H
    2222
    23 #ifdef __cplusplus
    24 extern "C" {
    25 #endif
    26 
    27 /** \file
    28 
    29   Real and complex buffers
    30 
    31   This file specifies fvec_t and cvec_t buffers types, which are used
    32   throughout aubio to store real and complex data. Complex values are stored in
    33   terms of phase and norm.
    34 
    35 */
    36 
    37 /** Sample buffer type */
    38 typedef struct _fvec_t fvec_t;
    39 /** Spectrum buffer type */
    40 typedef struct _cvec_t cvec_t;
    41 /** Buffer for real values */
    42 struct _fvec_t {
    43   uint_t length;   /**< length of buffer */
    44   uint_t channels; /**< number of channels */
    45   smpl_t **data;   /**< data array of size [length] * [channels] */
    46 };
    47 /** Buffer for complex data */
    48 struct _cvec_t {
    49   uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
    50   uint_t channels; /**< number of channels */
    51   smpl_t **norm;   /**< norm array of size [length] * [channels] */
    52   smpl_t **phas;   /**< phase array of size [length] * [channels] */
    53 };
    54 /** fvec_t buffer creation function
    55 
    56   \param length the length of the buffer to create
    57   \param channels the number of channels in the buffer
    58 
    59 */
    60 fvec_t * new_fvec(uint_t length, uint_t channels);
    61 /** fvec_t buffer deletion function
    62 
    63   \param s buffer to delete as returned by new_fvec()
    64 
    65 */
    66 void del_fvec(fvec_t *s);
    67 /** read sample value in a buffer
    68 
    69   Note that this function is not used in the aubio library, since the same
    70   result can be obtained using vec->data[channel][position]. Its purpose is to
    71   access these values from wrappers, as created by swig.
    72 
    73   \param s vector to read from
    74   \param channel channel to read from
    75   \param position sample position to read from
    76 
    77 */
    78 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position);
    79 /** write sample value in a buffer
    80 
    81   Note that this function is not used in the aubio library, since the same
    82   result can be obtained by assigning vec->data[channel][position]. Its purpose
    83   is to access these values from wrappers, as created by swig.
    84 
    85   \param s vector to write to
    86   \param data value to write in s->data[channel][position]
    87   \param channel channel to write to
    88   \param position sample position to write to
    89 
    90 */
    91 void  fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position);
    92 /** read channel vector from a buffer
    93 
    94   Note that this function is not used in the aubio library, since the same
    95   result can be obtained with vec->data[channel]. Its purpose is to access
    96   these values from wrappers, as created by swig.
    97 
    98   \param s vector to read from
    99   \param channel channel to read from
    100 
    101 */
    102 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel);
    103 /** write channel vector into a buffer
    104 
    105   Note that this function is not used in the aubio library, since the same
    106   result can be obtained by assigning vec->data[channel]. Its purpose is to
    107   access these values from wrappers, as created by swig.
    108 
    109   \param s vector to write to
    110   \param data vector of [length] values to write
    111   \param channel channel to write to
    112 
    113 */
    114 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel);
    115 /** read data from a buffer
    116 
    117   Note that this function is not used in the aubio library, since the same
    118   result can be obtained with vec->data. Its purpose is to access these values
    119   from wrappers, as created by swig.
    120 
    121   \param s vector to read from
    122 
    123 */
    124 smpl_t ** fvec_get_data(fvec_t *s);
    125 
    126 /** cvec_t buffer creation function
    127 
    128   This function creates a cvec_t structure holding two arrays of size
    129   [length/2+1] * channels, corresponding to the norm and phase values of the
    130   spectral frame. The length stored in the structure is the actual size of both
    131   arrays, not the length of the complex and symetrical vector, specified as
    132   creation argument.
    133 
    134   \param length the length of the buffer to create
    135   \param channels the number of channels in the buffer
    136 
    137 */
    138 cvec_t * new_cvec(uint_t length, uint_t channels);
    139 /** cvec_t buffer deletion function
    140 
    141   \param s buffer to delete as returned by new_cvec()
    142 
    143 */
    144 void del_cvec(cvec_t *s);
    145 /** write norm value in a complex buffer
    146 
    147   Note that this function is not used in the aubio library, since the same
    148   result can be obtained by assigning vec->norm[channel][position]. Its purpose
    149   is to access these values from wrappers, as created by swig.
    150 
    151   \param s vector to write to
    152   \param data norm value to write in s->norm[channel][position]
    153   \param channel channel to write to
    154   \param position sample position to write to
    155 
    156 */
    157 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
    158 /** write phase value in a complex buffer
    159 
    160   Note that this function is not used in the aubio library, since the same
    161   result can be obtained by assigning vec->phas[channel][position]. Its purpose
    162   is to access these values from wrappers, as created by swig.
    163 
    164   \param s vector to write to
    165   \param data phase value to write in s->phas[channel][position]
    166   \param channel channel to write to
    167   \param position sample position to write to
    168 
    169 */
    170 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
    171 /** read norm value from a complex buffer
    172 
    173   Note that this function is not used in the aubio library, since the same
    174   result can be obtained with vec->norm[channel][position]. Its purpose is to
    175   access these values from wrappers, as created by swig.
    176 
    177   \param s vector to read from
    178   \param channel channel to read from
    179   \param position sample position to read from
    180 
    181 */
    182 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
    183 /** read phase value from a complex buffer
    184 
    185   Note that this function is not used in the aubio library, since the same
    186   result can be obtained with vec->phas[channel][position]. Its purpose is to
    187   access these values from wrappers, as created by swig.
    188 
    189   \param s vector to read from
    190   \param channel channel to read from
    191   \param position sample position to read from
    192 
    193 */
    194 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
    195 /** write norm channel in a complex buffer
    196 
    197   Note that this function is not used in the aubio library, since the same
    198   result can be obtained by assigning vec->norm[channel]. Its purpose is to
    199   access these values from wrappers, as created by swig.
    200 
    201   \param s vector to write to
    202   \param data norm vector of [length] samples to write in s->norm[channel]
    203   \param channel channel to write to
    204 
    205 */
    206 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
    207 /** write phase channel in a complex buffer
    208 
    209   Note that this function is not used in the aubio library, since the same
    210   result can be obtained by assigning vec->phas[channel]. Its purpose is to
    211   access these values from wrappers, as created by swig.
    212 
    213   \param s vector to write to
    214   \param data phase vector of [length] samples to write in s->phas[channel]
    215   \param channel channel to write to
    216 
    217 */
    218 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
    219 /** read norm channel from a complex buffer
    220 
    221   Note that this function is not used in the aubio library, since the same
    222   result can be obtained with vec->norm[channel]. Its purpose is to access
    223   these values from wrappers, as created by swig.
    224 
    225   \param s vector to read from
    226   \param channel channel to read from
    227 
    228 */
    229 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
    230 /** write phase channel in a complex buffer
    231 
    232   Note that this function is not used in the aubio library, since the same
    233   result can be obtained with vec->phas[channel]. Its purpose is to access
    234   these values from wrappers, as created by swig.
    235 
    236   \param s vector to read from
    237   \param channel channel to read from
    238 
    239 */
    240 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
    241 /** read norm data from a complex buffer
    242 
    243   Note that this function is not used in the aubio library, since the same
    244   result can be obtained with vec->norm. Its purpose is to access these values
    245   from wrappers, as created by swig.
    246 
    247   \param s vector to read from
    248 
    249 */
    250 smpl_t ** cvec_get_norm(cvec_t *s);
    251 /** read phase data from a complex buffer
    252 
    253   Note that this function is not used in the aubio library, since the same
    254   result can be obtained with vec->phas. Its purpose is to access these values
    255   from wrappers, as created by swig.
    256 
    257   \param s vector to read from
    258 
    259 */
    260 smpl_t ** cvec_get_phas(cvec_t *s);
    261 
    262 #ifdef __cplusplus
    263 }
    264 #endif
     23#include "fvec.h"
     24#include "cvec.h"
    26525
    26626#endif /* _SAMPLE_H */
Note: See TracChangeset for help on using the changeset viewer.