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"
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,
45 int64_t start, int64_t len, int direction);
47 // Resample from the file handler and store in *output.
48 // Returns 1 if the input reader failed.
49 // Starting sample in output samplerate
50 // If reverse, the end of the buffer.
51 int resample(Samples *samples,
52 int64_t out_len, int in_rate, int out_rate,
53 int64_t out_position, int direction);
54 static void reverse_buffer(double *buffer, int64_t len);
56 // Reset after seeking
60 void blackman(double fcn, int l);
61 int set_input_position(int64_t in_pos, int in_dir);
63 int get_output_size();
64 // void read_output(Samples *output, int size);
65 // Resamples input and dumps it to output_temp
66 void resample_chunk(Samples *input, int64_t in_len,
67 int in_rate, int out_rate);
70 // Unaligned resampled output
72 // Total samples in unaligned output
74 // Allocation of unaligned output
75 int64_t output_allocation;
76 // History buffer for resampling.
81 // Position of source in source sample rate.
82 int64_t input_position;
84 int64_t output_position;
86 // Last sample ratio configured to
88 double blackfilt[2 * BPC + 1][BLACKSIZE];