aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth/emumidi.h
diff options
context:
space:
mode:
authordhewg2011-03-21 22:50:21 +0100
committerdhewg2011-03-22 21:02:08 +0100
commitbb12acfa0ffc0c1fe0a907e6b63c3dd0c2acaec5 (patch)
tree2be8978e43edfdcf4ba8b88a11094c6ea655f7af /audio/softsynth/emumidi.h
parent2053936959f6d079c927866da8936cf5dcc7edde (diff)
downloadscummvm-rg350-bb12acfa0ffc0c1fe0a907e6b63c3dd0c2acaec5.tar.gz
scummvm-rg350-bb12acfa0ffc0c1fe0a907e6b63c3dd0c2acaec5.tar.bz2
scummvm-rg350-bb12acfa0ffc0c1fe0a907e6b63c3dd0c2acaec5.zip
AUDIO: Cleanup
Is it just me or is overwriting-but-not-marking-as-virtual irritating?
Diffstat (limited to 'audio/softsynth/emumidi.h')
-rw-r--r--audio/softsynth/emumidi.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/audio/softsynth/emumidi.h b/audio/softsynth/emumidi.h
index 35c81490e4..815c020982 100644
--- a/audio/softsynth/emumidi.h
+++ b/audio/softsynth/emumidi.h
@@ -45,25 +45,24 @@ private:
int _samplesPerTick;
protected:
+ int _baseFreq;
+
virtual void generateSamples(int16 *buf, int len) = 0;
virtual void onTimer() {}
- int _baseFreq;
-
public:
- MidiDriver_Emulated(Audio::Mixer *mixer) : _mixer(mixer) {
- _isOpen = false;
-
- _timerProc = 0;
- _timerParam = 0;
-
- _nextTick = 0;
- _samplesPerTick = 0;
-
- _baseFreq = 250;
+ MidiDriver_Emulated(Audio::Mixer *mixer) :
+ _mixer(mixer),
+ _isOpen(false),
+ _timerProc(0),
+ _timerParam(0),
+ _nextTick(0),
+ _samplesPerTick(0),
+ _baseFreq(250) {
}
- int open() {
+ // MidiDriver API
+ virtual int open() {
_isOpen = true;
int d = getRate() / _baseFreq;
@@ -73,19 +72,21 @@ public:
// but less prone to arithmetic overflow.
_samplesPerTick = (d << FIXP_SHIFT) + (r << FIXP_SHIFT) / _baseFreq;
+
return 0;
}
- void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
+ virtual void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
_timerProc = timer_proc;
_timerParam = timer_param;
}
- uint32 getBaseTempo() { return 1000000 / _baseFreq; }
-
+ virtual uint32 getBaseTempo() {
+ return 1000000 / _baseFreq;
+ }
// AudioStream API
- int readBuffer(int16 *data, const int numSamples) {
+ virtual int readBuffer(int16 *data, const int numSamples) {
const int stereoFactor = isStereo() ? 2 : 1;
int len = numSamples / stereoFactor;
int step;
@@ -101,16 +102,22 @@ public:
if (!(_nextTick >> FIXP_SHIFT)) {
if (_timerProc)
(*_timerProc)(_timerParam);
+
onTimer();
+
_nextTick += _samplesPerTick;
}
+
data += step * stereoFactor;
len -= step;
} while (len);
return numSamples;
}
- bool endOfData() const { return false; }
+
+ virtual bool endOfData() const {
+ return false;
+ }
};
#endif