fix: adjust pitch, not just speed

This commit is contained in:
2026-03-28 04:39:19 +01:00
parent 1a3991db45
commit 6c5ac60ccb
3 changed files with 8 additions and 1 deletions

View File

@@ -231,7 +231,9 @@ void PlaybackEngine::musicFeedThread() {
}
if(haveTimeRatio.load()) {
stretcher.setTimeRatio(timeRatio.load());
double ratio = timeRatio.load();
stretcher.setTimeRatio(ratio);
stretcher.setPitchScale(ratio);
haveTimeRatio.store(false);
}
@@ -313,6 +315,7 @@ void PlaybackEngine::musicFeedThread() {
// next iteration will play silence
closeMusicFile();
stretcher.setTimeRatio(1.0); // buffer size for playing silence is computed from 'playbackRate', so reset timeRatio
stretcher.setPitchScale(1.0);
stretcher.process(buf_ptr, 0, true); // set end of playback
mPlayer->stopAudio();
continue;
@@ -322,6 +325,7 @@ void PlaybackEngine::musicFeedThread() {
LOGI("finished reading mp3 file (MPG123_DONE)");
closeMusicFile();
stretcher.setTimeRatio(1.0); // buffer size for playing silence is computed from 'playbackRate', so reset timeRatio
stretcher.setPitchScale(1.0);
stretcher.process(buf_ptr, 0, true); // set end of playback
mPlayer->stopAudio();
continue;

View File

@@ -259,6 +259,8 @@ public class LstForegroundService extends Service implements SensorEventListener
stepDetector.filter(event.timestamp, event.values);
// collect accelerometer recording - adjust timebase to 0.0 sec beginning
recording.add(new SensorData(event.timestamp - recordingStartTime, event.values));
// TODO: acquires at 8 ms intervals ... 125 Hz?!
// TODO: must compute actual sampling rate. and either downsample, or adapt the IIR filter parameters. (& length??) - easier to resample.
}
@Override