22 #ifndef AUDIO_SOFTSYNTH_EMUMIDI_H 23 #define AUDIO_SOFTSYNTH_EMUMIDI_H 25 #include "audio/audiostream.h" 26 #include "audio/mididrv.h" 27 #include "audio/mixer.h" 49 virtual void generateSamples(int16 *buf,
int len) = 0;
50 virtual void onTimer() {}
73 _samplesPerTick = (d << FIXP_SHIFT) + (r << FIXP_SHIFT) / _baseFreq;
78 bool isOpen()
const {
return _isOpen; }
81 _timerProc = timer_proc;
82 _timerParam = timer_param;
86 return 1000000 / _baseFreq;
90 virtual int readBuffer(int16 *data,
const int numSamples) {
91 const int stereoFactor =
isStereo() ? 2 : 1;
92 int len = numSamples / stereoFactor;
97 if (step > (_nextTick >> FIXP_SHIFT))
98 step = (_nextTick >> FIXP_SHIFT);
100 generateSamples(data, step);
102 _nextTick -= step << FIXP_SHIFT;
103 if (!(_nextTick >> FIXP_SHIFT)) {
105 (*_timerProc)(_timerParam);
109 _nextTick += _samplesPerTick;
112 data += step * stereoFactor;
virtual int readBuffer(int16 *data, const int numSamples)
Definition: emumidi.h:90
virtual int getRate() const =0
virtual uint32 getBaseTempo()
Definition: emumidi.h:85
void(* TimerProc)(void *refCon)
Definition: timer.h:42
virtual bool isStereo() const =0
Definition: mididrv.h:309
virtual bool endOfData() const
Definition: emumidi.h:119
virtual int open()
Definition: emumidi.h:64
Definition: audiostream.h:50
bool isOpen() const
Definition: emumidi.h:78