11 namespace AudioFileUtilities {
22 int getSamples(
const std::string& file,
float *buf,
unsigned int channel,
unsigned int startFrame,
unsigned int endFrame);
46 int write(
const std::string& filename,
float *buf,
unsigned int channels,
unsigned int frames,
unsigned int samplerate);
55 int write(
const std::string& filename,
const std::vector<std::vector<float> >& dataIn,
unsigned int sampleRate);
69 std::vector<std::vector<float> >
load(
const std::string& filename,
int maxCount = -1,
unsigned int start = 0);
76 std::vector<float>
loadMono(
const std::string& file);
79 #include <libraries/sndfile/sndfile.h>
92 int setup(
const std::string& path,
size_t bufferSize, Mode mode,
size_t channels = 0,
unsigned int sampleRate = 0);
94 size_t getLength()
const {
return sfinfo.frames; };
95 size_t getChannels()
const {
return sfinfo.channels; };
96 int getSampleRate()
const {
return sfinfo.samplerate; };
101 volatile size_t ioBuffer;
105 std::vector<float>& getRtBuffer();
106 std::array<std::vector<float>,kNumBufs> internalBuffers;
108 virtual void io(std::vector<float>& buffer) = 0;
114 SNDFILE* sndfile = NULL;
115 SF_INFO sfinfo = { 0 };
129 int setup(
const std::string& path,
size_t bufferSize);
void getSamples(std::vector<float>& buffer);
143 void getSamples(
float* dst,
size_t samplesCount);
144 int setLoop(
bool loop);
145 int setLoop(
size_t start,
size_t end);
148 void io(std::vector<float>& buffer)
override;
165 int setup(
const std::string& path,
size_t bufferSize,
size_t channels,
unsigned int sampleRate);
173 void setSamples(
float const * src,
size_t samplesCount);
175 void io(std::vector<float>& buffer)
override;
int getNumFrames(const std::string &file)
Definition: AudioFileUtilities.cpp:66
std::vector< std::vector< float > > load(const std::string &filename, int maxCount=-1, unsigned int start=0)
Definition: AudioFileUtilities.cpp:135
int getSamples(const std::string &file, float *buf, unsigned int channel, unsigned int startFrame, unsigned int endFrame)
Definition: AudioFileUtilities.cpp:9
Definition: AudioFile.h:118
int setup(const std::string &path, size_t bufferSize, size_t channels, unsigned int sampleRate)
Definition: AudioFile.cpp:209
int setup(const std::string &path, size_t bufferSize)
Definition: AudioFile.cpp:97
int getNumChannels(const std::string &file)
Definition: AudioFileUtilities.cpp:53
int write(const std::string &filename, float *buf, unsigned int channels, unsigned int frames, unsigned int samplerate)
Definition: AudioFileUtilities.cpp:79
Definition: AudioFile.h:83
std::vector< float > loadMono(const std::string &file)
Definition: AudioFileUtilities.cpp:157
void getSamples(std::vector< float > &buffer)
Definition: AudioFile.cpp:167
void setSamples(std::vector< float > &buffer)
Definition: AudioFile.cpp:214
Definition: AudioFile.h:155