77#include < halp/meta.hpp>
88#include < halp/midi.hpp>
99#include < libremidi/message.hpp>
10+ #include < ossia/detail/pod_vector.hpp>
11+ #include < ossia/detail/small_vector.hpp>
1012
1113#include < array>
1214#include < optional>
@@ -118,8 +120,10 @@ struct MIDISyncIn
118120 std::chrono::steady_clock::time_point last_mtc_timestamp;
119121
120122 // Clock tick tracking
123+ static constexpr size_t max_interval_history = 24 ; // 1 beat worth at 24 PPQN
121124 std::chrono::steady_clock::time_point last_clock_tick;
122- std::deque<double > tick_intervals; // Recent tick intervals for tempo estimation
125+ ossia::small_pod_vector<double , max_interval_history>
126+ tick_intervals; // Recent tick intervals for tempo estimation
123127 double estimated_tempo = 120.0 ;
124128 double filtered_tempo = 120.0 ;
125129 uint32_t ticks_since_mtc = 0 ;
@@ -130,13 +134,12 @@ struct MIDISyncIn
130134 uint16_t song_position_pointer = 0 ; // MIDI Song Position (in 16th notes)
131135 bool transport_running = false ;
132136
133- static constexpr size_t max_interval_history = 24 ; // 1 beat worth at 24 PPQN
134-
135137 void reset ()
136138 {
137139 active = false ;
138140 ticks_since_mtc = 0 ;
139141 tick_intervals.clear ();
142+
140143 estimated_tempo = 120.0 ;
141144 filtered_tempo = 120.0 ;
142145 clock_position_seconds = 0.0 ;
@@ -446,7 +449,7 @@ struct MIDISyncIn
446449 // Keep only recent history
447450 while (clock_interp.tick_intervals .size () > clock_interp.max_interval_history )
448451 {
449- clock_interp.tick_intervals .pop_front ( );
452+ clock_interp.tick_intervals .erase (clock_interp. tick_intervals . begin () );
450453 }
451454
452455 // Estimate tempo from tick intervals
0 commit comments