AUDIO: Add AdLib MS driver callback frequency
This change allows a consumer to specify the desired timer callback frequency for the AdLib multisource MIDI driver.
This commit is contained in:
parent
5e95bdcbda
commit
b2cf9a580b
2 changed files with 11 additions and 6 deletions
|
@ -394,7 +394,7 @@ bool MidiDriver_ADLIB_Multisource::detectOplType(OPL::Config::OplType oplType) {
|
||||||
return OPL::Config::detect(oplType) >= 0;
|
return OPL::Config::detect(oplType) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MidiDriver_ADLIB_Multisource::MidiDriver_ADLIB_Multisource(OPL::Config::OplType oplType) :
|
MidiDriver_ADLIB_Multisource::MidiDriver_ADLIB_Multisource(OPL::Config::OplType oplType, int timerFrequency) :
|
||||||
_oplType(oplType),
|
_oplType(oplType),
|
||||||
_opl(nullptr),
|
_opl(nullptr),
|
||||||
_isOpen(false),
|
_isOpen(false),
|
||||||
|
@ -413,9 +413,11 @@ MidiDriver_ADLIB_Multisource::MidiDriver_ADLIB_Multisource(OPL::Config::OplType
|
||||||
_melodicChannels(nullptr),
|
_melodicChannels(nullptr),
|
||||||
_numMelodicChannels(0),
|
_numMelodicChannels(0),
|
||||||
_noteCounter(1),
|
_noteCounter(1),
|
||||||
_oplFrequencyConversionFactor(pow(2, 20) / 49716.0f) {
|
_oplFrequencyConversionFactor(pow(2, 20) / 49716.0f),
|
||||||
|
_timerFrequency(timerFrequency) {
|
||||||
memset(_channelAllocations, 0xFF, sizeof(_channelAllocations));
|
memset(_channelAllocations, 0xFF, sizeof(_channelAllocations));
|
||||||
Common::fill(_shadowRegisters, _shadowRegisters + sizeof(_shadowRegisters), 0);
|
Common::fill(_shadowRegisters, _shadowRegisters + sizeof(_shadowRegisters), 0);
|
||||||
|
_timerRate = 1000000 / _timerFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
MidiDriver_ADLIB_Multisource::~MidiDriver_ADLIB_Multisource() {
|
MidiDriver_ADLIB_Multisource::~MidiDriver_ADLIB_Multisource() {
|
||||||
|
@ -463,10 +465,9 @@ int MidiDriver_ADLIB_Multisource::open() {
|
||||||
// Set default OPL register values.
|
// Set default OPL register values.
|
||||||
initOpl();
|
initOpl();
|
||||||
|
|
||||||
_timerRate = getBaseTempo();
|
|
||||||
// Start the emulator / hardware interface. This will also start the timer
|
// Start the emulator / hardware interface. This will also start the timer
|
||||||
// callbacks.
|
// callbacks.
|
||||||
_opl->start(new Common::Functor0Mem<void, MidiDriver_ADLIB_Multisource>(this, &MidiDriver_ADLIB_Multisource::onTimer));
|
_opl->start(new Common::Functor0Mem<void, MidiDriver_ADLIB_Multisource>(this, &MidiDriver_ADLIB_Multisource::onTimer), _timerFrequency);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -533,7 +534,7 @@ uint32 MidiDriver_ADLIB_Multisource::property(int prop, uint32 param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 MidiDriver_ADLIB_Multisource::getBaseTempo() {
|
uint32 MidiDriver_ADLIB_Multisource::getBaseTempo() {
|
||||||
return 1000000 / OPL::OPL::kDefaultCallbackFrequency;
|
return _timerRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
MidiChannel *MidiDriver_ADLIB_Multisource::allocateChannel() {
|
MidiChannel *MidiDriver_ADLIB_Multisource::allocateChannel() {
|
||||||
|
|
|
@ -589,8 +589,10 @@ public:
|
||||||
* of OPL chip.
|
* of OPL chip.
|
||||||
*
|
*
|
||||||
* @param oplType The type of OPL chip that should be used.
|
* @param oplType The type of OPL chip that should be used.
|
||||||
|
* @param timerFrequency The number of timer callbacks per second that
|
||||||
|
* should be generated.
|
||||||
*/
|
*/
|
||||||
MidiDriver_ADLIB_Multisource(OPL::Config::OplType oplType);
|
MidiDriver_ADLIB_Multisource(OPL::Config::OplType oplType, int timerFrequency = OPL::OPL::kDefaultCallbackFrequency);
|
||||||
~MidiDriver_ADLIB_Multisource();
|
~MidiDriver_ADLIB_Multisource();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1118,6 +1120,8 @@ protected:
|
||||||
|
|
||||||
// True if the driver has been successfully opened.
|
// True if the driver has been successfully opened.
|
||||||
bool _isOpen;
|
bool _isOpen;
|
||||||
|
// The number of timer callbacks per second.
|
||||||
|
int _timerFrequency;
|
||||||
// Controls the behavior for calculating note frequency and volume.
|
// Controls the behavior for calculating note frequency and volume.
|
||||||
AccuracyMode _accuracyMode;
|
AccuracyMode _accuracyMode;
|
||||||
// Controls the OPL channel allocation behavior.
|
// Controls the OPL channel allocation behavior.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue