source: src/sample.c @ 95a64c7

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 95a64c7 was 95a64c7, checked in by Amaury Hazan <mahmoudax@gmail.org>, 17 years ago

secondary frequency vectors make a copy of freqs values and are properly freed

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