1
/* Copyright (C) 2007 Jean-Marc Valin
4
Testing the resampling code
6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions are
10
1. Redistributions of source code must retain the above copyright notice,
11
this list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright
14
notice, this list of conditions and the following disclaimer in the
15
documentation and/or other materials provided with the distribution.
17
3. The name of the author may not be used to endorse or promote products
18
derived from this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
POSSIBILITY OF SUCH DAMAGE.
38
#include "speex/speex_resampler.h"
51
SpeexResamplerState *st = speex_resampler_init(1, 8000, 12000, 10, NULL);
52
speex_resampler_set_rate(st, 96000, 44100);
53
speex_resampler_skip_zeros(st);
55
in = malloc(NN*sizeof(short));
56
out = malloc(2*NN*sizeof(short));
57
fin = malloc(NN*sizeof(float));
58
fout = malloc(2*NN*sizeof(float));
63
fread(in, sizeof(short), NN, stdin);
71
speex_resampler_set_quality(st, 10);*/
72
speex_resampler_process_float(st, 0, fin, &in_len, fout, &out_len);
73
for (i=0;i<out_len;i++)
74
out[i]=floor(.5+fout[i]);
75
/*speex_warning_int("writing", out_len);*/
76
fwrite(out, sizeof(short), out_len, stdout);
79
speex_resampler_destroy(st);