aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorMax Horn2003-09-18 16:01:33 +0000
committerMax Horn2003-09-18 16:01:33 +0000
commit9470c9f66131d16ca19d111d21948ba57a1a8eb3 (patch)
tree79aa7b664c9dcab922649ad552ef03fe6ba58e21 /sky
parentdcf77f7a1008e4a6b98c9face6cc7461c6347e1d (diff)
downloadscummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.tar.gz
scummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.tar.bz2
scummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.zip
changed & documented the premixer semantics
svn-id: r10294
Diffstat (limited to 'sky')
-rw-r--r--sky/music/adlibmusic.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp
index 7aaf6e8c0e..52e0a7ed94 100644
--- a/sky/music/adlibmusic.cpp
+++ b/sky/music/adlibmusic.cpp
@@ -39,7 +39,7 @@ SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, OSystem *sys
OPLBuildTables((env_bits ? env_bits : FMOPL_ENV_BITS_HQ), (eg_ent ? eg_ent : FMOPL_EG_ENT_HQ));
_opl = OPLCreate(OPL_TYPE_YM3812, 3579545, _sampleRate);
- _mixer->setupPremix(this, passMixerFunc);
+ _mixer->setupPremix(passMixerFunc, this);
}
SkyAdlibMusic::~SkyAdlibMusic(void) {
@@ -55,30 +55,36 @@ void SkyAdlibMusic::setVolume(uint8 volume) {
_channels[cnt]->updateVolume(volume | 128);
}
-void SkyAdlibMusic::premixerCall(int16 *buf, uint len) {
+void SkyAdlibMusic::premixerCall(int16 *data, uint len) {
if (_musicData == NULL) {
// no music loaded
- memset(buf, 0, len * sizeof(int16));
- return;
+ memset(data, 0, 2 * len * sizeof(int16));
} else if ((_currentMusic == 0) || (_numberOfChannels == 0)) {
// music loaded but not played as of yet
- memset(buf, 0, len * sizeof(int16));
+ memset(data, 0, 2 * len * sizeof(int16));
// poll anyways as pollMusic() can activate the music
pollMusic();
_nextMusicPoll = _sampleRate/50;
- return;
- }
- uint32 render;
- while (len) {
- render = (len > _nextMusicPoll) ? (_nextMusicPoll) : (len);
- len -= render;
- _nextMusicPoll -= render;
- YM3812UpdateOne (_opl, buf, render);
- buf += render;
- if (_nextMusicPoll == 0) {
- pollMusic();
- _nextMusicPoll = _sampleRate/50;
+ } else {
+ uint32 render;
+ int16 *origData = data;
+ uint origLen = len;
+ while (len) {
+ render = (len > _nextMusicPoll) ? (_nextMusicPoll) : (len);
+ len -= render;
+ _nextMusicPoll -= render;
+ YM3812UpdateOne(_opl, data, render);
+ data += render;
+ if (_nextMusicPoll == 0) {
+ pollMusic();
+ _nextMusicPoll = _sampleRate/50;
+ }
+ }
+
+ // Convert mono data to stereo
+ for (int i = (origLen - 1); i >= 0; i--) {
+ origData[2 * i] = origData[2 * i + 1] = origData[i];
}
}
}