ardour
srcfilesource.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 Paul Davis
3  Written by: Robin Gareus <robin@gareus.org>
4 
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.
9 
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.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19 */
20 
21 #ifndef __ardour_srcfilesource_h__
22 #define __ardour_srcfilesource_h__
23 
24 #include <cstring>
25 #include <samplerate.h>
26 
28 #include "ardour/audiofilesource.h"
29 #include "ardour/session.h"
30 
31 namespace ARDOUR {
32 
34 public:
36  ~SrcFileSource ();
37 
38  int update_header (framepos_t /*when*/, struct tm&, time_t) { return 0; }
39  int flush_header () { return 0; }
40  void flush () { }
42  void set_length (framecnt_t /*len*/) {};
43 
44  float sample_rate () const { return _session.nominal_frame_rate(); }
45 
46  framepos_t natural_position() const { return _source->natural_position() * _ratio;}
47  framecnt_t readable_length() const { return _source->readable_length() * _ratio; }
48  framecnt_t length (framepos_t pos) const { return _source->length(pos) * _ratio; }
49 
50  bool destructive() const { return false; }
51  bool can_be_analysed() const { return false; }
52  bool clamped_at_unity() const { return false; }
53 
54 protected:
55  void close ();
56  framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
57  framecnt_t write_unlocked (Sample */*dst*/, framecnt_t /*cnt*/) { return 0; }
58 
59  int read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t /*start*/, framecnt_t /*cnt*/,
60  double /*samples_per_unit*/, framecnt_t /*fpp*/) const {
61  memset (peaks, 0, sizeof (PeakData) * npeaks);
62  return 0;
63  }
64 
65 private:
66  static const uint32_t blocksize;
68 
69  mutable SRC_STATE* _src_state;
70  mutable SRC_DATA _src_data;
71 
72  mutable Sample* _src_buffer;
75  mutable double _fract_position;
76 
77  double _ratio;
79 };
80 
81 } // namespace ARDOUR
82 
83 #endif /* __ardour_audiofilesource_h__ */
84 
framecnt_t readable_length() const
Definition: srcfilesource.h:47
static const uint32_t blocksize
Definition: srcfilesource.h:66
int read_peaks_with_fpp(PeakData *peaks, framecnt_t npeaks, framepos_t, framecnt_t, double, framecnt_t) const
Definition: srcfilesource.h:59
framecnt_t length(framepos_t pos) const
Definition: srcfilesource.h:48
framepos_t _target_position
Definition: srcfilesource.h:74
SrcQuality
Definition: types.h:522
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
Definition: region.cc:63
bool clamped_at_unity() const
Definition: srcfilesource.h:52
int update_header(framepos_t, struct tm &, time_t)
Definition: srcfilesource.h:38
int64_t framecnt_t
Definition: types.h:76
float Sample
Definition: types.h:54
framepos_t _source_position
Definition: srcfilesource.h:73
Definition: amp.h:29
float sample_rate() const
Definition: srcfilesource.h:44
int64_t framepos_t
Definition: types.h:66
boost::shared_ptr< AudioFileSource > _source
Definition: srcfilesource.h:67
bool destructive() const
Definition: srcfilesource.h:50
SRC_STATE * _src_state
Definition: srcfilesource.h:69
#define LIBARDOUR_API
void set_length(framecnt_t)
Definition: srcfilesource.h:42
framecnt_t write_unlocked(Sample *, framecnt_t)
Definition: srcfilesource.h:57
framepos_t natural_position() const
Definition: srcfilesource.h:46
bool can_be_analysed() const
Definition: srcfilesource.h:51
framecnt_t src_buffer_size
Definition: srcfilesource.h:78
void set_header_timeline_position()
Definition: srcfilesource.h:41