1 #include <ardour/sndfileimportable.h>
4 using namespace ARDOUR;
7 SndFileImportableSource::SndFileImportableSource (const string& path)
8 : in (sf_open (path.c_str(), SFM_READ, &sf_info), sf_close)
10 if (!in) throw failed_constructor();
13 SndFileImportableSource::~SndFileImportableSource ()
18 SndFileImportableSource::read (Sample* buffer, nframes_t nframes)
20 nframes_t per_channel = nframes / sf_info.channels;
21 per_channel = sf_readf_float (in.get(), buffer, per_channel);
22 return per_channel * sf_info.channels;
26 SndFileImportableSource::channels () const
28 return sf_info.channels;
32 SndFileImportableSource::length () const
34 return sf_info.frames;
38 SndFileImportableSource::samplerate() const
40 return sf_info.samplerate;
44 SndFileImportableSource::seek (nframes_t pos)
46 sf_seek (in.get(), 0, SEEK_SET);