docs
This commit is contained in:
@@ -54,7 +54,6 @@ static bool read_mp3(std::string filename, std::vector<float>& samples) {
|
|||||||
return ok1 && ok2;
|
return ok1 && ok2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct RbLogger : public RubberBand::RubberBandStretcher::Logger {
|
struct RbLogger : public RubberBand::RubberBandStretcher::Logger {
|
||||||
virtual void log(const char *s) {
|
virtual void log(const char *s) {
|
||||||
LOGI("%s", s);
|
LOGI("%s", s);
|
||||||
@@ -83,6 +82,8 @@ PlaybackEngine::PlaybackEngine(std::string filesDir, int resid):
|
|||||||
android_fd(0),
|
android_fd(0),
|
||||||
haveTimeRatio(false),
|
haveTimeRatio(false),
|
||||||
timeRatio(1.0),
|
timeRatio(1.0),
|
||||||
|
|
||||||
|
// these 3 values are preliminary -- will be set from MixingPlayer defaults in the ctor body below
|
||||||
playbackRate(48000),
|
playbackRate(48000),
|
||||||
numOutChannels(2),
|
numOutChannels(2),
|
||||||
numInChannels(2)
|
numInChannels(2)
|
||||||
@@ -90,21 +91,27 @@ PlaybackEngine::PlaybackEngine(std::string filesDir, int resid):
|
|||||||
LOGI("PlaybackEngine()");
|
LOGI("PlaybackEngine()");
|
||||||
LOGI("NDK LOG_LEVEL=%d", LOG_LEVEL);
|
LOGI("NDK LOG_LEVEL=%d", LOG_LEVEL);
|
||||||
// NDK LOG_LEVEL=3 (DEBUG)
|
// NDK LOG_LEVEL=3 (DEBUG)
|
||||||
|
|
||||||
|
// load "bump" sound effect
|
||||||
std::vector<float> samples;
|
std::vector<float> samples;
|
||||||
bool is_ok = read_mp3(mFilesDir + "/" + std::to_string(resid) + ".mp3", samples);
|
bool is_ok = read_mp3(mFilesDir + "/" + std::to_string(resid) + ".mp3", samples);
|
||||||
LOGI("read_mp3() is_ok=%d", is_ok);
|
LOGI("read_mp3() for bump effect, is_ok=%d", is_ok);
|
||||||
|
|
||||||
mPlayer = new MixingPlayer(samples);
|
mPlayer = new MixingPlayer(samples);
|
||||||
int32_t res = mPlayer->startAudio();
|
int32_t res = mPlayer->startAudio();
|
||||||
playbackRate.store(mPlayer->getRate());
|
playbackRate.store(mPlayer->getRate());
|
||||||
numOutChannels.store(mPlayer->getNumChannels());
|
numOutChannels.store(mPlayer->getNumChannels());
|
||||||
LOGI("startAudio() = %d rate=%d channels=%d", res, playbackRate.load(), numOutChannels.load());
|
LOGI("startAudio() = %d rate=%d channels=%d", res, playbackRate.load(), numOutChannels.load());
|
||||||
|
|
||||||
|
// configure stretcher and start musicFeedThread()
|
||||||
initRubberBand();
|
initRubberBand();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackEngine::initRubberBand() {
|
void PlaybackEngine::initRubberBand() {
|
||||||
// TODO: check mp3 actual sample rate, and adapt to 48000 Hz playback here
|
// we do not yet have a music file with actual sampling rate, so set the default ratio
|
||||||
stretcher.setTimeRatio(1.0);
|
stretcher.setTimeRatio(1.0);
|
||||||
stretcher.setPitchScale(1.0);
|
stretcher.setPitchScale(1.0);
|
||||||
|
|
||||||
stretcher.setDebugLevel(1); // 1: errors only. generally 0..4
|
stretcher.setDebugLevel(1); // 1: errors only. generally 0..4
|
||||||
|
|
||||||
// feed samples into 'stretcher' and read bogus output
|
// feed samples into 'stretcher' and read bogus output
|
||||||
|
|||||||
Reference in New Issue
Block a user