-
Notifications
You must be signed in to change notification settings - Fork 45
WaveReader
See <utilities/wavereader.h>
WaveReader is a class that provides static methods allowing you to load a .WAV file from the filesystem and read its contents into an AudioBuffer, so it can be used for playback within the MWEngine (for instance as a SampleEvent).
The accepted file types are PCM .WAV files using the RIFF bitstream format (in other words : standard Wave files ;) ). Multiple channel audio is supported and will return a multi channel AudioBuffer.
typedef struct
{
unsigned int sampleRate;
AudioBuffer* buffer;
} waveFile;
Structure to bind an AudioBuffer to a sample rate. This can be used in back-and-forth conversion between in-memory audio and on disk .WAV files.
AudioBuffer* WaveReader::fileToBuffer( std::string inputFile );
Where given inputFile should be an absolute path to a .WAV file on the Android filesystem. If the file didn't exist or wasn't of a valid RIFF type, a null pointer is returned. If the file could successfully be opened and parsed into an AudioBuffer, a new AudioBuffer instance is returned.
WaveTable* WaveReader::fileToTable( std::string inputFile );
Where given inputFile should be an absolute path to a .WAV file on the Android filesystem. If the file didn't exist or wasn't of a valid RIFF type, a null pointer is returned. If the file could successfully be opened and parsed into a WaveTable, a new WaveTable instance is returned. This can be used Waveforms::TABLE to use a sample as a waveform.
waveFile byteArrayToBuffer( std::vector<char> byteArray )
Converts the contents of given byteArray into a waveFile struct.