Compare commits
2 Commits
81e8d2727b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 89bb464e7e | |||
| 2a50293799 |
@@ -273,9 +273,15 @@ void PlaybackEngine::musicFeedThread() {
|
||||
}
|
||||
|
||||
if(haveTimeRatio.load() || haveStretchFactor.load()) {
|
||||
LOGI("ratio: %.3lf stretch: %.3lf", timeRatio.load(), stretchFactor.load());
|
||||
#if 1
|
||||
double ratio = timeRatio.load() * stretchFactor.load();
|
||||
#else
|
||||
double ratio = timeRatio.load();
|
||||
#endif
|
||||
stretcher.setTimeRatio(ratio);
|
||||
stretcher.setPitchScale(1.0 / ratio);
|
||||
//stretcher.setPitchScale(1.0 / ratio);
|
||||
stretcher.setPitchScale(1.0 / timeRatio.load());
|
||||
haveTimeRatio.store(false);
|
||||
haveStretchFactor.store(false);
|
||||
}
|
||||
@@ -622,6 +628,11 @@ void MusicProvider::onAudioReady(float *data, int32_t frames) {
|
||||
// this is an audio glitch
|
||||
// TODO: bubble info upwards, in a counter (so we can collect device-specific glitch stats)
|
||||
LOGI("stretcher lag: %d requested, %d available", num_frames_requested, num_frames_available);
|
||||
if(num_frames_available == 0) {
|
||||
// at least play silence, avoiding to play garbled stuff
|
||||
memset(data, 0, sizeof(float)*frames*num_ch_out);
|
||||
return;
|
||||
}
|
||||
}
|
||||
size_t num_frames = std::min(num_frames_available, num_frames_requested);
|
||||
stretcher->retrieve(buf_ptr, num_frames);
|
||||
|
||||
@@ -8,7 +8,9 @@ TempoController::TempoController(std::atomic<bool> *have_stretch_factor, std::at
|
||||
have_stretch_factor(have_stretch_factor),
|
||||
stretch_factor(stretch_factor),
|
||||
lastBeatT(0.0),
|
||||
lastStepT(0.0)
|
||||
lastStepT(0.0),
|
||||
dtBeat(0.0),
|
||||
dtStep(0.0)
|
||||
{
|
||||
this->have_stretch_factor->store(false);
|
||||
this->stretch_factor->store(1.0);
|
||||
@@ -28,7 +30,6 @@ void TempoController::seekTo(double oldMarkerPosSec, double newMarkerPosSec) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
double dt = newMarkerPosSec - oldMarkerPosSec;
|
||||
lastBeatT += dt;
|
||||
lastStepT += dt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ void TempoController::onStep(double t) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
if(lastStepT != 0.0) dtStep = t - lastStepT;
|
||||
lastStepT = t;
|
||||
setStretchFactor();
|
||||
//setStretchFactor(); // one call is enough. otherwise we set twice roughly around the same time.
|
||||
}
|
||||
|
||||
void TempoController::setStretchFactor() {
|
||||
|
||||
Reference in New Issue
Block a user