aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/fmopl.h3
-rw-r--r--audio/miles_adlib.cpp4
-rw-r--r--audio/softsynth/adlib.cpp2
-rw-r--r--audio/softsynth/opl/dosbox.cpp9
-rw-r--r--audio/softsynth/opl/dosbox.h2
-rw-r--r--audio/softsynth/opl/mame.cpp6
-rw-r--r--audio/softsynth/opl/mame.h2
-rw-r--r--engines/agos/drivers/accolade/adlib.cpp4
-rw-r--r--engines/cine/sound.cpp2
-rw-r--r--engines/cruise/sound.cpp2
-rw-r--r--engines/gob/sound/adlib.cpp2
-rw-r--r--engines/kyra/sound_adlib.cpp2
-rw-r--r--engines/mads/nebular/sound_nebular.cpp6
-rw-r--r--engines/mads/nebular/sound_nebular.h2
-rw-r--r--engines/mads/sound.cpp2
-rw-r--r--engines/parallaction/adlib.cpp2
-rw-r--r--engines/queen/midiadlib.cpp2
-rw-r--r--engines/sci/sound/drivers/adlib.cpp4
-rw-r--r--engines/scumm/players/player_ad.cpp2
-rw-r--r--engines/sherlock/scalpel/drivers/adlib.cpp4
-rw-r--r--engines/sky/music/adlibmusic.cpp2
-rw-r--r--engines/tsage/sound.cpp2
22 files changed, 33 insertions, 35 deletions
diff --git a/audio/fmopl.h b/audio/fmopl.h
index b8dbdc1550..aaa8edd42d 100644
--- a/audio/fmopl.h
+++ b/audio/fmopl.h
@@ -108,10 +108,9 @@ public:
/**
* Initializes the OPL emulator.
*
- * @param rate output sample rate
* @return true on success, false on failure
*/
- virtual bool init(int rate) = 0;
+ virtual bool init() = 0;
/**
* Reinitializes the OPL emulator
diff --git a/audio/miles_adlib.cpp b/audio/miles_adlib.cpp
index 903b0a92be..4560a812e7 100644
--- a/audio/miles_adlib.cpp
+++ b/audio/miles_adlib.cpp
@@ -298,8 +298,6 @@ MidiDriver_Miles_AdLib::~MidiDriver_Miles_AdLib() {
}
int MidiDriver_Miles_AdLib::open() {
- int rate = _mixer->getOutputRate();
-
if (_modeOPL3) {
// Try to create OPL3 first
_opl = OPL::Config::create(OPL::Config::kOpl3);
@@ -319,7 +317,7 @@ int MidiDriver_Miles_AdLib::open() {
return -1;
}
- _opl->init(rate);
+ _opl->init();
MidiDriver_Emulated::open();
diff --git a/audio/softsynth/adlib.cpp b/audio/softsynth/adlib.cpp
index 98519343b4..49e69ecd57 100644
--- a/audio/softsynth/adlib.cpp
+++ b/audio/softsynth/adlib.cpp
@@ -1434,7 +1434,7 @@ int MidiDriver_ADLIB::open() {
_opl3Mode = false;
}
#endif
- _opl->init(getRate());
+ _opl->init();
_regCache = (byte *)calloc(256, 1);
diff --git a/audio/softsynth/opl/dosbox.cpp b/audio/softsynth/opl/dosbox.cpp
index 5c3d833f54..bcc73a9b9e 100644
--- a/audio/softsynth/opl/dosbox.cpp
+++ b/audio/softsynth/opl/dosbox.cpp
@@ -32,6 +32,7 @@
#include "dosbox.h"
#include "dbopl.h"
+#include "audio/mixer.h"
#include "common/system.h"
#include "common/scummsys.h"
#include "common/util.h"
@@ -156,7 +157,7 @@ void OPL::free() {
_emulator = 0;
}
-bool OPL::init(int rate) {
+bool OPL::init() {
free();
memset(&_reg, 0, sizeof(_reg));
@@ -167,19 +168,19 @@ bool OPL::init(int rate) {
return false;
DBOPL::InitTables();
- _emulator->Setup(rate);
+ _rate = g_system->getMixer()->getOutputRate();
+ _emulator->Setup(_rate);
if (_type == Config::kDualOpl2) {
// Setup opl3 mode in the hander
_emulator->WriteReg(0x105, 1);
}
- _rate = rate;
return true;
}
void OPL::reset() {
- init(_rate);
+ init();
}
void OPL::write(int port, int val) {
diff --git a/audio/softsynth/opl/dosbox.h b/audio/softsynth/opl/dosbox.h
index 513a49f6b8..d3df6ba6ed 100644
--- a/audio/softsynth/opl/dosbox.h
+++ b/audio/softsynth/opl/dosbox.h
@@ -87,7 +87,7 @@ public:
OPL(Config::OplType type);
~OPL();
- bool init(int rate);
+ bool init();
void reset();
void write(int a, int v);
diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp
index da75ba76ba..1a5810f6c8 100644
--- a/audio/softsynth/opl/mame.cpp
+++ b/audio/softsynth/opl/mame.cpp
@@ -31,6 +31,8 @@
#include "mame.h"
+#include "audio/mixer.h"
+#include "common/system.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -50,11 +52,11 @@ OPL::~OPL() {
_opl = 0;
}
-bool OPL::init(int rate) {
+bool OPL::init() {
if (_opl)
MAME::OPLDestroy(_opl);
- _opl = MAME::makeAdLibOPL(rate);
+ _opl = MAME::makeAdLibOPL(g_system->getMixer()->getOutputRate());
return (_opl != 0);
}
diff --git a/audio/softsynth/opl/mame.h b/audio/softsynth/opl/mame.h
index bd479d9e45..080cc6d171 100644
--- a/audio/softsynth/opl/mame.h
+++ b/audio/softsynth/opl/mame.h
@@ -181,7 +181,7 @@ public:
OPL() : _opl(0) {}
~OPL();
- bool init(int rate);
+ bool init();
void reset();
void write(int a, int v);
diff --git a/engines/agos/drivers/accolade/adlib.cpp b/engines/agos/drivers/accolade/adlib.cpp
index 11edc7c5f7..61f209b063 100644
--- a/engines/agos/drivers/accolade/adlib.cpp
+++ b/engines/agos/drivers/accolade/adlib.cpp
@@ -213,8 +213,6 @@ MidiDriver_Accolade_AdLib::~MidiDriver_Accolade_AdLib() {
}
int MidiDriver_Accolade_AdLib::open() {
- int rate = _mixer->getOutputRate();
-
// debugC(kDebugLevelAdLibDriver, "AdLib: starting driver");
_opl = OPL::Config::create(OPL::Config::kOpl2);
@@ -222,7 +220,7 @@ int MidiDriver_Accolade_AdLib::open() {
if (!_opl)
return -1;
- _opl->init(rate);
+ _opl->init();
MidiDriver_Emulated::open();
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 8da6dba532..2ac0f91cac 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -285,7 +285,7 @@ AdLibSoundDriver::AdLibSoundDriver(Audio::Mixer *mixer)
_sampleRate = _mixer->getOutputRate();
_opl = OPL::Config::create();
- if (!_opl || !_opl->init(_sampleRate))
+ if (!_opl || !_opl->init())
error("Failed to create OPL");
memset(_channelsVolumeTable, 0, sizeof(_channelsVolumeTable));
diff --git a/engines/cruise/sound.cpp b/engines/cruise/sound.cpp
index 0bf9bf706e..1f4960465e 100644
--- a/engines/cruise/sound.cpp
+++ b/engines/cruise/sound.cpp
@@ -304,7 +304,7 @@ AdLibSoundDriver::AdLibSoundDriver(Audio::Mixer *mixer)
: _mixer(mixer) {
_sampleRate = _mixer->getOutputRate();
_opl = OPL::Config::create();
- if (!_opl || !_opl->init(_sampleRate))
+ if (!_opl || !_opl->init())
error("Failed to create OPL");
for (int i = 0; i < 5; ++i) {
diff --git a/engines/gob/sound/adlib.cpp b/engines/gob/sound/adlib.cpp
index 65b43cae7a..b92e20b42c 100644
--- a/engines/gob/sound/adlib.cpp
+++ b/engines/gob/sound/adlib.cpp
@@ -136,7 +136,7 @@ void AdLib::createOPL() {
}
_opl = OPL::Config::create(OPL::Config::parse(oplDriver), OPL::Config::kOpl2);
- if (!_opl || !_opl->init(_rate)) {
+ if (!_opl || !_opl->init()) {
delete _opl;
error("Could not create an AdLib emulator");
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));
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index b0a0938958..10cbc73bf2 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -211,7 +211,7 @@ ASound::ASound(Audio::Mixer *mixer, OPL::OPL *opl, const Common::String &filenam
_mixer = mixer;
_opl = opl;
- _opl->init(getRate());
+ _opl->init();
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1,
Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
@@ -861,6 +861,10 @@ int ASound::readBuffer(int16 *buffer, const int numSamples) {
return numSamples;
}
+int ASound::getRate() const {
+ return g_system->getMixer()->getOutputRate();
+}
+
void ASound::setVolume(int volume) {
_masterVolume = volume;
if (!volume)
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index e0956327b4..8c1d7f8021 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -385,7 +385,7 @@ public:
/**
* Return sample rate
*/
- virtual int getRate() const { return 11025; }
+ virtual int getRate() const;
/**
* Set the volume
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 09bc3a3f13..4a35edb80f 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -40,7 +40,7 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
_masterVolume = 255;
_opl = OPL::Config::create();
- _opl->init(11025);
+ _opl->init();
// Validate sound files
switch (_vm->getGameID()) {
diff --git a/engines/parallaction/adlib.cpp b/engines/parallaction/adlib.cpp
index 7c1dd1681f..a2defa932b 100644
--- a/engines/parallaction/adlib.cpp
+++ b/engines/parallaction/adlib.cpp
@@ -351,7 +351,7 @@ int AdLibDriver::open() {
MidiDriver_Emulated::open();
_opl = OPL::Config::create();
- _opl->init(getRate());
+ _opl->init();
_opl->writeReg(0x1, 0x20); // set bit 5 (enable all waveforms)
// Reset the OPL registers.
diff --git a/engines/queen/midiadlib.cpp b/engines/queen/midiadlib.cpp
index 6bf0d59846..369ac99baf 100644
--- a/engines/queen/midiadlib.cpp
+++ b/engines/queen/midiadlib.cpp
@@ -122,7 +122,7 @@ private:
int AdLibMidiDriver::open() {
MidiDriver_Emulated::open();
_opl = OPL::Config::create();
- if (!_opl || !_opl->init(getRate()))
+ if (!_opl || !_opl->init())
error("Failed to create OPL");
adlibSetupCard();
diff --git a/engines/sci/sound/drivers/adlib.cpp b/engines/sci/sound/drivers/adlib.cpp
index fcfda2f532..3c9538170d 100644
--- a/engines/sci/sound/drivers/adlib.cpp
+++ b/engines/sci/sound/drivers/adlib.cpp
@@ -215,8 +215,6 @@ static const int ym3812_note[13] = {
};
int MidiDriver_AdLib::openAdLib(bool isSCI0) {
- int rate = _mixer->getOutputRate();
-
_stereo = STEREO;
debug(3, "ADLIB: Starting driver in %s mode", (isSCI0 ? "SCI0" : "SCI1"));
@@ -233,7 +231,7 @@ int MidiDriver_AdLib::openAdLib(bool isSCI0) {
if (!_opl)
return -1;
- _opl->init(rate);
+ _opl->init();
setRegister(0xBD, 0);
setRegister(0x08, 0);
diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp
index adcda68e10..b22180b47f 100644
--- a/engines/scumm/players/player_ad.cpp
+++ b/engines/scumm/players/player_ad.cpp
@@ -38,7 +38,7 @@ namespace Scumm {
Player_AD::Player_AD(ScummEngine *scumm, Audio::Mixer *mixer)
: _vm(scumm), _mixer(mixer), _rate(mixer->getOutputRate()) {
_opl2 = OPL::Config::create();
- if (!_opl2->init(_rate)) {
+ if (!_opl2->init()) {
error("Could not initialize OPL2 emulator");
}
diff --git a/engines/sherlock/scalpel/drivers/adlib.cpp b/engines/sherlock/scalpel/drivers/adlib.cpp
index 91641fcccd..3c5a6559c4 100644
--- a/engines/sherlock/scalpel/drivers/adlib.cpp
+++ b/engines/sherlock/scalpel/drivers/adlib.cpp
@@ -285,8 +285,6 @@ private:
};
int MidiDriver_SH_AdLib::open() {
- int rate = _mixer->getOutputRate();
-
debugC(kDebugLevelAdLibDriver, "AdLib: starting driver");
_opl = OPL::Config::create(OPL::Config::kOpl2);
@@ -294,7 +292,7 @@ int MidiDriver_SH_AdLib::open() {
if (!_opl)
return -1;
- _opl->init(rate);
+ _opl->init();
MidiDriver_Emulated::open();
diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp
index 2b73cb1411..e410b3fb7b 100644
--- a/engines/sky/music/adlibmusic.cpp
+++ b/engines/sky/music/adlibmusic.cpp
@@ -36,7 +36,7 @@ AdLibMusic::AdLibMusic(Audio::Mixer *pMixer, Disk *pDisk) : MusicBase(pMixer, pD
_sampleRate = pMixer->getOutputRate();
_opl = OPL::Config::create();
- if (!_opl || !_opl->init(_sampleRate))
+ if (!_opl || !_opl->init())
error("Failed to create OPL");
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 455b58d09f..6ff983eef6 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -2746,7 +2746,7 @@ AdlibSoundDriver::AdlibSoundDriver(): SoundDriver() {
_sampleRate = _mixer->getOutputRate();
_opl = OPL::Config::create();
assert(_opl);
- _opl->init(_sampleRate);
+ _opl->init();
_samplesTillCallback = 0;
_samplesTillCallbackRemainder = 0;