source: src/cvec.c @ bd54912

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since bd54912 was 55b7cb4, checked in by Paul Brossier <piem@piem.org>, 15 years ago

src/cvec.c: add cvec_print

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2   Copyright (C) 2003-2007 Paul Brossier <piem@piem.org>
3
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.
8
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.
13
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.
17
18*/
19
20#include "aubio_priv.h"
21#include "cvec.h"
22
23cvec_t * new_cvec( uint_t length, uint_t channels) {
24  cvec_t * s = AUBIO_NEW(cvec_t);
25  uint_t i,j;
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++) {
34      s->norm[i][j]=0.;
35      s->phas[i][j]=0.;
36    }
37  }
38  return s;
39}
40
41void del_cvec(cvec_t *s) {
42  uint_t i;
43  for (i=0; i<s->channels; i++) {
44    AUBIO_FREE(s->norm[i]);
45    AUBIO_FREE(s->phas[i]);
46  }
47  AUBIO_FREE(s->norm);
48  AUBIO_FREE(s->phas);
49  AUBIO_FREE(s);
50}
51
52void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
53  s->norm[channel][position] = data;
54}
55void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
56  s->phas[channel][position] = data;
57}
58smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
59  return s->norm[channel][position];
60}
61smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
62  return s->phas[channel][position];
63}
64void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
65  s->norm[channel] = data;
66}
67void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
68  s->phas[channel] = data;
69}
70smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
71  return s->norm[channel];
72}
73smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
74  return s->phas[channel];
75}
76smpl_t ** cvec_get_norm(cvec_t *s) {
77  return s->norm;
78}
79smpl_t ** cvec_get_phas(cvec_t *s) {
80  return s->phas;
81}
82
83/* helper functions */
84
85void cvec_print(cvec_t *s) {
86  uint_t i,j;
87  for (i=0; i< s->channels; i++) {
88    AUBIO_MSG("norm: ");
89    for (j=0; j< s->length; j++) {
90      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[i][j]);
91    }
92    AUBIO_MSG("\n");
93    AUBIO_MSG("phas: ");
94    for (j=0; j< s->length; j++) {
95      AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[i][j]);
96    }
97    AUBIO_MSG("\n");
98  }
99}
100
Note: See TracBrowser for help on using the repository browser.