source: src/temporal/resample.c @ 422edfb

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

src/temporal/resample.c: include config,h before checking HAVE_SAMPLERATE

  • Property mode set to 100644
File size: 1.9 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 "config.h"
21
22#if HAVE_SAMPLERATE
23
24#include <samplerate.h> /* from libsamplerate */
25
26#include "aubio_priv.h"
27#include "fvec.h"
28#include "temporal/resample.h"
29
30struct _aubio_resampler_t {
31        SRC_DATA  *proc;
32        SRC_STATE *stat;
33        float ratio;
34        uint_t type;
35};
36
37aubio_resampler_t * new_aubio_resampler(float ratio, uint_t type) {
38        aubio_resampler_t * s  = AUBIO_NEW(aubio_resampler_t);
39        int error = 0;
40        s->stat = src_new (type, 1, &error) ; /* only one channel */
41        s->proc = AUBIO_NEW(SRC_DATA);
42        if (error) AUBIO_ERR("%s\n",src_strerror(error));
43        s->ratio = ratio;
44        return s;
45}
46
47void del_aubio_resampler(aubio_resampler_t *s) {
48        src_delete(s->stat);
49        AUBIO_FREE(s->proc);
50        AUBIO_FREE(s);
51}
52
53uint_t aubio_resampler_process(aubio_resampler_t *s, 
54    fvec_t * input,  fvec_t * output) {
55        uint_t i ;
56        s->proc->input_frames = input->length;
57        s->proc->output_frames = output->length;
58        s->proc->src_ratio = s->ratio;
59        for (i = 0 ; i< input->channels; i++) 
60        {
61                /* make SRC_PROC data point to input outputs */
62                s->proc->data_in = (float *)input->data[i];
63                s->proc->data_out= (float *)output->data[i];
64                /* do resampling */
65                src_process (s->stat, s->proc) ;
66        }
67        return AUBIO_OK;
68}       
69
70#endif /* HAVE_SAMPLERATE */
Note: See TracBrowser for help on using the repository browser.