diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/sky/music/adlibmusic.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/sky/music/adlibmusic.cpp')
-rw-r--r-- | engines/sky/music/adlibmusic.cpp | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp index dd64c5bc81..be5e7b2353 100644 --- a/engines/sky/music/adlibmusic.cpp +++ b/engines/sky/music/adlibmusic.cpp @@ -22,6 +22,7 @@ #include "common/endian.h" +#include "common/textconsole.h" #include "sky/music/adlibmusic.h" #include "sky/music/adlibchannel.h" @@ -32,44 +33,21 @@ namespace Sky { AdLibMusic::AdLibMusic(Audio::Mixer *pMixer, Disk *pDisk) : MusicBase(pMixer, pDisk) { _driverFileBase = 60202; - _sampleRate = pMixer->getOutputRate(); - _opl = makeAdLibOPL(_sampleRate); + _opl = OPL::Config::create(); + if (!_opl || !_opl->init()) + error("Failed to create OPL"); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _opl->start(new Common::Functor0Mem<void, AdLibMusic>(this, &AdLibMusic::onTimer), 50); } AdLibMusic::~AdLibMusic() { - OPLDestroy(_opl); - _mixer->stopHandle(_soundHandle); + delete _opl; } -int AdLibMusic::readBuffer(int16 *data, const int numSamples) { - if (_musicData == NULL) { - // no music loaded - memset(data, 0, numSamples * sizeof(int16)); - } else if ((_currentMusic == 0) || (_numberOfChannels == 0)) { - // music loaded but not played as of yet - memset(data, 0, numSamples * sizeof(int16)); - // poll anyways as pollMusic() can activate the music +void AdLibMusic::onTimer() { + if (_musicData != NULL) pollMusic(); - _nextMusicPoll = _sampleRate / 50; - } else { - uint32 render; - uint remaining = numSamples; - while (remaining) { - render = (remaining > _nextMusicPoll) ? _nextMusicPoll : remaining; - remaining -= render; - _nextMusicPoll -= render; - YM3812UpdateOne(_opl, data, render); - data += render; - if (_nextMusicPoll == 0) { - pollMusic(); - _nextMusicPoll = _sampleRate / 50; - } - } - } - return numSamples; } void AdLibMusic::setupPointers() { @@ -87,7 +65,6 @@ void AdLibMusic::setupPointers() { _musicDataLoc = READ_LE_UINT16(_musicData + 0x1201); _initSequence = _musicData + 0xE91; } - _nextMusicPoll = 0; } void AdLibMusic::setupChannels(uint8 *channelData) { @@ -102,26 +79,15 @@ void AdLibMusic::setupChannels(uint8 *channelData) { void AdLibMusic::startDriver() { uint16 cnt = 0; while (_initSequence[cnt] || _initSequence[cnt + 1]) { - OPLWriteReg (_opl, _initSequence[cnt], _initSequence[cnt + 1]); + _opl->writeReg(_initSequence[cnt], _initSequence[cnt + 1]); cnt += 2; } } void AdLibMusic::setVolume(uint16 param) { _musicVolume = param; - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 2 * param); -} - -bool AdLibMusic::isStereo() const { - return false; -} - -bool AdLibMusic::endOfData() const { - return false; -} - -int AdLibMusic::getRate() const { - return _sampleRate; + for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) + _channels[cnt]->updateVolume(_musicVolume); } } // End of namespace Sky |