Skip to content

Commit 82f6179

Browse files
committed
tick: use an espilon for very slow speed instead of == 0.
1 parent c6b7edd commit 82f6179

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

src/ossia/dataflow/execution_state.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ ossia::net::node_base* exec_state_facade::find_node(std::string_view name) const
519519
auto exec_state_facade::timings(const token_request& t) const noexcept -> sample_timings
520520
{
521521
sample_timings tm;
522-
if(t.speed > 0.)
522+
static constexpr double speed_epsilon = 0.01;
523+
if(t.speed > speed_epsilon)
523524
{
524525
[[likely]];
525526
tm.start_sample = t.physical_start(impl->modelToSamplesRatio);
@@ -531,13 +532,7 @@ auto exec_state_facade::timings(const token_request& t) const noexcept -> sample
531532

532533
tm.length = std::min(tick_dur, max_dur);
533534
}
534-
else if(t.speed == 0.)
535-
{
536-
tm.start_sample = 0;
537-
tm.length = 0;
538-
return tm;
539-
}
540-
else
535+
else if(t.speed < -speed_epsilon)
541536
{
542537
tm.start_sample = -t.physical_start(impl->modelToSamplesRatio);
543538

@@ -548,29 +543,38 @@ auto exec_state_facade::timings(const token_request& t) const noexcept -> sample
548543

549544
tm.length = std::min(tick_dur, max_dur);
550545
}
551-
546+
else
547+
{
548+
tm.start_sample = 0;
549+
tm.length = 0;
550+
return tm;
551+
}
552552
if(tm.start_sample < 0)
553553
{
554554
[[unlikely]];
555-
assert(false);
555+
ossia::logger().error("tm.start_sample < 0: {}", tm.start_sample);
556556
return {};
557557
}
558558
if(tm.start_sample >= impl->bufferSize)
559559
{
560560
[[unlikely]];
561-
assert(false);
561+
ossia::logger().error(
562+
"tm.start_sample >= impl->bufferSize: {} >= {}", tm.start_sample,
563+
impl->bufferSize);
562564
return {};
563565
}
564566
if(tm.length < 0)
565567
{
566568
[[unlikely]];
567-
assert(false);
569+
ossia::logger().error("tm.length < 0: {}", tm.length);
568570
return {};
569571
}
570572
if(tm.start_sample + tm.length > impl->bufferSize)
571573
{
572574
[[unlikely]];
573-
assert(false);
575+
ossia::logger().error(
576+
"tm.start_sample + tm.length > impl->bufferSize: {} + {} > {}", tm.start_sample,
577+
tm.length, impl->bufferSize);
574578
return {};
575579
}
576580
return tm;

src/ossia/dataflow/nodes/timestretch/rubberband_stretcher.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct rubberband_stretcher
8484
int64_t samples_to_read, const int64_t samples_to_write,
8585
const int64_t samples_offset, const ossia::mutable_audio_span<double>& ap) noexcept
8686
{
87-
const double abs_tempo_ratio = std::abs(tempo_ratio);
87+
const double abs_tempo_ratio = std::min(70., std::abs(tempo_ratio));
8888
if(abs_tempo_ratio != m_rubberBand->getTimeRatio())
8989
{
9090
m_rubberBand->setTimeRatio(abs_tempo_ratio);

0 commit comments

Comments
 (0)