Hi
I try to fetch the bpm from the Midi Clock, and stumble over "jitter".
So I start to collect data for a larger amount of time, but it wouldn't
help.
Here is what I do:
else if ((in_event.buffer[0] ) == 0xf8) { // midi beat clock
clock_gettime(CLOCK_MONOTONIC, &ts1);
time0 = (ts1.tv_sec*1000000000.0)+(ts1.tv_nsec);
static int collect = 0;
static int bpm = 0;
bpm += ((1000000000 / (time0-time1) / 24) * 60); // nanosec
to bpm
collect+=1;
if (collect >=30) {
set_bpm_val(bpm/collect);
collect = 0;
bpm = 0;
}
timed = time0-time1;
// printf("Midi clock event %X time0 %f time1 %f timed %f
ts1.tv_nsec %lu\n",in_event.buffer[0], time0, time1, timed, ts1.tv_nsec);
time1 = time0;
} else if ((in_event.buffer[0] ) == 0xfa) { // midi clock start
printf("Midi clock start\n");
//set_ctr_val(MIDICLOCK, 1);
} else if ((in_event.buffer[0] ) == 0xfb) { // midi beat
clock continue
//set_ctr_val(MIDICLOCK, 1);
printf("Midi clock continue\n");
}else if ((in_event.buffer[0] ) == 0xfc) { // midi beat clock
stop
//set_ctr_val(MIDICLOCK, 0);
printf("Midi clock stop\n");
} else {
printf("CC number %x\n", in_event.buffer[0] );
}
tim0 and time1 are set as double.
I experience jitter around 1 or 2 beats around the "original bpm set in
the master.
When master is set to 360 I receive 374.
How do you usually fetch the bpm from Midi Clock, any pointer will be
welcome.
regards
hermann
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sun Nov 2 00:15:04 2014
This archive was generated by hypermail 2.1.8 : Sun Nov 02 2014 - 00:15:06 EET