Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include <samplerate.h>
25 
27 #include "ardour/types.h"
29 
30 namespace ARDOUR {
31 
33 {
34  public:
35  ResampledImportableSource (std::shared_ptr<ImportableSource>, samplecnt_t rate, SrcQuality);
36 
38 
39  samplecnt_t read (Sample* buffer, samplecnt_t nframes);
40  float ratio() const { return _src_data.src_ratio; }
41  uint32_t channels() const { return source->channels(); }
42  samplecnt_t length() const { return source->length(); }
43  samplecnt_t samplerate() const { return source->samplerate(); }
44  void seek (samplepos_t);
46 
47  bool clamped_at_unity () const {
48  /* resampling may generate inter-sample peaks with magnitude > 1 */
49  return false;
50  }
51 
52  static const uint32_t blocksize;
53 
54  private:
55  std::shared_ptr<ImportableSource> source;
56  float* _input;
57  int _src_type;
58  SRC_STATE* _src_state;
59  SRC_DATA _src_data;
61 };
62 
63 }
64 
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