2 Copyright (C) 2003 Paul Brossier
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "aubio_priv.h"
23 fvec_t * new_fvec( uint_t length, uint_t channels) {
24 fvec_t * s = AUBIO_NEW(fvec_t);
26 s->channels = channels;
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++) {
38 void del_fvec(fvec_t *s) {
40 for (i=0; i<s->channels; i++) {
41 AUBIO_FREE(s->data[i]);
47 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
48 s->data[channel][position] = data;
50 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
51 return s->data[channel][position];
53 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
54 s->data[channel] = data;
56 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
57 return s->data[channel];
60 smpl_t ** fvec_get_data(fvec_t *s) {
64 cvec_t * new_cvec( uint_t length, uint_t channels) {
65 cvec_t * s = AUBIO_NEW(cvec_t);
67 s->channels = channels;
68 s->length = length/2 + 1;
69 s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
70 s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
71 for (i=0; i< s->channels; i++) {
72 s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
73 s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
74 for (j=0; j< s->length; j++) {
82 void del_cvec(cvec_t *s) {
84 for (i=0; i<s->channels; i++) {
85 AUBIO_FREE(s->norm[i]);
86 AUBIO_FREE(s->phas[i]);