Correcting w.r.t. comments

This commit is contained in:
Paul Fd 2021-03-20 22:12:36 +01:00
parent 2735d1536e
commit ec021ae5de
5 changed files with 26 additions and 5 deletions

View file

@ -157,10 +157,9 @@ absl::Span<const float> BeatClock::getRunningBeatPosition()
return absl::MakeConstSpan(runningBeatPosition_.data(), currentCycleFrames_);
}
float BeatClock::getLastBeatPosition() const
double BeatClock::getLastBeatPosition() const
{
double beats = lastClientPos_.toBeats(timeSig_);
return static_cast<float>(beats);
return lastClientPos_.toBeats(timeSig_);
}
absl::Span<const int> BeatClock::getRunningBeatsPerBar()

View file

@ -145,7 +145,7 @@ public:
*
* @return float
*/
float getLastBeatPosition() const;
double getLastBeatPosition() const;
/**
* @brief Get the Beats Per Frame object
*

View file

@ -31,6 +31,12 @@ void OnePoleSmoother::setSmoothing(unsigned smoothValue, float sampleRate)
void OnePoleSmoother::reset(float value)
{
filter.reset(value);
target_ = value;
}
void OnePoleSmoother::resetToTarget()
{
reset(target_);
}
void OnePoleSmoother::process(absl::Span<const float> input, absl::Span<float> output, bool canShortcut)
@ -55,6 +61,8 @@ void OnePoleSmoother::process(absl::Span<const float> input, absl::Span<float> o
} else if (input.data() != output.data()) {
copy<float>(input, output);
}
target_ = input.back();
}
///
@ -76,6 +84,11 @@ void LinearSmoother::reset(float value)
//framesToTarget_ = 0;
}
void LinearSmoother::resetToTarget()
{
reset(target_);
}
void LinearSmoother::process(absl::Span<const float> input, absl::Span<float> output, bool canShortcut)
{
CHECK_SPAN_SIZES(input, output);

View file

@ -31,6 +31,10 @@ public:
* @param value
*/
void reset(float value = 0.0f);
/**
* @brief Reset to the target value (the back of the last vector passed)
*/
void resetToTarget();
/**
* @brief Process a span of data. Input and output can refer to the same
* memory.
@ -47,6 +51,7 @@ public:
private:
bool smoothing { false };
OnePoleFilter<float> filter {};
float target_ { 0.0f };
};
/**
@ -70,6 +75,10 @@ public:
* @param value
*/
void reset(float value = 0.0f);
/**
* @brief Reset to the target value (the back of the last vector passed)
*/
void resetToTarget();
/**
* @brief Process a span of data. Input and output can refer to the same
* memory.

View file

@ -1312,7 +1312,7 @@ void Synth::timePosition(int delay, int bar, double barBeat)
const auto newBeatPosition = newPosition.toBeats(impl.resources_.beatClock.getTimeSignature());
const auto currentBeatPosition = impl.resources_.beatClock.getLastBeatPosition();
const auto positionDifference = std::abs(newBeatPosition - currentBeatPosition);
const auto threshold = 2 * static_cast<float>(impl.resources_.beatClock.getBeatsPerFrame());
const auto threshold = 2 * impl.resources_.beatClock.getBeatsPerFrame();
if (positionDifference > threshold)
impl.playheadMoved_ = true;