aboutsummaryrefslogtreecommitdiff
path: root/audio/miles_adlib.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2015-06-28 13:57:07 -0400
committerMatthew Hoops2015-07-07 20:19:45 -0400
commit22d985f3c265162419ab8c65dd47b48ac385f463 (patch)
treed0344340c271cd2794c645fe741873f0919bbcc4 /audio/miles_adlib.cpp
parent0c5d40e94c6f10d63763a72c70d06fe2fa15de29 (diff)
downloadscummvm-rg350-22d985f3c265162419ab8c65dd47b48ac385f463.tar.gz
scummvm-rg350-22d985f3c265162419ab8c65dd47b48ac385f463.tar.bz2
scummvm-rg350-22d985f3c265162419ab8c65dd47b48ac385f463.zip
AUDIO: Use the built-in OPL timer for MidiDriver_Miles_AdLib
Diffstat (limited to 'audio/miles_adlib.cpp')
-rw-r--r--audio/miles_adlib.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/audio/miles_adlib.cpp b/audio/miles_adlib.cpp
index 4560a812e7..7f3f05a769 100644
--- a/audio/miles_adlib.cpp
+++ b/audio/miles_adlib.cpp
@@ -129,6 +129,7 @@ public:
MidiChannel *getPercussionChannel() { return NULL; }
// AudioStream
+ int readBuffer(int16 *data, const int numSamples);
bool isStereo() const { return _modeStereo; }
int getRate() const { return _mixer->getOutputRate(); }
int getPolyphony() const { return _modePhysicalFmVoicesCount; }
@@ -140,6 +141,8 @@ public:
void setVolume(byte volume);
virtual uint32 property(int prop, uint32 param);
+ void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc);
+
private:
bool _modeOPL3;
byte _modePhysicalFmVoicesCount;
@@ -222,6 +225,9 @@ private:
OPL::OPL *_opl;
int _masterVolume;
+ Common::TimerManager::TimerProc _adlibTimerProc;
+ void *_adlibTimerParam;
+
// stores information about all MIDI channels (not the actual OPL FM voice channels!)
MidiChannelEntry _midiChannels[MILES_MIDI_CHANNEL_COUNT];
@@ -238,10 +244,8 @@ private:
bool circularPhysicalAssignment;
byte circularPhysicalAssignmentFmVoice;
-protected:
void onTimer();
-private:
void resetData();
void resetAdLib();
void resetAdLibOperatorRegisters(byte baseRegister, byte value);
@@ -272,7 +276,8 @@ private:
};
MidiDriver_Miles_AdLib::MidiDriver_Miles_AdLib(Audio::Mixer *mixer, InstrumentEntry *instrumentTablePtr, uint16 instrumentTableCount)
- : MidiDriver_Emulated(mixer), _masterVolume(15), _opl(0) {
+ : MidiDriver_Emulated(mixer), _masterVolume(15), _opl(0),
+ _adlibTimerProc(0), _adlibTimerParam(0) {
_instrumentTablePtr = instrumentTablePtr;
_instrumentTableCount = instrumentTableCount;
@@ -321,6 +326,7 @@ int MidiDriver_Miles_AdLib::open() {
MidiDriver_Emulated::open();
+ _opl->start(new Common::Functor0Mem<void, MidiDriver_Miles_AdLib>(this, &MidiDriver_Miles_AdLib::onTimer));
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
resetAdLib();
@@ -340,6 +346,8 @@ void MidiDriver_Miles_AdLib::setVolume(byte volume) {
}
void MidiDriver_Miles_AdLib::onTimer() {
+ if (_adlibTimerProc)
+ (*_adlibTimerProc)(_adlibTimerParam);
}
void MidiDriver_Miles_AdLib::resetData() {
@@ -437,10 +445,16 @@ void MidiDriver_Miles_AdLib::send(uint32 b) {
}
void MidiDriver_Miles_AdLib::generateSamples(int16 *data, int len) {
- if (_modeStereo)
- len *= 2;
+ // Dummy implementation until we no longer inherit from MidiDriver_Emulated
+}
+
+int MidiDriver_Miles_AdLib::readBuffer(int16 *data, const int numSamples) {
+ return _opl->readBuffer(data, numSamples);
+}
- _opl->readBuffer(data, len);
+void MidiDriver_Miles_AdLib::setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc) {
+ _adlibTimerProc = timerProc;
+ _adlibTimerParam = timerParam;
}
int16 MidiDriver_Miles_AdLib::searchFreeVirtualFmVoiceChannel() {