Ardour  8.12
sndfile_reader.h
Go to the documentation of this file.
1 #ifndef AUDIOGRAPHER_SNDFILE_READER_H
2 #define AUDIOGRAPHER_SNDFILE_READER_H
3 
7 
8 namespace AudioGrapher
9 {
10 
14 template<typename T = DefaultSampleType>
16  : public virtual SndfileBase
17  , public ListedSource<T>
18  , public Throwing<>
19 {
20  public:
21 
22  SndfileReader (std::string const & path) : SndfileHandle (path) {}
23  virtual ~SndfileReader () {}
24 
25  SndfileReader (SndfileReader const & other) : SndfileHandle (other) {}
26  using SndfileHandle::operator=;
27 
33  {
34  if (throw_level (ThrowStrict) && context.channels() != channels() ) {
35  throw Exception (*this, boost::str (boost::format
36  ("Wrong number of channels given to process(), %1% instead of %2%")
37  % context.channels() % channels()));
38  }
39 
40  samplecnt_t const samples_read = SndfileHandle::read (context.data(), context.samples());
41  ProcessContext<T> c_out = context.beginning (samples_read);
42 
43  if (samples_read < context.samples()) {
45  }
46  this->output (c_out);
47  return samples_read;
48  }
49 
50  protected:
53 };
54 
55 } // namespace
56 
57 #endif // AUDIOGRAPHER_SNDFILE_READER_H
An generic Source that uses a std::list for managing outputs.
Definition: listed_source.h:17
void output(ProcessContext< DefaultSampleType > const &c)
Helper for derived classes.
Definition: listed_source.h:28
ChannelCount const & channels() const
T const * data() const
data points to the array of data to process
ProcessContext beginning(samplecnt_t samples)
Make new Context out of the beginning of this context.
samplecnt_t const & samples() const
samples tells how many samples the array pointed by data contains
void set_flag(Flag flag) const
Base class for all classes using libsndfile.
Definition: sndfile_base.h:13
sf_count_t read(short *ptr, sf_count_t items)
int channels(void) const
Definition: sndfile.hh:102
SndfileReader(std::string const &path)
samplecnt_t read(ProcessContext< T > &context)
SndfileReader()
SndfileHandle has to be constructed directly by deriving classes.
SndfileReader(SndfileReader const &other)
bool throw_level(ThrowLevel level)
Definition: throwing.h:47
@ ThrowStrict
Stricter checks than ThrowProcess, less than ThrowSample.
Definition: throwing.h:24