source: src/sample.c @ fb8bde7

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since fb8bde7 was 7c206df, checked in by Paul Brossier <piem@altern.org>, 19 years ago

[src,swig] added cvec methods to sample
[src,swig] added cvec methods to sample

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2   Copyright (C) 2003 Paul Brossier
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 "sample.h"
22
23fvec_t * new_fvec( uint_t length, uint_t channels) {
24  fvec_t * s = AUBIO_NEW(fvec_t);
25  uint_t i,j;
26  s->channels = channels;
27  s->length = length;
28  s->data = AUBIO_ARRAY(smpl_t*,s->channels);
29  for (i=0; i< s->channels; i++) {
30    s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
31    for (j=0; j< s->length; j++) {
32      s->data[i][j]=0.;
33    }
34  }
35  return s;
36}
37
38void del_fvec(fvec_t *s) {
39  uint_t i;
40  for (i=0; i<s->channels; i++) {
41    AUBIO_FREE(s->data[i]);
42  }
43  AUBIO_FREE(s->data);
44  AUBIO_FREE(s);
45}
46
47void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
48  s->data[channel][position] = data;
49}
50smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
51  return s->data[channel][position];
52}
53void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
54  s->data[channel] = data;
55}
56smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
57  return s->data[channel];
58}
59
60smpl_t ** fvec_get_data(fvec_t *s) {
61  return s->data;
62}
63
64cvec_t * new_cvec( uint_t length, uint_t channels) {
65  cvec_t * s = AUBIO_NEW(cvec_t);
66  uint_t i,j;
67  s->channels = channels;
68  s->length = length/2 + 1;
69  s->norm = AUBIO_ARRAY(smpl_t*,s->channels);
70  s->phas = AUBIO_ARRAY(smpl_t*,s->channels);
71  for (i=0; i< s->channels; i++) {
72    s->norm[i] = AUBIO_ARRAY(smpl_t,s->length);
73    s->phas[i] = AUBIO_ARRAY(smpl_t,s->length);
74    for (j=0; j< s->length; j++) {
75      s->norm[i][j]=0.;
76      s->phas[i][j]=0.;
77    }
78  }
79  return s;
80}
81
82void del_cvec(cvec_t *s) {
83  uint_t i;
84  for (i=0; i<s->channels; i++) {
85    AUBIO_FREE(s->norm[i]);
86    AUBIO_FREE(s->phas[i]);
87  }
88  AUBIO_FREE(s->norm);
89  AUBIO_FREE(s->phas);
90  AUBIO_FREE(s);
91}
92
93void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
94  s->norm[channel][position] = data;
95}
96void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
97  s->phas[channel][position] = data;
98}
99smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
100  return s->norm[channel][position];
101}
102smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
103  return s->phas[channel][position];
104}
105void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
106  s->norm[channel] = data;
107}
108void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
109  s->phas[channel] = data;
110}
111smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
112  return s->norm[channel];
113}
114smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
115  return s->phas[channel];
116}
117smpl_t ** cvec_get_norm(cvec_t *s) {
118  return s->norm;
119}
120smpl_t ** cvec_get_phas(cvec_t *s) {
121  return s->phas;
122}
Note: See TracBrowser for help on using the repository browser.