65f6070348
Hold keeps its picker. Also: one home for the %-fold, duration-ordered Hold travel, and a corrupt tail degrades to absent rather than fabricating one.
20 lines
759 B
C++
20 lines
759 B
C++
// trigger_seam.cpp — see trigger_seam.h.
|
|
|
|
#include "core/instrument/map/trigger_seam.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace reasampler::instrument::map {
|
|
|
|
std::int64_t triggerPlayLength(double lengthFraction,
|
|
std::int64_t frameCount,
|
|
std::int64_t startFrame) {
|
|
const std::int64_t postStart = (std::max)(std::int64_t{0}, frameCount - startFrame);
|
|
if (postStart <= 0 || !(lengthFraction > 0.0)) return 0; // also catches NaN
|
|
const double frac = (std::min)(1.0, lengthFraction);
|
|
const auto len = static_cast<std::int64_t>(frac * static_cast<double>(postStart) + 0.5);
|
|
return (std::min)(postStart, (std::max)(std::int64_t{0}, len));
|
|
}
|
|
|
|
} // namespace reasampler::instrument::map
|