From 3cf96075498e5091a40579169a98c7430e38a08f Mon Sep 17 00:00:00 2001 From: David Madl Date: Sun, 22 Mar 2026 08:50:39 +0100 Subject: [PATCH] docs --- app/src/main/cpp/PlaybackEngine.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/PlaybackEngine.cpp b/app/src/main/cpp/PlaybackEngine.cpp index abec43b..635f487 100644 --- a/app/src/main/cpp/PlaybackEngine.cpp +++ b/app/src/main/cpp/PlaybackEngine.cpp @@ -54,7 +54,6 @@ static bool read_mp3(std::string filename, std::vector& samples) { return ok1 && ok2; } - struct RbLogger : public RubberBand::RubberBandStretcher::Logger { virtual void log(const char *s) { LOGI("%s", s); @@ -83,6 +82,8 @@ PlaybackEngine::PlaybackEngine(std::string filesDir, int resid): android_fd(0), haveTimeRatio(false), timeRatio(1.0), + + // these 3 values are preliminary -- will be set from MixingPlayer defaults in the ctor body below playbackRate(48000), numOutChannels(2), numInChannels(2) @@ -90,21 +91,27 @@ PlaybackEngine::PlaybackEngine(std::string filesDir, int resid): LOGI("PlaybackEngine()"); LOGI("NDK LOG_LEVEL=%d", LOG_LEVEL); // NDK LOG_LEVEL=3 (DEBUG) + + // load "bump" sound effect std::vector 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); int32_t res = mPlayer->startAudio(); playbackRate.store(mPlayer->getRate()); numOutChannels.store(mPlayer->getNumChannels()); LOGI("startAudio() = %d rate=%d channels=%d", res, playbackRate.load(), numOutChannels.load()); + + // configure stretcher and start musicFeedThread() 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.setPitchScale(1.0); + stretcher.setDebugLevel(1); // 1: errors only. generally 0..4 // feed samples into 'stretcher' and read bogus output