mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-05 05:05:43 +01:00
Fix MIDI Clock generator (rounding issues)
This broke inf67029bd0and notablybcc1aeeb86. next_tick needs to accommodate for sub-sample accuracy when PPQN are not integer samples. e.g. 110 bpm @ 48kHz PS. Instead of `double` we could use superclock next_tick, and `one_ppqn_in_superclocks` respectively. This would provide us with 62 bit significand (instead of 52 bit using double). Yet for the case of MIDI clock, this will have no real world effect.
This commit is contained in:
parent
c98a36be0f
commit
6e2d34df2d
2 changed files with 3 additions and 2 deletions
|
|
@ -47,7 +47,7 @@ private:
|
|||
ARDOUR::Session& _session;
|
||||
std::shared_ptr<MidiPort> _midi_port;
|
||||
bool _rolling;
|
||||
samplepos_t _next_tick;
|
||||
double _next_tick;
|
||||
uint32_t _beat_pos;
|
||||
uint32_t _clock_cnt;
|
||||
samplepos_t _transport_pos;
|
||||
|
|
|
|||
|
|
@ -219,7 +219,8 @@ double
|
|||
MidiClockTicker::one_ppqn_in_samples (samplepos_t transport_position) const
|
||||
{
|
||||
TempoPoint const & tempo (TempoMap::use()->metric_at (timepos_t (transport_position)).tempo());
|
||||
const double samples_per_quarter_note = superclock_to_samples (tempo.superclocks_per_note_type_at (timepos_t (transport_position)), _session.nominal_sample_rate());
|
||||
/* un-rounded superclock_to_samples (tempo.superclocks_per_note_type_at (timepos_t (transport_position)), _session.nominal_sample_rate()) */
|
||||
const double samples_per_quarter_note = tempo.superclocks_per_note_type_at (timepos_t (transport_position)) * _session.nominal_sample_rate() / (double)superclock_ticks_per_second ();
|
||||
return samples_per_quarter_note / 24.0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue