38 #include <itpp/itexports.h> 
   73   _encoding(e), _sampling_rate(sr), _num_channels(nc){}
 
   98   std::string _description;
 
  110 namespace audiofile_details{
 
  114   class Audio_Samples_Reader_If
 
  117     virtual bool read_sample(
double& s, 
int ch) = 0;
 
  118     virtual vec read_channel(
int n, 
int ch) = 0;
 
  119     virtual mat read(
int n) = 0;
 
  120     virtual std::streamoff tell() 
const = 0;
 
  121     virtual bool seek(std::streamoff n) = 0;
 
  122     virtual std::streamoff num_samples() = 0;
 
  123     virtual ~Audio_Samples_Reader_If() {}
 
  127   class Audio_Samples_Writer_If
 
  130     virtual bool write_sample(
const double& s, 
int ch) = 0;
 
  131     virtual bool write_channel(
const vec& s, 
int ch) = 0;
 
  133     virtual bool write(
const mat& s) = 0;
 
  134     virtual std::streamoff tell() 
const = 0;
 
  135     virtual bool seek(std::streamoff n) = 0;
 
  136     virtual std::streamoff num_samples() = 0;
 
  137     virtual ~Audio_Samples_Writer_If() {}
 
  186   bool open(
const char* fname);
 
  192   bool seek_read(std::streamoff pos)
 
  194     if((pos > _num_samples) || (pos < 0))
 
  198       return _samples_reader->seek(pos);
 
  203   std::streamoff tell_read()
 
  206       return _samples_reader->tell();
 
  213   bool read_sample(
double& s, 
int ch = 0)
 
  216       return _samples_reader->read_sample(s,ch);
 
  221   vec read_channel(
int n, 
int ch = 0)
 
  224       return _samples_reader->read_channel(n,ch);
 
  232       return _samples_reader->read(n);
 
  240   std::streamoff _num_samples;
 
  242   audiofile_details::Audio_Samples_Reader_If* _samples_reader;
 
  298   bool seek_write(std::streamoff pos)
 
  300     if((pos > _num_samples) || (pos < 0))
 
  304       return _samples_writer->seek(pos);
 
  309   std::streamoff tell_write()
 
  312       return _samples_writer->tell();
 
  319   bool write_sample(
const double &s, 
int ch = 0)
 
  322       bool ret = _samples_writer->write_sample(s,ch);
 
  324         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  332   bool write_channel(
const vec &v, 
int ch = 0)
 
  335       bool ret = _samples_writer->write_channel(v,ch);
 
  337         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  345   bool write(
const mat &m)
 
  348       bool ret = _samples_writer->write(m);
 
  350         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  361   std::streamoff _num_samples;
 
  363   audiofile_details::Audio_Samples_Writer_If* _samples_writer;
 
  386   bool open(
const char *fname);
 
  394   bool seek_read(std::streamoff pos)
 
  396     if((pos > _num_samples) || (pos < 0))
 
  400       return _samples_reader->seek(pos);
 
  405   std::streamoff tell_read()
 
  408       return _samples_reader->tell();
 
  413   bool seek_write(std::streamoff pos)
 
  415     if((pos > _num_samples) || (pos < 0))
 
  419       return _samples_writer->seek(pos);
 
  424   std::streamoff tell_write()
 
  427       return _samples_writer->tell();
 
  434   bool read_sample(
double& s, 
int ch = 0)
 
  437       return _samples_reader->read_sample(s,ch);
 
  442   vec read_channel(
int n, 
int ch = 0)
 
  445       return _samples_reader->read_channel(n,ch);
 
  453       return _samples_reader->read(n);
 
  459   bool write_sample(
const double &s, 
int ch = 0)
 
  462       bool ret = _samples_writer->write_sample(s,ch);
 
  464         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  472   bool write_channel(
const vec &v, 
int ch = 0)
 
  475       bool ret = _samples_writer->write_channel(v,ch);
 
  477         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  485   bool write(
const mat &m)
 
  488       bool ret = _samples_writer->write(m);
 
  490         _num_samples = 
std::max(_num_samples, _samples_writer->tell());
 
  501   std::streamoff _num_samples;
 
  503   audiofile_details::Audio_Samples_Reader_If* _samples_reader;
 
  505   audiofile_details::Audio_Samples_Writer_If* _samples_writer;
 
  637 inline mat 
snd_read(
const char *fname, 
int len, std::streamoff beg = 0)
 
  674 #endif // #ifndef AUDIOFILE_H