rename all Evoral source from .(hpp|cpp)$ to .(h|cc)
[ardour.git] / libs / ardour / ardour / resampled_source.h
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
27 #include "ardour/libardour_visibility.h"
28 #include "ardour/types.h"
29 #include "ardour/importable_source.h"
30
31 namespace ARDOUR {
32
33 class LIBARDOUR_API ResampledImportableSource : public ImportableSource
34 {
35   public:
36         ResampledImportableSource (boost::shared_ptr<ImportableSource>, samplecnt_t rate, SrcQuality);
37
38         ~ResampledImportableSource ();
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);
46         samplepos_t natural_position() const;
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         boost::shared_ptr<ImportableSource> source;
57         float*          _input;
58         int             _src_type;
59         SRC_STATE*      _src_state;
60         SRC_DATA        _src_data;
61         bool            _end_of_input;
62 };
63
64 }
65
66 #endif /* __ardour_resampled_source_h__ */