source: src/lvec.c @ 51ee670

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

src/lvec.{c,h}: add lvec_print

  • Property mode set to 100644
File size: 2.0 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 "lvec.h"
22
23lvec_t * new_lvec( uint_t length, uint_t channels) {
24  lvec_t * s = AUBIO_NEW(lvec_t);
25  uint_t i,j;
26  s->channels = channels;
27  s->length = length;
28  s->data = AUBIO_ARRAY(lsmp_t*,s->channels);
29  for (i=0; i< s->channels; i++) {
30    s->data[i] = AUBIO_ARRAY(lsmp_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_lvec(lvec_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 lvec_write_sample(lvec_t *s, lsmp_t data, uint_t channel, uint_t position) {
48  s->data[channel][position] = data;
49}
50lsmp_t lvec_read_sample(lvec_t *s, uint_t channel, uint_t position) {
51  return s->data[channel][position];
52}
53void lvec_put_channel(lvec_t *s, lsmp_t * data, uint_t channel) {
54  s->data[channel] = data;
55}
56lsmp_t * lvec_get_channel(lvec_t *s, uint_t channel) {
57  return s->data[channel];
58}
59
60lsmp_t ** lvec_get_data(lvec_t *s) {
61  return s->data;
62}
63
64/* helper functions */
65
66void lvec_print(lvec_t *s) {
67  uint_t i,j;
68  for (i=0; i< s->channels; i++) {
69    for (j=0; j< s->length; j++) {
70      AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[i][j]);
71    }
72    AUBIO_MSG("\n");
73  }
74}
75
Note: See TracBrowser for help on using the repository browser.