4 * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
6 * This program 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 2 of the License, or
9 * (at your option) any later version.
11 * This program 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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 // Generic resampling module
31 #include "resample.inc"
32 #include "samples.inc"
41 // All positions are in file sample rate
42 // This must reverse the buffer during reverse playback
43 // so the filter always renders forward.
44 virtual int read_samples(Samples *buffer, int64_t start, int64_t len);
46 // Resample from the file handler and store in *output.
47 // Returns 1 if the input reader failed.
48 int resample(Samples *samples,
52 // Starting sample in output samplerate
53 // If reverse, the end of the buffer.
59 static void reverse_buffer(double *buffer, int64_t len);
61 // Reset after seeking
65 double blackman(int i, double offset, double fcn, int l);
67 int get_output_size();
68 // void read_output(Samples *output, int size);
69 // Resamples input and dumps it to output_temp
70 void resample_chunk(Samples *input,
74 int read_chunk(Samples *input,
77 // History buffer for resampling.
83 // Unaligned resampled output
87 // Total samples in unaligned output
91 // Allocation of unaligned output
92 int64_t output_allocation;
95 // Position of source in source sample rate.
96 int64_t input_position;
98 int64_t output_position;
100 // Last sample ratio configured to
102 double blackfilt[2 * BPC + 1][BLACKSIZE];