aboutsummaryrefslogtreecommitdiff
path: root/sky/music
diff options
context:
space:
mode:
authorRobert Göffringmann2004-10-22 05:34:18 +0000
committerRobert Göffringmann2004-10-22 05:34:18 +0000
commiteb7fe9cee4f248887ac7d18d84b0637c14a094fc (patch)
treed20d0c7012e2beb6c17aa2c07e24505794df0659 /sky/music
parent5c87bcafa6094239270e65cafe6a9c8a203bdb7c (diff)
downloadscummvm-rg350-eb7fe9cee4f248887ac7d18d84b0637c14a094fc.tar.gz
scummvm-rg350-eb7fe9cee4f248887ac7d18d84b0637c14a094fc.tar.bz2
scummvm-rg350-eb7fe9cee4f248887ac7d18d84b0637c14a094fc.zip
changed timing code.
svn-id: r15639
Diffstat (limited to 'sky/music')
-rw-r--r--sky/music/gmmusic.cpp19
-rw-r--r--sky/music/gmmusic.h2
-rw-r--r--sky/music/mt32music.cpp22
-rw-r--r--sky/music/mt32music.h2
4 files changed, 22 insertions, 23 deletions
diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp
index e7653ef19c..733a18fde4 100644
--- a/sky/music/gmmusic.cpp
+++ b/sky/music/gmmusic.cpp
@@ -38,11 +38,10 @@ GmMusic::GmMusic(MidiDriver *pMidiDrv, Disk *pDisk, OSystem *system)
_driverFileBase = 60200;
_midiDrv = pMidiDrv;
int midiRes = _midiDrv->open();
- if (midiRes != 0) {
+ if (midiRes != 0)
error("Can't open midi device. Errorcode: %d", midiRes);
- }
+ _timerCount = 0;
_midiDrv->setTimerCallback(this, passTimerFunc);
- _ignoreNextPoll = false;
}
GmMusic::~GmMusic(void) {
@@ -62,13 +61,13 @@ void GmMusic::setVolume(uint8 volume) {
}
void GmMusic::timerCall(void) {
-
- // midi driver polls hundred times per sec. We only want 50 times.
- _ignoreNextPoll = !_ignoreNextPoll;
- if (!_ignoreNextPoll) return;
-
- if (_musicData != NULL)
- pollMusic();
+ _timerCount += _midiDrv->getBaseTempo();
+ if (_timerCount > (1000000 / 50)) {
+ // call pollMusic() 50 times per second
+ _timerCount -= 1000000 / 50;
+ if (_musicData != NULL)
+ pollMusic();
+ }
}
void GmMusic::setupPointers(void) {
diff --git a/sky/music/gmmusic.h b/sky/music/gmmusic.h
index b6bb2c7c98..8eceb90ad3 100644
--- a/sky/music/gmmusic.h
+++ b/sky/music/gmmusic.h
@@ -37,7 +37,7 @@ private:
static void passTimerFunc(void *param);
void timerCall(void);
- bool _ignoreNextPoll;
+ uint32 _timerCount;
uint8 *_sysExSequence;
MidiDriver *_midiDrv;
static byte _mt32_to_gm[128];
diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp
index a9ed8b693a..8be1e3e7db 100644
--- a/sky/music/mt32music.cpp
+++ b/sky/music/mt32music.cpp
@@ -37,13 +37,12 @@ MT32Music::MT32Music(MidiDriver *pMidiDrv, Disk *pDisk, OSystem *system)
_driverFileBase = 60200;
_midiDrv = pMidiDrv;
int midiRes = _midiDrv->open();
- if (midiRes != 0) {
+ if (midiRes != 0)
error("Can't open midi device. Errorcode: %d",midiRes);
- }
- _midiDrv->setTimerCallback(this, passTimerFunc);
- _ignoreNextPoll = false;
for (uint8 cnt = 0; cnt < 128; cnt++)
_dummyMap[cnt] = cnt;
+ _timerCount = 0;
+ _midiDrv->setTimerCallback(this, passTimerFunc);
}
MT32Music::~MT32Music(void) {
@@ -54,13 +53,13 @@ MT32Music::~MT32Music(void) {
}
void MT32Music::timerCall(void) {
-
- // midi driver polls hundred times per sec. We only want 50 times.
- _ignoreNextPoll = !_ignoreNextPoll;
- if (!_ignoreNextPoll) return;
-
- if (_musicData != NULL)
- pollMusic();
+ _timerCount += _midiDrv->getBaseTempo();
+ if (_timerCount > (1000000 / 50)) {
+ // call pollMusic() 50 times per second
+ _timerCount -= 1000000 / 50;
+ if (_musicData != NULL)
+ pollMusic();
+ }
}
void MT32Music::setVolume(uint8 volume) {
@@ -87,6 +86,7 @@ void MT32Music::setupChannels(uint8 *channelData) {
for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc;
_channels[cnt] = new GmChannel(_musicData, chDataStart, _midiDrv, _dummyMap, _dummyMap);
+ _channels[cnt]->updateVolume(_musicVolume);
}
}
diff --git a/sky/music/mt32music.h b/sky/music/mt32music.h
index 46409f6b11..8038a6dda9 100644
--- a/sky/music/mt32music.h
+++ b/sky/music/mt32music.h
@@ -38,7 +38,7 @@ private:
bool processPatchSysEx(uint8 *sysExData);
virtual void setVolume(uint8 volume);
- bool _ignoreNextPoll;
+ uint32 _timerCount;
uint8 *_sysExSequence;
MidiDriver *_midiDrv;
uint8 _dummyMap[128];