pw-cat: fix tempo changes

Use time in seconds as event timestamp.
Apply tempo from the new events, keep track of elapsed time and
time since tempo change to get the right time.
Skip metadata midi in pw-cat.
This commit is contained in:
Wim Taymans 2020-02-18 16:13:35 +01:00
parent fe616e38d8
commit b6a6d1f0bb
3 changed files with 12 additions and 7 deletions

View file

@ -989,8 +989,10 @@ static int midi_play(struct data *d, void *src, unsigned int n_frames)
if (res < 0)
return res;
frame = ev.tick * ((double)d->position->clock.rate.denom * d->md.file.tempo) /
(1000000.0 * d->md.file.division);
if (ev.status == 0xff)
goto next;
frame = ev.sec * d->position->clock.rate.denom;
if (frame < first_frame)
frame = 0;
@ -1001,11 +1003,10 @@ static int midi_play(struct data *d, void *src, unsigned int n_frames)
spa_pod_builder_control(&b, frame, SPA_CONTROL_Midi);
buf[0] = ev.status;
if (ev.status == 0xff)
buf[1] = ev.meta;
midi_read(d, ev.offset, ev.status == 0xff ? &buf[2] : &buf[1], ev.size);
midi_read(d, ev.offset, &buf[1], ev.size);
spa_pod_builder_bytes(&b, buf, ev.size + 1);
next:
midi_file_consume_event(&d->md.file, &ev);
}
spa_pod_builder_pop(&b, &f);