2 * Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2014-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __ardour_srcfilesource_h__
21 #define __ardour_srcfilesource_h__
24 #include <samplerate.h>
26 #include "ardour/libardour_visibility.h"
27 #include "ardour/audiofilesource.h"
28 #include "ardour/session.h"
32 class LIBARDOUR_API SrcFileSource : public AudioFileSource {
34 SrcFileSource (Session&, boost::shared_ptr<AudioFileSource>, SrcQuality srcq = SrcQuality(SrcQuick));
37 int update_header (samplepos_t /*when*/, struct tm&, time_t) { return 0; }
38 int flush_header () { return 0; }
40 void set_header_natural_position () {};
41 void set_length (samplecnt_t /*len*/) {};
43 float sample_rate () const { return _session.nominal_sample_rate(); }
45 samplepos_t natural_position() const { return _source->natural_position() * _ratio;}
46 samplecnt_t readable_length() const { return _source->readable_length() * _ratio; }
47 samplecnt_t length (samplepos_t pos) const { return _source->length(pos) * _ratio; }
49 bool destructive() const { return false; }
50 bool can_be_analysed() const { return false; }
51 bool clamped_at_unity() const { return false; }
55 samplecnt_t read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const;
56 samplecnt_t write_unlocked (Sample */*dst*/, samplecnt_t /*cnt*/) { return 0; }
58 int read_peaks_with_fpp (PeakData *peaks, samplecnt_t npeaks, samplepos_t /*start*/, samplecnt_t /*cnt*/,
59 double /*samples_per_unit*/, samplecnt_t /*fpp*/) const {
60 memset (peaks, 0, sizeof (PeakData) * npeaks);
65 static const uint32_t max_blocksize;
66 boost::shared_ptr<AudioFileSource> _source;
68 mutable SRC_STATE* _src_state;
69 mutable SRC_DATA _src_data;
71 mutable Sample* _src_buffer;
72 mutable samplepos_t _source_position;
73 mutable samplepos_t _target_position;
74 mutable double _fract_position;
77 samplecnt_t src_buffer_size;
82 #endif /* __ardour_audiofilesource_h__ */