1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-10-25 09:27:01 +00:00

Made very first attempt at closing the loop on this. But it's time for work.

This commit is contained in:
Thomas Harte
2016-08-03 08:16:23 -04:00
parent e15241dc3c
commit 9af9b28baf
4 changed files with 36 additions and 20 deletions

View File

@@ -29,6 +29,18 @@ void TimedEventLoop::reset_timer()
_stepper.reset();
}
void TimedEventLoop::reset_timer_to_offset(Time offset)
{
unsigned int common_clock_rate = NumberTheory::least_common_multiple(offset.clock_rate, _event_interval.clock_rate);
_time_into_interval = offset.length * (common_clock_rate / offset.clock_rate);
_event_interval.length *= common_clock_rate / _event_interval.clock_rate;
_event_interval.clock_rate = common_clock_rate;
if(common_clock_rate != _stepper->get_output_rate())
{
_stepper.reset(new SignalProcessing::Stepper(_event_interval.clock_rate, _input_clock_rate));
}
}
void TimedEventLoop::jump_to_next_event()
{
reset_timer();