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) {
25 cvec_t * s = AUBIO_NEW(cvec_t);
26 s->length = length/2 + 1;
27 s->norm = AUBIO_ARRAY(smpl_t,s->length);
28 s->phas = AUBIO_ARRAY(smpl_t,s->length);
32 void del_cvec(cvec_t *s) {
38 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
39 s->norm[position] = data;
41 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
42 s->phas[position] = data;
44 smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
45 return s->norm[position];
47 smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
48 return s->phas[position];
50 smpl_t * cvec_get_norm(cvec_t *s) {
53 smpl_t * cvec_get_phas(cvec_t *s) {
57 /* helper functions */
59 void cvec_print(cvec_t *s) {
62 for (j=0; j< s->length; j++) {
63 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]);
67 for (j=0; j< s->length; j++) {
68 AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]);
73 void cvec_set(cvec_t *s, smpl_t val) {
75 for (j=0; j< s->length; j++) {
80 void cvec_zeros(cvec_t *s) {
84 void cvec_ones(cvec_t *s) {