2 Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
4 This file is part of aubio.
6 aubio is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 aubio is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with aubio. If not, see <http://www.gnu.org/licenses/>.
21 #include "aubio_priv.h"
24 cvec_t * new_cvec( uint_t length, uint_t channels) {
25 cvec_t * s = AUBIO_NEW(cvec_t);
27 s->channels = channels;
28 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++) {
42 void del_cvec(cvec_t *s) {
44 for (i=0; i<s->channels; i++) {
45 AUBIO_FREE(s->norm[i]);
46 AUBIO_FREE(s->phas[i]);
53 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
54 s->norm[channel][position] = data;
56 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
57 s->phas[channel][position] = data;
59 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
60 return s->norm[channel][position];
62 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
63 return s->phas[channel][position];
65 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
66 s->norm[channel] = data;
68 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
69 s->phas[channel] = data;
71 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
72 return s->norm[channel];
74 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
75 return s->phas[channel];
77 smpl_t ** cvec_get_norm(cvec_t *s) {
80 smpl_t ** cvec_get_phas(cvec_t *s) {
84 /* helper functions */
86 void cvec_print(cvec_t *s) {
88 for (i=0; i< s->channels; i++) {
90 for (j=0; j< s->length; j++) {
91 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]);
95 for (j=0; j< s->length; j++) {
96 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]);
102 void cvec_set(cvec_t *s, smpl_t val) {
104 for (i=0; i< s->channels; i++) {
105 for (j=0; j< s->length; j++) {
111 void cvec_zeros(cvec_t *s) {
115 void cvec_ones(cvec_t *s) {