From 495694da29ff736fba2fdc696553ee7197247174 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 10 May 2014 14:00:41 -0400 Subject: opl: Add API to adjust tempo. When the tempo is changed, the times on all active timers must be adjusted to match the new timing values. Add an API to do this and invoke it when a tempo change meta event is read. --- opl/opl_queue.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'opl/opl_queue.c') diff --git a/opl/opl_queue.c b/opl/opl_queue.c index d05cc6a1..ee87a19b 100644 --- a/opl/opl_queue.c +++ b/opl/opl_queue.c @@ -201,6 +201,19 @@ unsigned int OPL_Queue_Peek(opl_callback_queue_t *queue) } } +void OPL_Queue_AdjustCallbacks(opl_callback_queue_t *queue, + unsigned int time, float factor) +{ + int offset; + int i; + + for (i = 0; i < queue->num_entries; ++i) + { + offset = queue->entries[i].time - time; + queue->entries[i].time = time + (int) (offset * factor); + } +} + #ifdef TEST #include -- cgit v1.2.3