source: src/lvec.c @ 41eff53

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

src/lvec.c: no need to set to 0 after calloc

  • Property mode set to 100644
File size: 1.6 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 "lvec.h"
23
24lvec_t * new_lvec( uint_t length) {
25  lvec_t * s = AUBIO_NEW(lvec_t);
26  s->length = length;
27  s->data = AUBIO_ARRAY(lsmp_t, s->length);
28  return s;
29}
30
31void del_lvec(lvec_t *s) {
32  AUBIO_FREE(s->data);
33  AUBIO_FREE(s);
34}
35
36void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position) {
37  s->data[position] = data;
38}
39lsmp_t lvec_read_sample(lvec_t *s, uint_t position) {
40  return s->data[position];
41}
42
43lsmp_t * lvec_get_data(lvec_t *s) {
44  return s->data;
45}
46
47/* helper functions */
48
49void lvec_print(lvec_t *s) {
50  uint_t j;
51  for (j=0; j< s->length; j++) {
52    AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]);
53  }
54  AUBIO_MSG("\n");
55}
56
57void lvec_set(lvec_t *s, smpl_t val) {
58  uint_t j;
59  for (j=0; j< s->length; j++) {
60    s->data[j] = val;
61  }
62}
63
64void lvec_zeros(lvec_t *s) {
65#if HAVE_MEMCPY_HACKS
66  memset(s->data, 0, s->length * sizeof(lsmp_t));
67#else
68  lvec_set(s, 0.);
69#endif
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.