13
0

* enabled moving averages again... plays much nicer in a realtime setup

* disabled excessive tracing

git-svn-id: svn://localhost/ardour2/branches/3.0@3668 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-08-07 04:03:17 +00:00
parent 9e677f9a9b
commit 025f7a1c69
2 changed files with 30 additions and 4 deletions

View File

@ -135,6 +135,11 @@ class MIDIClock_Slave : public Slave, public sigc::trackable {
nframes_t first_midi_clock_frame;
nframes_t first_midi_clock_time;
static const int32_t accumulator_size = 128;
float accumulator[accumulator_size];
int32_t accumulator_index;
bool have_first_accumulated_speed;
void reset ();
void start (MIDI::Parser& parser);
void stop (MIDI::Parser& parser);

View File

@ -97,10 +97,11 @@ MIDIClock_Slave::update_midi_clock (Parser& parser)
midi_clock_frame += (long) (one_ppqn_in_frames)
+ session.worst_output_latency();
/*
std::cerr << "got MIDI Clock message at time " << now
<< " midi_clock_frame: " << midi_clock_frame
<< " one_ppqn_in_frames: " << one_ppqn_in_frames << std::endl;
*/
if (first_midi_clock_frame == 0) {
first_midi_clock_frame = midi_clock_frame;
first_midi_clock_time = now;
@ -204,9 +205,29 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
speed_now = (float) ((last.position - first_midi_clock_frame) / (double) (now - first_midi_clock_time));
}
cerr << "speed_and_position: speed_now: " << speed_now ;
//cerr << "speed_and_position: speed_now: " << speed_now ;
midi_clock_speed = speed_now;
accumulator[accumulator_index++] = speed_now;
if (accumulator_index >= accumulator_size) {
have_first_accumulated_speed = true;
accumulator_index = 0;
}
if (have_first_accumulated_speed) {
float total = 0;
for (int32_t i = 0; i < accumulator_size; ++i) {
total += accumulator[i];
}
midi_clock_speed = total / accumulator_size;
} else {
midi_clock_speed = speed_now;
}
if (midi_clock_speed == 0.0f) {
@ -229,7 +250,7 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
speed = midi_clock_speed;
cerr << " final speed: " << speed << " position: " << pos << endl;
//cerr << " final speed: " << speed << " position: " << pos << endl;
return true;
}