feat: TempoController: minimal demo
This commit is contained in:
@@ -37,7 +37,9 @@ void TempoController::seekTo(double oldMarkerPosSec, double newMarkerPosSec) {
|
||||
*/
|
||||
void TempoController::onBeat(double t) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
if(lastBeatT != 0.0) dtBeat = t - lastBeatT;
|
||||
lastBeatT = t;
|
||||
setStretchFactor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,5 +48,16 @@ void TempoController::onBeat(double t) {
|
||||
*/
|
||||
void TempoController::onStep(double t) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
if(lastStepT != 0.0) dtStep = t - lastStepT;
|
||||
lastStepT = t;
|
||||
setStretchFactor();
|
||||
}
|
||||
|
||||
void TempoController::setStretchFactor() {
|
||||
if(dtBeat == 0.0 || dtStep == 0.0) return;
|
||||
double ratio = dtStep / dtBeat;
|
||||
ratio = std::min(3.3, ratio);
|
||||
ratio = std::max(0.3, ratio);
|
||||
this->have_stretch_factor->store(true);
|
||||
this->stretch_factor->store(ratio);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user