Ardour  8.12
silentfilesource.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
6  * Copyright (C) 2016-2018 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_silentfilesource_h__
24 #define __ardour_silentfilesource_h__
25 
26 #include <cstring>
27 #include "ardour/audiofilesource.h"
28 
29 namespace ARDOUR {
30 
32 public:
33  int update_header (samplepos_t /*when*/, struct tm&, time_t) { return 0; }
34  int flush_header () { return 0; }
35  float sample_rate () const { return _sample_rate; }
36 
37  void set_length (samplecnt_t len) { _length = timecnt_t (len); }
38  void flush () {}
39 
40  bool can_be_analysed() const { return false; }
41 
42  bool clamped_at_unity() const { return false; }
43 
44 protected:
45  void close() {}
46  friend class SourceFactory;
47 
48  SilentFileSource (Session& s, const XMLNode& x, samplecnt_t len, float srate)
49  : Source (s, x)
50  , AudioFileSource (s, x, false)
51  , _sample_rate(srate)
52  {
53  _length = timecnt_t (len);
54  }
55 
57  cnt = std::min (cnt, std::max<samplecnt_t> (0, _length.samples() - start));
58  memset (dst, 0, sizeof (Sample) * cnt);
59  return cnt;
60  }
61 
62  samplecnt_t write_unlocked (Sample */*dst*/, samplecnt_t /*cnt*/) { return 0; }
63 
65 
67  double /*samples_per_pixel*/, samplecnt_t /*fpp*/) const {
68  memset (peaks, 0, sizeof (PeakData) * npeaks);
69  return 0;
70  }
71 
72  float _sample_rate;
73 };
74 
75 } // namespace ARDOUR
76 
77 #endif /* __ardour_audiofilesource_h__ */
78 
int update_header(samplepos_t, struct tm &, time_t)
int read_peaks_with_fpp(PeakData *peaks, samplecnt_t npeaks, samplepos_t, samplecnt_t, double, samplecnt_t) const
samplecnt_t write_unlocked(Sample *, samplecnt_t)
SilentFileSource(Session &s, const XMLNode &x, samplecnt_t len, float srate)
samplecnt_t read_unlocked(Sample *dst, samplepos_t start, samplecnt_t cnt) const
void set_length(samplecnt_t len)
Definition: xml++.h:114
#define LIBARDOUR_API
void peaks(const float *data, float &min, float &max, uint32_t n_samples)
void memset(float *data, const float val, const uint32_t n_samples)
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
Temporal::timecnt_t timecnt_t
Temporal::samplepos_t samplepos_t