1 #include <ardour/sndfileimportable.h>
5 using namespace ARDOUR;
8 SndFileImportableSource::SndFileImportableSource (const string& path)
10 memset(&sf_info, 0 , sizeof(sf_info));
11 in.reset( sf_open(path.c_str(), SFM_READ, &sf_info), sf_close);
12 if (!in) throw failed_constructor();
15 SndFileImportableSource::~SndFileImportableSource ()
20 SndFileImportableSource::read (Sample* buffer, nframes_t nframes)
22 nframes_t per_channel = nframes / sf_info.channels;
23 per_channel = sf_readf_float (in.get(), buffer, per_channel);
24 return per_channel * sf_info.channels;
28 SndFileImportableSource::channels () const
30 return sf_info.channels;
34 SndFileImportableSource::length () const
36 return sf_info.frames;
40 SndFileImportableSource::samplerate() const
42 return sf_info.samplerate;
46 SndFileImportableSource::seek (nframes_t pos)
48 sf_seek (in.get(), 0, SEEK_SET);