1 #include <ardour/sndfileimportable.h>
5 using namespace ARDOUR;
8 SndFileImportableSource::SndFileImportableSource (const string& path)
9 : in (sf_open (path.c_str(), SFM_READ, &sf_info), sf_close)
11 if (!in) throw failed_constructor();
14 SndFileImportableSource::~SndFileImportableSource ()
19 SndFileImportableSource::read (Sample* buffer, nframes_t nframes)
21 nframes_t per_channel = nframes / sf_info.channels;
22 per_channel = sf_readf_float (in.get(), buffer, per_channel);
23 return per_channel * sf_info.channels;
27 SndFileImportableSource::channels () const
29 return sf_info.channels;
33 SndFileImportableSource::length () const
35 return sf_info.frames;
39 SndFileImportableSource::samplerate() const
41 return sf_info.samplerate;
45 SndFileImportableSource::seek (nframes_t pos)
47 sf_seek (in.get(), 0, SEEK_SET);