source: src/cvec.c @ b8aaaff

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

modified cvec to be mono

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
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.
10
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.
15
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/>.
18
19*/
20
21#include "aubio_priv.h"
22#include "cvec.h"
23
24cvec_t * new_cvec( uint_t length) {
25  cvec_t * s = AUBIO_NEW(cvec_t);
26  uint_t j;
27  s->length = length/2 + 1;
28  s->norm = AUBIO_ARRAY(smpl_t,s->length);
29  s->phas = AUBIO_ARRAY(smpl_t,s->length);
30  for (j=0; j< s->length; j++) {
31    s->norm[j]=0.;
32    s->phas[j]=0.;
33  }
34  return s;
35}
36
37void del_cvec(cvec_t *s) {
38  AUBIO_FREE(s->norm);
39  AUBIO_FREE(s->phas);
40  AUBIO_FREE(s);
41}
42
43void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position) {
44  s->norm[position] = data;
45}
46void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position) {
47  s->phas[position] = data;
48}
49smpl_t cvec_read_norm(cvec_t *s, uint_t position) {
50  return s->norm[position];
51}
52smpl_t cvec_read_phas(cvec_t *s, uint_t position) {
53  return s->phas[position];
54}
55smpl_t * cvec_get_norm(cvec_t *s) {
56  return s->norm;
57}
58smpl_t * cvec_get_phas(cvec_t *s) {
59  return s->phas;
60}
61
62/* helper functions */
63
64void cvec_print(cvec_t *s) {
65  uint_t j;
66  AUBIO_MSG("norm: ");
67  for (j=0; j< s->length; j++) {
68    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->norm[j]);
69  }
70  AUBIO_MSG("\n");
71  AUBIO_MSG("phas: ");
72  for (j=0; j< s->length; j++) {
73    AUBIO_MSG(AUBIO_SMPL_FMT " ", s->phas[j]);
74  }
75  AUBIO_MSG("\n");
76}
77
78void cvec_set(cvec_t *s, smpl_t val) {
79  uint_t j;
80  for (j=0; j< s->length; j++) {
81    s->norm[j] = val;
82  }
83}
84
85void cvec_zeros(cvec_t *s) {
86  cvec_set(s, 0.);
87}
88
89void cvec_ones(cvec_t *s) {
90  cvec_set(s, 1.);
91}
92
Note: See TracBrowser for help on using the repository browser.