Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
24 
25 #include <cstring>
26 #include "ardour/audiofilesource.h"
27 
28 namespace ARDOUR {
29 
31 public:
32  int update_header (samplepos_t /*when*/, struct tm&, time_t) { return 0; }
33  int flush_header () { return 0; }
34  float sample_rate () const { return _sample_rate; }
35 
36  void set_length (samplecnt_t len) { _length = timecnt_t (len); }
37  void flush () {}
38 
39  bool can_be_analysed() const { return false; }
40 
41  bool clamped_at_unity() const { return false; }
42 
43 protected:
44  void close() {}
45  friend class SourceFactory;
46 
47  SilentFileSource (Session& s, const XMLNode& x, samplecnt_t len, float srate)
48  : Source (s, x)
49  , AudioFileSource (s, x, false)
50  , _sample_rate(srate)
51  {
52  _length = timecnt_t (len);
53  }
54 
56  cnt = std::min (cnt, std::max<samplecnt_t> (0, _length.samples() - start));
57  memset (dst, 0, sizeof (Sample) * cnt);
58  return cnt;
59  }
60 
61  samplecnt_t write_unlocked (Sample const * /*src*/, samplecnt_t /*cnt*/) { return 0; }
62 
64 
66  double /*samples_per_pixel*/, samplecnt_t /*fpp*/) const {
67  memset (peaks, 0, sizeof (PeakData) * npeaks);
68  return 0;
69  }
70 
71  float _sample_rate;
72 };
73 
74 } // namespace ARDOUR
75 
76 
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
SilentFileSource(Session &s, const XMLNode &x, samplecnt_t len, float srate)
samplecnt_t write_unlocked(Sample const *, samplecnt_t)
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