aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth
diff options
context:
space:
mode:
authorMatthew Hoops2015-04-03 01:38:14 -0400
committerMatthew Hoops2015-07-07 20:19:42 -0400
commitb9307ef1a4420ef61aa35c747d2f3f11875d3b72 (patch)
tree8f47b4cccb59139a1afecf4451ca4e578993007d /audio/softsynth
parent2e8f9dcec93653f1bd1f115662f9fcf3a5581fd8 (diff)
downloadscummvm-rg350-b9307ef1a4420ef61aa35c747d2f3f11875d3b72.tar.gz
scummvm-rg350-b9307ef1a4420ef61aa35c747d2f3f11875d3b72.tar.bz2
scummvm-rg350-b9307ef1a4420ef61aa35c747d2f3f11875d3b72.zip
AUDIO: Introduce a callback to the OPL code
Currently unused, but ready to be hooked up to various classes using it.
Diffstat (limited to 'audio/softsynth')
-rw-r--r--audio/softsynth/opl/dosbox.cpp6
-rw-r--r--audio/softsynth/opl/dosbox.h6
-rw-r--r--audio/softsynth/opl/mame.cpp11
-rw-r--r--audio/softsynth/opl/mame.h6
4 files changed, 22 insertions, 7 deletions
diff --git a/audio/softsynth/opl/dosbox.cpp b/audio/softsynth/opl/dosbox.cpp
index bcc73a9b9e..f6f17c5e3c 100644
--- a/audio/softsynth/opl/dosbox.cpp
+++ b/audio/softsynth/opl/dosbox.cpp
@@ -153,6 +153,7 @@ OPL::~OPL() {
}
void OPL::free() {
+ stopCallbacks();
delete _emulator;
_emulator = 0;
}
@@ -176,6 +177,9 @@ bool OPL::init() {
_emulator->WriteReg(0x105, 1);
}
+ // FIXME: Remove this once EmulatedOPL is actually controlling playback
+ start(0);
+
return true;
}
@@ -308,7 +312,7 @@ void OPL::dualWrite(uint8 index, uint8 reg, uint8 val) {
_emulator->WriteReg(fullReg, val);
}
-void OPL::readBuffer(int16 *buffer, int length) {
+void OPL::generateSamples(int16 *buffer, int length) {
// For stereo OPL cards, we divide the sample count by 2,
// to match stereo AudioStream behavior.
if (_type != Config::kOpl2)
diff --git a/audio/softsynth/opl/dosbox.h b/audio/softsynth/opl/dosbox.h
index d3df6ba6ed..c52f06761a 100644
--- a/audio/softsynth/opl/dosbox.h
+++ b/audio/softsynth/opl/dosbox.h
@@ -69,7 +69,7 @@ namespace DBOPL {
struct Chip;
} // end of namespace DBOPL
-class OPL : public ::OPL::OPL {
+class OPL : public ::OPL::EmulatedOPL {
private:
Config::OplType _type;
uint _rate;
@@ -95,8 +95,10 @@ public:
void writeReg(int r, int v);
- void readBuffer(int16 *buffer, int length);
bool isStereo() const { return _type != Config::kOpl2; }
+
+protected:
+ void generateSamples(int16 *buffer, int length);
};
} // End of namespace DOSBox
diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp
index 1a5810f6c8..fe23d300fa 100644
--- a/audio/softsynth/opl/mame.cpp
+++ b/audio/softsynth/opl/mame.cpp
@@ -48,15 +48,22 @@ namespace OPL {
namespace MAME {
OPL::~OPL() {
+ stopCallbacks();
MAME::OPLDestroy(_opl);
_opl = 0;
}
bool OPL::init() {
- if (_opl)
+ if (_opl) {
+ stopCallbacks();
MAME::OPLDestroy(_opl);
+ }
_opl = MAME::makeAdLibOPL(g_system->getMixer()->getOutputRate());
+
+ // FIXME: Remove this once EmulatedOPL is actually controlling playback
+ start(0);
+
return (_opl != 0);
}
@@ -76,7 +83,7 @@ void OPL::writeReg(int r, int v) {
MAME::OPLWriteReg(_opl, r, v);
}
-void OPL::readBuffer(int16 *buffer, int length) {
+void OPL::generateSamples(int16 *buffer, int length) {
MAME::YM3812UpdateOne(_opl, buffer, length);
}
diff --git a/audio/softsynth/opl/mame.h b/audio/softsynth/opl/mame.h
index 080cc6d171..67d80bb193 100644
--- a/audio/softsynth/opl/mame.h
+++ b/audio/softsynth/opl/mame.h
@@ -174,7 +174,7 @@ void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length);
FM_OPL *makeAdLibOPL(int rate);
// OPL API implementation
-class OPL : public ::OPL::OPL {
+class OPL : public ::OPL::EmulatedOPL {
private:
FM_OPL *_opl;
public:
@@ -189,8 +189,10 @@ public:
void writeReg(int r, int v);
- void readBuffer(int16 *buffer, int length);
bool isStereo() const { return false; }
+
+protected:
+ void generateSamples(int16 *buffer, int length);
};
} // End of namespace MAME