2 * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4 * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
5 * Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __ardour_resampled_source_h__
23 #define __ardour_resampled_source_h__
25 #include <samplerate.h>
27 #include "ardour/libardour_visibility.h"
28 #include "ardour/types.h"
29 #include "ardour/importable_source.h"
33 class LIBARDOUR_API ResampledImportableSource : public ImportableSource
36 ResampledImportableSource (boost::shared_ptr<ImportableSource>, samplecnt_t rate, SrcQuality);
38 ~ResampledImportableSource ();
40 samplecnt_t read (Sample* buffer, samplecnt_t nframes);
41 float ratio() const { return _src_data.src_ratio; }
42 uint32_t channels() const { return source->channels(); }
43 samplecnt_t length() const { return source->length(); }
44 samplecnt_t samplerate() const { return source->samplerate(); }
45 void seek (samplepos_t);
46 samplepos_t natural_position() const;
48 bool clamped_at_unity () const {
49 /* resampling may generate inter-sample peaks with magnitude > 1 */
53 static const uint32_t blocksize;
56 boost::shared_ptr<ImportableSource> source;
59 SRC_STATE* _src_state;
66 #endif /* __ardour_resampled_source_h__ */