Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Member Functions | List of all members
AudioFileReader Class Reference
Inheritance diagram for AudioFileReader:
AudioFile

Public Member Functions

int setup (const std::string &path, size_t bufferSize)
 
void getSamples (std::vector< float > &buffer)
 
void getSamples (float *dst, size_t samplesCount)
 
int setLoop (bool loop)
 
int setLoop (size_t start, size_t end)
 
size_t getIdx ()
 
- Public Member Functions inherited from AudioFile
size_t getLength () const
 
size_t getChannels () const
 
int getSampleRate () const
 

Additional Inherited Members

- Protected Types inherited from AudioFile
enum  Mode { kRead, kWrite }
 
enum  { kNumBufs = 2 }
 
- Protected Member Functions inherited from AudioFile
int setup (const std::string &path, size_t bufferSize, Mode mode, size_t channels=0, unsigned int sampleRate=0)
 
void scheduleIo ()
 
std::vector< float > & getRtBuffer ()
 
void threadLoop ()
 
- Protected Attributes inherited from AudioFile
volatile size_t ioBuffer
 
size_t ioBufferOld
 
std::array< std::vector< float >
, kNumBufs > 
internalBuffers
 
std::thread diskIo
 
size_t size
 
volatile bool stop
 
bool ramOnly
 
size_t rtIdx
 
SNDFILE * sndfile = NULL
 
SF_INFO sfinfo = { 0 }
 

Member Function Documentation

int AudioFileReader::setup ( const std::string &  path,
size_t  bufferSize 
)

Open a file and prepare to stream it from disk.

Parameters
pathPath to the file
bufferSizethe size of the internal buffer. If this is larger than the file itself, the whole file will be loaded in memory, otherwise the file will be read from disk from a separate thread.
void AudioFileReader::getSamples ( std::vector< float > &  buffer)

Write interleaved samples from the file to the destination.

Parameters
bufferthe destination buffer. Its size() must be a multiple of getChannels().
void AudioFileReader::getSamples ( float *  dst,
size_t  samplesCount 
)

Write interleaved samples from the file to the destination.

Parameters
dstthe destination buffer
samplesCountThe number of samples to write. This has to be a multiple of getChannels().

The documentation for this class was generated from the following files: