2 Copyright (C) 2003-2007 Paul Brossier <piem@piem.org>
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 cvec_t * new_cvec( uint_t length, uint_t channels) {
24 cvec_t * s = AUBIO_NEW(cvec_t);
26 s->channels = channels;
27 s->length = length/2 + 1;
28 s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
29 s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
30 for (i=0; i< s->channels; i++) {
31 s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
32 s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
33 for (j=0; j< s->length; j++) {
41 void del_cvec(cvec_t *s) {
43 for (i=0; i<s->channels; i++) {
44 AUBIO_FREE(s->norm[i]);
45 AUBIO_FREE(s->phas[i]);
52 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
53 s->norm[channel][position] = data;
55 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
56 s->phas[channel][position] = data;
58 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
59 return s->norm[channel][position];
61 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
62 return s->phas[channel][position];
64 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
65 s->norm[channel] = data;
67 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
68 s->phas[channel] = data;
70 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
71 return s->norm[channel];
73 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
74 return s->phas[channel];
76 smpl_t ** cvec_get_norm(cvec_t *s) {
79 smpl_t ** cvec_get_phas(cvec_t *s) {