|
|
@ -8,90 +8,90 @@ |
|
|
|
template <class TResamplingReader> |
|
|
|
template <class TResamplingReader> |
|
|
|
class AudioPlayResmp : public AudioStream |
|
|
|
class AudioPlayResmp : public AudioStream |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
AudioPlayResmp(): AudioStream(0, NULL), reader(nullptr) |
|
|
|
AudioPlayResmp(): AudioStream(0, NULL), reader(nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
virtual ~AudioPlayResmp() { |
|
|
|
virtual ~AudioPlayResmp() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void begin(void) |
|
|
|
void begin(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
reader->begin(); |
|
|
|
reader->begin(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool playRaw(const char *filename, uint16_t numChannels) |
|
|
|
bool playRaw(const char *filename, uint16_t numChannels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stop(); |
|
|
|
stop(); |
|
|
|
return reader->play(filename, false, numChannels); |
|
|
|
return reader->play(filename, false, numChannels); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool playWav(const char *filename) |
|
|
|
bool playWav(const char *filename) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stop(); |
|
|
|
stop(); |
|
|
|
return reader->play(filename, true, 0); |
|
|
|
return reader->play(filename, true, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool playRaw(int16_t *data, uint32_t numSamples, uint16_t numChannels) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
stop(); |
|
|
|
|
|
|
|
return reader->playRaw(data, numSamples, numChannels); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool playRaw(int16_t *data, uint32_t numSamples, uint16_t numChannels) |
|
|
|
bool playRaw(const unsigned int *data, uint32_t numSamples, uint16_t numChannels)
|
|
|
|
{ |
|
|
|
{ |
|
|
|
stop(); |
|
|
|
return playRaw((int16_t *) data, numSamples, numChannels); |
|
|
|
return reader->playRaw(data, numSamples, numChannels); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool playRaw(const unsigned int *data, uint32_t numSamples, uint16_t numChannels)
|
|
|
|
bool playWav(int16_t *data, uint32_t fileSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return playRaw((int16_t *) data, numSamples, numChannels); |
|
|
|
stop(); |
|
|
|
} |
|
|
|
return reader->playWav(data, fileSize); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool playWav(int16_t *data, uint32_t fileSize) |
|
|
|
bool playWav(const unsigned int *data, uint32_t fileSize) { |
|
|
|
{ |
|
|
|
return playWav((int16_t *) data, fileSize); |
|
|
|
stop(); |
|
|
|
} |
|
|
|
return reader->playWav(data, fileSize); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool playWav(const unsigned int *data, uint32_t fileSize) { |
|
|
|
|
|
|
|
return playWav((int16_t *) data, fileSize); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setPlaybackRate(float f) { |
|
|
|
|
|
|
|
reader->setPlaybackRate(f); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setLoopType(loop_type t) { |
|
|
|
|
|
|
|
reader->setLoopType(t); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setLoopStart(uint32_t loop_start) { |
|
|
|
|
|
|
|
reader->setLoopStart(loop_start); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setLoopFinish(uint32_t loop_finish) { |
|
|
|
|
|
|
|
reader->setLoopFinish(loop_finish); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void enableInterpolation(bool enable) { |
|
|
|
|
|
|
|
if (enable) |
|
|
|
|
|
|
|
reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_quadratic); |
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_none); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isPlaying(void) { |
|
|
|
|
|
|
|
return reader->isPlaying(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stop() { |
|
|
|
void setPlaybackRate(float f) { |
|
|
|
reader->stop(); |
|
|
|
reader->setPlaybackRate(f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void update() |
|
|
|
void setLoopType(loop_type t) { |
|
|
|
{ |
|
|
|
reader->setLoopType(t); |
|
|
|
int _numChannels = reader->getNumChannels(); |
|
|
|
} |
|
|
|
if (_numChannels == -1) |
|
|
|
|
|
|
|
return; |
|
|
|
void setLoopStart(uint32_t loop_start) { |
|
|
|
|
|
|
|
reader->setLoopStart(loop_start); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setLoopFinish(uint32_t loop_finish) { |
|
|
|
|
|
|
|
reader->setLoopFinish(loop_finish); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void enableInterpolation(bool enable) { |
|
|
|
|
|
|
|
if (enable) |
|
|
|
|
|
|
|
reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_quadratic); |
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reader->setInterpolationType(ResampleInterpolationType::resampleinterpolation_none); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isPlaying(void) { |
|
|
|
|
|
|
|
return reader->isPlaying(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stop() { |
|
|
|
|
|
|
|
reader->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void update() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int _numChannels = reader->getNumChannels(); |
|
|
|
|
|
|
|
if (_numChannels == -1) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int n; |
|
|
|
unsigned int n; |
|
|
|
audio_block_t *blocks[_numChannels]; |
|
|
|
audio_block_t *blocks[_numChannels]; |
|
|
|
int16_t *data[_numChannels]; |
|
|
|
int16_t *data[_numChannels]; |
|
|
|
// only update if we're playing
|
|
|
|
// only update if we're playing
|
|
|
|