andrew@0: /* andrew@0: Copyright (C) 2003 Paul Brossier andrew@0: andrew@0: This program is free software; you can redistribute it and/or modify andrew@0: it under the terms of the GNU General Public License as published by andrew@0: the Free Software Foundation; either version 2 of the License, or andrew@0: (at your option) any later version. andrew@0: andrew@0: This program is distributed in the hope that it will be useful, andrew@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrew@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrew@0: GNU General Public License for more details. andrew@0: andrew@0: You should have received a copy of the GNU General Public License andrew@0: along with this program; if not, write to the Free Software andrew@0: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. andrew@0: andrew@0: */ andrew@0: andrew@0: #ifndef _SAMPLE_H andrew@0: #define _SAMPLE_H andrew@0: andrew@0: #ifdef __cplusplus andrew@0: extern "C" { andrew@0: #endif andrew@0: andrew@0: /** \file andrew@0: andrew@0: Real and complex buffers andrew@0: andrew@0: This file specifies fvec_t and cvec_t buffers types, which are used andrew@0: throughout aubio to store real and complex data. Complex values are stored in andrew@0: terms of phase and norm. andrew@0: andrew@0: */ andrew@0: andrew@0: /** Sample buffer type */ andrew@0: typedef struct _fvec_t fvec_t; andrew@0: /** Spectrum buffer type */ andrew@0: typedef struct _cvec_t cvec_t; andrew@0: /** Buffer for real values */ andrew@0: struct _fvec_t { andrew@0: ba_uint_t length; /**< length of buffer */ andrew@0: ba_uint_t channels; /**< number of channels */ andrew@0: smpl_t **data; /**< data array of size [length] * [channels] */ andrew@0: }; andrew@0: /** Buffer for complex data */ andrew@0: struct _cvec_t { andrew@0: ba_uint_t length; /**< length of buffer = (requested length)/2 + 1 */ andrew@0: ba_uint_t channels; /**< number of channels */ andrew@0: smpl_t **norm; /**< norm array of size [length] * [channels] */ andrew@0: smpl_t **phas; /**< phase array of size [length] * [channels] */ andrew@0: }; andrew@0: /** fvec_t buffer creation function andrew@0: andrew@0: \param length the length of the buffer to create andrew@0: \param channels the number of channels in the buffer andrew@0: andrew@0: */ andrew@0: fvec_t * new_fvec(ba_uint_t length, ba_uint_t channels); andrew@0: /** fvec_t buffer deletion function andrew@0: andrew@0: \param s buffer to delete as returned by new_fvec() andrew@0: andrew@0: */ andrew@0: void del_fvec(fvec_t *s); andrew@0: /** read sample value in a buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained using vec->data[channel][position]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: \param position sample position to read from andrew@0: andrew@0: */ andrew@0: smpl_t fvec_read_sample(fvec_t *s, ba_uint_t channel, ba_uint_t position); andrew@0: /** write sample value in a buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->data[channel][position]. Its purpose andrew@0: is to access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data value to write in s->data[channel][position] andrew@0: \param channel channel to write to andrew@0: \param position sample position to write to andrew@0: andrew@0: */ andrew@0: void fvec_write_sample(fvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position); andrew@0: /** read channel vector from a buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->data[channel]. Its purpose is to access andrew@0: these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: andrew@0: */ andrew@0: smpl_t * fvec_get_channel(fvec_t *s, ba_uint_t channel); andrew@0: /** write channel vector into a buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->data[channel]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data vector of [length] values to write andrew@0: \param channel channel to write to andrew@0: andrew@0: */ andrew@0: void fvec_put_channel(fvec_t *s, smpl_t * data, ba_uint_t channel); andrew@0: /** read data from a buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->data. Its purpose is to access these values andrew@0: from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: andrew@0: */ andrew@0: smpl_t ** fvec_get_data(fvec_t *s); andrew@0: andrew@0: /** cvec_t buffer creation function andrew@0: andrew@0: This function creates a cvec_t structure holding two arrays of size andrew@0: [length/2+1] * channels, corresponding to the norm and phase values of the andrew@0: spectral frame. The length stored in the structure is the actual size of both andrew@0: arrays, not the length of the complex and symetrical vector, specified as andrew@0: creation argument. andrew@0: andrew@0: \param length the length of the buffer to create andrew@0: \param channels the number of channels in the buffer andrew@0: andrew@0: */ andrew@0: cvec_t * new_cvec(ba_uint_t length, ba_uint_t channels); andrew@0: /** cvec_t buffer deletion function andrew@0: andrew@0: \param s buffer to delete as returned by new_cvec() andrew@0: andrew@0: */ andrew@0: void del_cvec(cvec_t *s); andrew@0: /** write norm value in a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->norm[channel][position]. Its purpose andrew@0: is to access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data norm value to write in s->norm[channel][position] andrew@0: \param channel channel to write to andrew@0: \param position sample position to write to andrew@0: andrew@0: */ andrew@0: void cvec_write_norm(cvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position); andrew@0: /** write phase value in a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->phas[channel][position]. Its purpose andrew@0: is to access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data phase value to write in s->phas[channel][position] andrew@0: \param channel channel to write to andrew@0: \param position sample position to write to andrew@0: andrew@0: */ andrew@0: void cvec_write_phas(cvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position); andrew@0: /** read norm value from a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->norm[channel][position]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: \param position sample position to read from andrew@0: andrew@0: */ andrew@0: smpl_t cvec_read_norm(cvec_t *s, ba_uint_t channel, ba_uint_t position); andrew@0: /** read phase value from a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->phas[channel][position]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: \param position sample position to read from andrew@0: andrew@0: */ andrew@0: smpl_t cvec_read_phas(cvec_t *s, ba_uint_t channel, ba_uint_t position); andrew@0: /** write norm channel in a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->norm[channel]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data norm vector of [length] samples to write in s->norm[channel] andrew@0: \param channel channel to write to andrew@0: andrew@0: */ andrew@0: void cvec_put_norm_channel(cvec_t *s, smpl_t * data, ba_uint_t channel); andrew@0: /** write phase channel in a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained by assigning vec->phas[channel]. Its purpose is to andrew@0: access these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to write to andrew@0: \param data phase vector of [length] samples to write in s->phas[channel] andrew@0: \param channel channel to write to andrew@0: andrew@0: */ andrew@0: void cvec_put_phas_channel(cvec_t *s, smpl_t * data, ba_uint_t channel); andrew@0: /** read norm channel from a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->norm[channel]. Its purpose is to access andrew@0: these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: andrew@0: */ andrew@0: smpl_t * cvec_get_norm_channel(cvec_t *s, ba_uint_t channel); andrew@0: /** write phase channel in a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->phas[channel]. Its purpose is to access andrew@0: these values from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: \param channel channel to read from andrew@0: andrew@0: */ andrew@0: smpl_t * cvec_get_phas_channel(cvec_t *s, ba_uint_t channel); andrew@0: /** read norm data from a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->norm. Its purpose is to access these values andrew@0: from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: andrew@0: */ andrew@0: smpl_t ** cvec_get_norm(cvec_t *s); andrew@0: /** read phase data from a complex buffer andrew@0: andrew@0: Note that this function is not used in the aubio library, since the same andrew@0: result can be obtained with vec->phas. Its purpose is to access these values andrew@0: from wrappers, as created by swig. andrew@0: andrew@0: \param s vector to read from andrew@0: andrew@0: */ andrew@0: smpl_t ** cvec_get_phas(cvec_t *s); andrew@0: andrew@0: #ifdef __cplusplus andrew@0: } andrew@0: #endif andrew@0: andrew@0: #endif /* _SAMPLE_H */