From 6d08055db3368dbaadb22e82d78c86bcb1026950 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 21 May 2015 22:47:02 +0200 Subject: KYRA: Update comment since the file it pointed to moved Also, ScummVM does have a more modern FMOPL implementation now, so there's no need to bring up other implementations. --- engines/kyra/sound_adlib.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 89ee41e859..c0e0f67b8e 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -947,15 +947,10 @@ void AdLibDriver::unkOutput2(uint8 chan) { // // This is very strange behavior, and causes problems with the ancient // FMOPL code we borrowed from AdPlug. I've added a workaround. See - // fmopl.cpp for more details. + // audio/softsynth/opl/mame.cpp for more details. // - // More recent versions of the MAME FMOPL don't seem to have this - // problem, but cannot currently be used because of licensing and - // performance issues. - // - // Ken Silverman's AdLib emulator (which can be found on his Web page - - // http://www.advsys.net/ken - and as part of AdPlug) also seems to be - // immune, but is apparently not as feature complete as MAME's. + // Fortunately, the more modern DOSBox FMOPL code does not seem to have + // any trouble with this. writeOPL(0xB0 + chan, 0x20); } -- cgit v1.2.3 From f1f29302f5401c4782985cec4d47d069b99036ee Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 3 Apr 2015 00:18:58 -0400 Subject: AUDIO: Remove the legacy OPL API --- engines/kyra/sound_adlib.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index c0e0f67b8e..203931fcd1 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -88,7 +88,7 @@ public: int32 render = MIN(samplesLeft, _samplesTillCallback); samplesLeft -= render; _samplesTillCallback -= render; - YM3812UpdateOne(_adlib, buffer, render); + _adlib->readBuffer(buffer, render); buffer += render; } return numSamples; @@ -365,7 +365,7 @@ private: uint8 _unkValue19; uint8 _unkValue20; - FM_OPL *_adlib; + OPL::OPL *_adlib; uint8 *_soundData; uint32 _soundDataSize; @@ -427,8 +427,9 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { _mixer = mixer; - _adlib = makeAdLibOPL(getRate()); - assert(_adlib); + _adlib = OPL::Config::create(); + if (!_adlib || !_adlib->init(getRate())) + error("Failed to create OPL"); memset(_channels, 0, sizeof(_channels)); _soundData = 0; @@ -471,7 +472,7 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { AdLibDriver::~AdLibDriver() { _mixer->stopHandle(_soundHandle); - OPLDestroy(_adlib); + delete _adlib; _adlib = 0; } @@ -877,7 +878,7 @@ void AdLibDriver::resetAdLibState() { // New calling style: writeOPL(0xAB, 0xCD) void AdLibDriver::writeOPL(byte reg, byte val) { - OPLWriteReg(_adlib, reg, val); + _adlib->writeReg(reg, val); } void AdLibDriver::initChannel(Channel &channel) { -- cgit v1.2.3 From 2e8f9dcec93653f1bd1f115662f9fcf3a5581fd8 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 3 Apr 2015 01:05:03 -0400 Subject: AUDIO: Remove the sample rate configuration from the OPL code --- engines/kyra/sound_adlib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra') diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 203931fcd1..ad3395b74a 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -428,7 +428,7 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { _mixer = mixer; _adlib = OPL::Config::create(); - if (!_adlib || !_adlib->init(getRate())) + if (!_adlib || !_adlib->init()) error("Failed to create OPL"); memset(_channels, 0, sizeof(_channels)); -- cgit v1.2.3 From 5803dffead8cdf51bac64f00d095e5f5604d9e27 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 3 Apr 2015 17:20:29 -0400 Subject: KYRA: Use the built-in OPL timer --- engines/kyra/sound_adlib.cpp | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index ad3395b74a..999bd96972 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -72,28 +72,10 @@ public: // AudioStream API int readBuffer(int16 *buffer, const int numSamples) { - int32 samplesLeft = numSamples; - memset(buffer, 0, sizeof(int16) * numSamples); - while (samplesLeft) { - if (!_samplesTillCallback) { - callback(); - _samplesTillCallback = _samplesPerCallback; - _samplesTillCallbackRemainder += _samplesPerCallbackRemainder; - if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) { - _samplesTillCallback++; - _samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND; - } - } - - int32 render = MIN(samplesLeft, _samplesTillCallback); - samplesLeft -= render; - _samplesTillCallback -= render; - _adlib->readBuffer(buffer, render); - buffer += render; - } - return numSamples; + return _adlib->readBuffer(buffer, numSamples); } + bool isStereo() const { return false; } bool endOfData() const { return false; } int getRate() const { return _mixer->getOutputRate(); } @@ -334,11 +316,6 @@ private: // _unkTable2_2[] - One of the tables in _unkTable2[] // _unkTable2_3[] - One of the tables in _unkTable2[] - int32 _samplesPerCallback; - int32 _samplesPerCallbackRemainder; - int32 _samplesTillCallback; - int32 _samplesTillCallbackRemainder; - int _curChannel; uint8 _soundTrigger; @@ -452,13 +429,6 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { _tablePtr1 = _tablePtr2 = 0; - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); - - _samplesPerCallback = getRate() / CALLBACKS_PER_SECOND; - _samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND; - _samplesTillCallback = 0; - _samplesTillCallbackRemainder = 0; - _syncJumpMask = 0; _musicVolume = 0; @@ -468,6 +438,9 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { _programQueueStart = _programQueueEnd = 0; _retrySounds = false; + + _adlib->start(new Common::Functor0Mem(this, &AdLibDriver::callback), CALLBACKS_PER_SECOND); + _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } AdLibDriver::~AdLibDriver() { -- cgit v1.2.3 From bed9da8b9dbbaa19d317f71663e42875c1717fda Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 30 Apr 2015 00:01:30 -0400 Subject: AUDIO: Remove all AudioStream access to OPL --- engines/kyra/sound_adlib.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 999bd96972..1d741d8bd0 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -55,7 +55,7 @@ namespace Kyra { -class AdLibDriver : public Audio::AudioStream { +class AdLibDriver { public: AdLibDriver(Audio::Mixer *mixer, int version); ~AdLibDriver(); @@ -70,16 +70,6 @@ public: void callback(); - // AudioStream API - int readBuffer(int16 *buffer, const int numSamples) { - return _adlib->readBuffer(buffer, numSamples); - } - - - bool isStereo() const { return false; } - bool endOfData() const { return false; } - int getRate() const { return _mixer->getOutputRate(); } - void setSyncJumpMask(uint16 mask) { _syncJumpMask = mask; } void setMusicVolume(uint8 volume); @@ -388,7 +378,6 @@ private: Common::Mutex _mutex; Audio::Mixer *_mixer; - Audio::SoundHandle _soundHandle; uint8 _musicVolume, _sfxVolume; @@ -440,11 +429,9 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) { _retrySounds = false; _adlib->start(new Common::Functor0Mem(this, &AdLibDriver::callback), CALLBACKS_PER_SECOND); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } AdLibDriver::~AdLibDriver() { - _mixer->stopHandle(_soundHandle); delete _adlib; _adlib = 0; } -- cgit v1.2.3