Ardour  8.12
resampled_source.h
Go to the documentation of this file.
1 /*
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>
6  *
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.
11  *
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.
16  *
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.
20  */
21 
22 #ifndef __ardour_resampled_source_h__
23 #define __ardour_resampled_source_h__
24 
25 #include <samplerate.h>
26 
28 #include "ardour/types.h"
30 
31 namespace ARDOUR {
32 
34 {
35  public:
36  ResampledImportableSource (std::shared_ptr<ImportableSource>, samplecnt_t rate, SrcQuality);
37 
39 
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);
47 
48  bool clamped_at_unity () const {
49  /* resampling may generate inter-sample peaks with magnitude > 1 */
50  return false;
51  }
52 
53  static const uint32_t blocksize;
54 
55  private:
56  std::shared_ptr<ImportableSource> source;
57  float* _input;
58  int _src_type;
59  SRC_STATE* _src_state;
60  SRC_DATA _src_data;
62 };
63 
64 }
65 
66 #endif /* __ardour_resampled_source_h__ */
ResampledImportableSource(std::shared_ptr< ImportableSource >, samplecnt_t rate, SrcQuality)
std::shared_ptr< ImportableSource > source
samplepos_t natural_position() const
samplecnt_t read(Sample *buffer, samplecnt_t nframes)
#define LIBARDOUR_API
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t