source: src/lvec.c @ 7c84204

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

modified fvec and lvec to be mono, added fmat

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[a3a01e1]1/*
[a6db140]2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
[a3a01e1]3
[a6db140]4  This file is part of aubio.
[a3a01e1]5
[a6db140]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.
[a3a01e1]10
[a6db140]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/>.
[a3a01e1]18
19*/
20
21#include "aubio_priv.h"
22#include "lvec.h"
23
[c7860af]24lvec_t * new_lvec( uint_t length) {
[a3a01e1]25  lvec_t * s = AUBIO_NEW(lvec_t);
[c7860af]26  uint_t j;
[a3a01e1]27  s->length = length;
[c7860af]28  s->data = AUBIO_ARRAY(lsmp_t, s->length);
29  for (j=0; j< s->length; j++) {
30    s->data[j]=0.;
[a3a01e1]31  }
32  return s;
33}
34
35void del_lvec(lvec_t *s) {
36  AUBIO_FREE(s->data);
37  AUBIO_FREE(s);
38}
39
[c7860af]40void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
41  s->data[position] = data;
[a3a01e1]42}
[c7860af]43lsmp_t lvec_read_sample(lvec_t *s, uint_t position) {
44  return s->data[position];
[a3a01e1]45}
46
[c7860af]47lsmp_t * lvec_get_data(lvec_t *s) {
[a3a01e1]48  return s->data;
49}
50
[79a01c5]51/* helper functions */
52
53void lvec_print(lvec_t *s) {
[c7860af]54  uint_t j;
55  for (j=0; j< s->length; j++) {
56    AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]);
[79a01c5]57  }
[c7860af]58  AUBIO_MSG("\n");
[79a01c5]59}
60
[b849106]61void lvec_set(lvec_t *s, smpl_t val) {
[c7860af]62  uint_t j;
63  for (j=0; j< s->length; j++) {
64    s->data[j] = val;
[b849106]65  }
66}
67
68void lvec_zeros(lvec_t *s) {
69  lvec_set(s, 0.);
70}
71
72void lvec_ones(lvec_t *s) {
73  lvec_set(s, 1.);
74}
75
Note: See TracBrowser for help on using the repository browser.