summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2009-08-30 23:54:21 +0000
committerSimon Howard2009-08-30 23:54:21 +0000
commit01cebf1373d482f3dca1eb9706a6b85595e83ea1 (patch)
treef27f102aff195547a6e9ecfe76cb6e7cd0f12ba1
parentab14960e3a24208709270fb11476f0bbb629b145 (diff)
downloadchocolate-doom-01cebf1373d482f3dca1eb9706a6b85595e83ea1.tar.gz
chocolate-doom-01cebf1373d482f3dca1eb9706a6b85595e83ea1.tar.bz2
chocolate-doom-01cebf1373d482f3dca1eb9706a6b85595e83ea1.zip
Use milliseconds rather than microseconds, to avoid integer overflow.
Subversion-branch: /branches/opl-branch Subversion-revision: 1648
-rw-r--r--src/i_oplmusic.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index eff3f942..f70e085d 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -108,7 +108,7 @@ typedef struct
// Tempo control variables
unsigned int ticks_per_beat;
- unsigned int us_per_beat;
+ unsigned int ms_per_beat;
} opl_track_data_t;
typedef struct opl_voice_s opl_voice_t;
@@ -823,19 +823,19 @@ static void TrackTimerCallback(void *arg)
static void ScheduleTrack(opl_track_data_t *track)
{
unsigned int nticks;
- unsigned int us;
+ unsigned int ms;
static int total = 0;
- // Get the number of microseconds until the next event.
+ // Get the number of milliseconds until the next event.
nticks = MIDI_GetDeltaTime(track->iter);
- us = (nticks * track->us_per_beat) / track->ticks_per_beat;
- total += us;
+ ms = (nticks * track->ms_per_beat) / track->ticks_per_beat;
+ total += ms;
// Set a timer to be invoked when the next event is
// ready to play.
- OPL_SetCallback(us / 1000, TrackTimerCallback, track);
+ OPL_SetCallback(ms, TrackTimerCallback, track);
}
// Initialise a channel.
@@ -862,7 +862,7 @@ static void StartTrack(midi_file_t *file, unsigned int track_num)
// Default is 120 bpm.
// TODO: this is wrong
- track->us_per_beat = 500 * 1000 * 260;
+ track->ms_per_beat = 500 * 260;
for (i=0; i<MIDI_CHANNELS_PER_TRACK; ++i)
{