aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/adlmidi.cpp68
-rw-r--r--src/adlmidi_load.cpp28
-rw-r--r--src/adlmidi_midiplay.cpp90
-rw-r--r--src/adlmidi_midiplay.hpp2
-rw-r--r--src/adlmidi_private.cpp10
-rw-r--r--src/adlmidi_private.hpp2
-rw-r--r--src/adlmidi_sequencer.cpp2
7 files changed, 102 insertions, 100 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index cddfca2..541dbb4 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -120,7 +120,7 @@ ADLMIDI_EXPORT int adl_setNumChips(ADL_MIDIPlayer *device, int numChips)
else if(play->m_setup.numFourOps < -1)
play->m_setup.numFourOps = -1;
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
if(!synth.setupLocked())
{
synth.m_numChips = play->m_setup.numChips;
@@ -180,7 +180,7 @@ ADLMIDI_EXPORT int adl_setBank(ADL_MIDIPlayer *device, int bank)
return -1;
}
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.bankId = static_cast<uint32_t>(bankno);
synth.setEmbeddedBank(play->m_setup.bankId);
play->applySetup();
@@ -213,7 +213,7 @@ ADLMIDI_EXPORT int adl_reserveBanks(ADL_MIDIPlayer *device, unsigned banks)
return -1;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3::BankMap &map = play->m_synth->m_insBanks;
+ Synth::BankMap &map = play->m_synth->m_insBanks;
map.reserve(banks);
return (int)map.capacity();
}
@@ -226,13 +226,13 @@ ADLMIDI_EXPORT int adl_getBank(ADL_MIDIPlayer *device, const ADL_BankId *idp, in
ADL_BankId id = *idp;
if(id.lsb > 127 || id.msb > 127 || id.percussive > 1)
return -1;
- size_t idnumber = ((id.msb << 8) | id.lsb | (id.percussive ? size_t(OPL3::PercussionTag) : 0));
+ size_t idnumber = ((id.msb << 8) | id.lsb | (id.percussive ? size_t(Synth::PercussionTag) : 0));
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3::BankMap &map = play->m_synth->m_insBanks;
+ Synth::BankMap &map = play->m_synth->m_insBanks;
- OPL3::BankMap::iterator it;
+ Synth::BankMap::iterator it;
if(!(flags & ADLMIDI_Bank_Create))
{
it = map.find(idnumber);
@@ -241,16 +241,16 @@ ADLMIDI_EXPORT int adl_getBank(ADL_MIDIPlayer *device, const ADL_BankId *idp, in
}
else
{
- std::pair<size_t, OPL3::Bank> value;
+ std::pair<size_t, Synth::Bank> value;
value.first = idnumber;
memset(&value.second, 0, sizeof(value.second));
for (unsigned i = 0; i < 128; ++i)
value.second.ins[i].flags = adlinsdata::Flag_NoSound;
- std::pair<OPL3::BankMap::iterator, bool> ir;
+ std::pair<Synth::BankMap::iterator, bool> ir;
if(flags & ADLMIDI_Bank_CreateRt)
{
- ir = map.insert(value, OPL3::BankMap::do_not_expand_t());
+ ir = map.insert(value, Synth::BankMap::do_not_expand_t());
if(ir.first == map.end())
return -1;
}
@@ -268,11 +268,11 @@ ADLMIDI_EXPORT int adl_getBankId(ADL_MIDIPlayer *device, const ADL_Bank *bank, A
if(!device || !bank)
return -1;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
- OPL3::BankMap::key_type idnumber = it->first;
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap::key_type idnumber = it->first;
id->msb = (idnumber >> 8) & 127;
id->lsb = idnumber & 127;
- id->percussive = (idnumber & OPL3::PercussionTag) ? 1 : 0;
+ id->percussive = (idnumber & Synth::PercussionTag) ? 1 : 0;
return 0;
}
@@ -283,8 +283,8 @@ ADLMIDI_EXPORT int adl_removeBank(ADL_MIDIPlayer *device, ADL_Bank *bank)
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3::BankMap &map = play->m_synth->m_insBanks;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap &map = play->m_synth->m_insBanks;
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
size_t size = map.size();
map.erase(it);
return (map.size() != size) ? 0 : -1;
@@ -297,9 +297,9 @@ ADLMIDI_EXPORT int adl_getFirstBank(ADL_MIDIPlayer *device, ADL_Bank *bank)
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3::BankMap &map = play->m_synth->m_insBanks;
+ Synth::BankMap &map = play->m_synth->m_insBanks;
- OPL3::BankMap::iterator it = map.begin();
+ Synth::BankMap::iterator it = map.begin();
if(it == map.end())
return -1;
@@ -314,9 +314,9 @@ ADLMIDI_EXPORT int adl_getNextBank(ADL_MIDIPlayer *device, ADL_Bank *bank)
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3::BankMap &map = play->m_synth->m_insBanks;
+ Synth::BankMap &map = play->m_synth->m_insBanks;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
if(++it == map.end())
return -1;
@@ -329,7 +329,7 @@ ADLMIDI_EXPORT int adl_getInstrument(ADL_MIDIPlayer *device, const ADL_Bank *ban
if(!device || !bank || index > 127 || !ins)
return -1;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
cvt_FMIns_to_ADLI(*ins, it->second.ins[index]);
ins->version = 0;
return 0;
@@ -343,7 +343,7 @@ ADLMIDI_EXPORT int adl_setInstrument(ADL_MIDIPlayer *device, ADL_Bank *bank, uns
if(ins->version != 0)
return -1;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
cvt_ADLI_to_FMIns(it->second.ins[index], *ins);
return 0;
}
@@ -366,11 +366,11 @@ ADLMIDI_EXPORT int adl_loadEmbeddedBank(struct ADL_MIDIPlayer *device, ADL_Bank
if(num < 0 || num >= maxAdlBanks())
return -1;
- OPL3::BankMap::iterator it = OPL3::BankMap::iterator::from_ptrs(bank->pointer);
+ Synth::BankMap::iterator it = Synth::BankMap::iterator::from_ptrs(bank->pointer);
size_t id = it->first;
for (unsigned i = 0; i < 128; ++i) {
- size_t insno = i + ((id & OPL3::PercussionTag) ? 128 : 0);
+ size_t insno = i + ((id & Synth::PercussionTag) ? 128 : 0);
size_t adlmeta = ::banks[num][insno];
it->second.ins[i] = adlinsdata2::from_adldata(::adlins[adlmeta]);
}
@@ -393,7 +393,7 @@ ADLMIDI_EXPORT int adl_setNumFourOpsChn(ADL_MIDIPlayer *device, int ops4)
return -1;
}
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.numFourOps = ops4;
if(!synth.setupLocked())
{
@@ -431,7 +431,7 @@ ADLMIDI_EXPORT void adl_setPercMode(ADL_MIDIPlayer *device, int percmod)
if(!device) return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.rhythmMode = percmod;
if(!synth.setupLocked())
{
@@ -447,7 +447,7 @@ ADLMIDI_EXPORT void adl_setHVibrato(ADL_MIDIPlayer *device, int hvibro)
if(!device) return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.deepVibratoMode = hvibro;
if(!synth.setupLocked())
{
@@ -471,7 +471,7 @@ ADLMIDI_EXPORT void adl_setHTremolo(ADL_MIDIPlayer *device, int htremo)
if(!device) return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.deepTremoloMode = htremo;
if(!synth.setupLocked())
{
@@ -496,7 +496,7 @@ ADLMIDI_EXPORT void adl_setScaleModulators(ADL_MIDIPlayer *device, int smod)
return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.scaleModulators = smod;
if(!synth.setupLocked())
{
@@ -544,7 +544,7 @@ ADLMIDI_EXPORT void adl_setLogarithmicVolumes(struct ADL_MIDIPlayer *device, int
return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.logarithmicVolumes = (logvol != 0);
if(!synth.setupLocked())
{
@@ -561,12 +561,12 @@ ADLMIDI_EXPORT void adl_setVolumeRangeModel(struct ADL_MIDIPlayer *device, int v
return;
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.volumeScaleModel = volumeModel;
if(!synth.setupLocked())
{
if(play->m_setup.volumeScaleModel == ADLMIDI_VolumeModel_AUTO)//Use bank default volume model
- synth.m_volumeScale = (OPL3::VolumesScale)synth.m_insBankSetup.volumeModel;
+ synth.m_volumeScale = (Synth::VolumesScale)synth.m_insBankSetup.volumeModel;
else
synth.setVolumeScaleModel(static_cast<ADLMIDI_VolumeModels>(volumeModel));
}
@@ -692,7 +692,7 @@ ADLMIDI_EXPORT const char *adl_chipEmulatorName(struct ADL_MIDIPlayer *device)
#ifndef ADLMIDI_HW_OPL
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
if(!synth.m_chips.empty())
return synth.m_chips[0]->emulatorName();
#else
@@ -726,7 +726,7 @@ ADLMIDI_EXPORT int adl_setRunAtPcmRate(ADL_MIDIPlayer *device, int enabled)
{
MidiPlayer *play = GET_MIDI_PLAYER(device);
assert(play);
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
play->m_setup.runAtPcmRate = (enabled != 0);
if(!synth.setupLocked())
play->partialReset();
@@ -1309,7 +1309,7 @@ ADLMIDI_EXPORT int adl_playFormat(ADL_MIDIPlayer *device, int sampleCount,
//fill buffer with zeros
int32_t *out_buf = player->m_outBuf;
std::memset(out_buf, 0, static_cast<size_t>(in_generatedPhys) * sizeof(out_buf[0]));
- OPL3 &synth = *player->m_synth;
+ Synth &synth = *player->m_synth;
unsigned int chips = synth.m_numChips;
if(chips == 1)
{
@@ -1400,7 +1400,7 @@ ADLMIDI_EXPORT int adl_generateFormat(struct ADL_MIDIPlayer *device, int sampleC
//fill buffer with zeros
int32_t *out_buf = player->m_outBuf;
std::memset(out_buf, 0, static_cast<size_t>(in_generatedPhys) * sizeof(out_buf[0]));
- OPL3 &synth = *player->m_synth;
+ Synth &synth = *player->m_synth;
unsigned int chips = synth.m_numChips;
if(chips == 1)
synth.m_chips[0]->generate32(out_buf, (size_t)in_generatedStereo);
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index 534256c..e270f3b 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -108,7 +108,7 @@ bool MIDIplay::LoadBank(FileAndMemReader &fr)
}
}
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
synth.m_insBankSetup.adLibPercussions = false;
synth.m_insBankSetup.scaleModulators = false;
synth.m_insBankSetup.deepTremolo = (wopl->opl_flags & WOPL_FLAG_DEEP_TREMOLO) != 0;
@@ -129,8 +129,8 @@ bool MIDIplay::LoadBank(FileAndMemReader &fr)
{
size_t bankno = (slots_src_ins[ss][i].bank_midi_msb * 256) +
(slots_src_ins[ss][i].bank_midi_lsb) +
- (ss ? size_t(OPL3::PercussionTag) : 0);
- OPL3::Bank &bank = synth.m_insBanks[bankno];
+ (ss ? size_t(Synth::PercussionTag) : 0);
+ Synth::Bank &bank = synth.m_insBanks[bankno];
for(int j = 0; j < 128; j++)
{
adlinsdata2 &ins = bank.ins[j];
@@ -141,7 +141,7 @@ bool MIDIplay::LoadBank(FileAndMemReader &fr)
}
}
- synth.m_embeddedBank = OPL3::CustomBankTag; // Use dynamic banks!
+ synth.m_embeddedBank = Synth::CustomBankTag; // Use dynamic banks!
//Percussion offset is count of instruments multipled to count of melodic banks
applySetup();
@@ -155,8 +155,8 @@ bool MIDIplay::LoadBank(FileAndMemReader &fr)
bool MIDIplay::LoadMIDI_pre()
{
#ifdef DISABLE_EMBEDDED_BANKS
- OPL3 &synth = *m_synth;
- if((synth.m_embeddedBank != OPL3::CustomBankTag) || synth.m_insBanks.empty())
+ Synth &synth = *m_synth;
+ if((synth.m_embeddedBank != Synth::CustomBankTag) || synth.m_insBanks.empty())
{
errorStringOut = "Bank is not set! Please load any instruments bank by using of adl_openBankFile() or adl_openBankData() functions!";
return false;
@@ -171,7 +171,7 @@ bool MIDIplay::LoadMIDI_pre()
bool MIDIplay::LoadMIDI_post()
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
MidiSequencer &seq = *m_sequencer;
MidiSequencer::FileFormat format = seq.getFormat();
if(format == MidiSequencer::Format_CMF)
@@ -187,7 +187,7 @@ bool MIDIplay::LoadMIDI_post()
bank = ((bank & 127) + ((bank >> 7) << 8));
if(bank > 127 + (127 << 8))
break;
- bank += (i % 256 < 128) ? 0 : size_t(OPL3::PercussionTag);
+ bank += (i % 256 < 128) ? 0 : size_t(Synth::PercussionTag);
/*std::printf("Ins %3u: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
i, InsData[0],InsData[1],InsData[2],InsData[3], InsData[4],InsData[5],InsData[6],InsData[7],
@@ -217,11 +217,11 @@ bool MIDIplay::LoadMIDI_post()
adlins.voice2_fine_tune = 0.0;
}
- synth.m_embeddedBank = OPL3::CustomBankTag; // Ignore AdlBank number, use dynamic banks instead
+ synth.m_embeddedBank = Synth::CustomBankTag; // Ignore AdlBank number, use dynamic banks instead
//std::printf("CMF deltas %u ticks %u, basictempo = %u\n", deltas, ticks, basictempo);
synth.m_rhythmMode = true;
- synth.m_musicMode = OPL3::MODE_CMF;
- synth.m_volumeScale = OPL3::VOLUME_NATIVE;
+ synth.m_musicMode = Synth::MODE_CMF;
+ synth.m_volumeScale = Synth::VOLUME_NATIVE;
synth.m_numChips = 1;
synth.m_numFourOps = 0;
@@ -229,8 +229,8 @@ bool MIDIplay::LoadMIDI_post()
else if(format == MidiSequencer::Format_RSXX)
{
//opl.CartoonersVolumes = true;
- synth.m_musicMode = OPL3::MODE_RSXX;
- synth.m_volumeScale = OPL3::VOLUME_NATIVE;
+ synth.m_musicMode = Synth::MODE_RSXX;
+ synth.m_volumeScale = Synth::VOLUME_NATIVE;
synth.m_numChips = 1;
synth.m_numFourOps = 0;
@@ -239,7 +239,7 @@ bool MIDIplay::LoadMIDI_post()
{
//std::fprintf(stderr, "Done reading IMF file\n");
synth.m_numFourOps = 0; //Don't use 4-operator channels for IMF playing!
- synth.m_musicMode = OPL3::MODE_IMF;
+ synth.m_musicMode = Synth::MODE_IMF;
synth.m_numChips = 1;
synth.m_numFourOps = 0;
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 708ee69..1a20e9e 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -158,7 +158,7 @@ MIDIplay::MIDIplay(unsigned long sampleRate):
m_setup.carry = 0.0;
m_setup.tick_skip_samples_delay = 0;
- m_synth.reset(new OPL3);
+ m_synth.reset(new Synth);
#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER
m_sequencer.reset(new MidiSequencer);
@@ -175,16 +175,16 @@ MIDIplay::~MIDIplay()
void MIDIplay::applySetup()
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
- synth.m_musicMode = OPL3::MODE_MIDI;
+ synth.m_musicMode = Synth::MODE_MIDI;
m_setup.tick_skip_samples_delay = 0;
synth.m_runAtPcmRate = m_setup.runAtPcmRate;
#ifndef DISABLE_EMBEDDED_BANKS
- if(synth.m_embeddedBank != OPL3::CustomBankTag)
+ if(synth.m_embeddedBank != Synth::CustomBankTag)
synth.m_insBankSetup = adlbanksetup[m_setup.bankId];
#endif
@@ -207,7 +207,7 @@ void MIDIplay::applySetup()
synth.setVolumeScaleModel(static_cast<ADLMIDI_VolumeModels>(m_setup.volumeScaleModel));
if(m_setup.volumeScaleModel == ADLMIDI_VolumeModel_AUTO)//Use bank default volume model
- synth.m_volumeScale = (OPL3::VolumesScale)synth.m_insBankSetup.volumeModel;
+ synth.m_volumeScale = (Synth::VolumesScale)synth.m_insBankSetup.volumeModel;
synth.m_numChips = m_setup.numChips;
m_cmfPercussionMode = false;
@@ -227,7 +227,7 @@ void MIDIplay::applySetup()
void MIDIplay::partialReset()
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
realTime_panic();
m_setup.tick_skip_samples_delay = 0;
synth.m_runAtPcmRate = m_setup.runAtPcmRate;
@@ -253,7 +253,7 @@ void MIDIplay::resetMIDI()
void MIDIplay::TickIterators(double s)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
for(uint16_t c = 0; c < synth.m_numChannels; ++c)
m_chipChannels[c].addAge(static_cast<int64_t>(s * 1e6));
updateVibrato(s);
@@ -265,12 +265,12 @@ void MIDIplay::TickIterators(double s)
void MIDIplay::realTime_ResetState()
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
for(size_t ch = 0; ch < m_midiChannels.size(); ch++)
{
MIDIchannel &chan = m_midiChannels[ch];
chan.resetAllControllers();
- chan.volume = (synth.m_musicMode == OPL3::MODE_RSXX) ? 127 : 100;
+ chan.volume = (synth.m_musicMode == Synth::MODE_RSXX) ? 127 : 100;
chan.vibpos = 0.0;
chan.lastlrpn = 0;
chan.lastmrpn = 0;
@@ -285,12 +285,12 @@ void MIDIplay::realTime_ResetState()
bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
if(note >= 128)
note = 127;
- if((synth.m_musicMode == OPL3::MODE_RSXX) && (velocity != 0))
+ if((synth.m_musicMode == Synth::MODE_RSXX) && (velocity != 0))
{
// Check if this is just a note after-touch
MIDIchannel::activenoteiterator i = m_midiChannels[channel].activenotes_find(note);
@@ -345,16 +345,16 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
}
if(isPercussion)
- bank += OPL3::PercussionTag;
+ bank += Synth::PercussionTag;
- const adlinsdata2 *ains = &OPL3::m_emptyInstrument;
+ const adlinsdata2 *ains = &Synth::m_emptyInstrument;
//Set bank bank
- const OPL3::Bank *bnk = NULL;
+ const Synth::Bank *bnk = NULL;
bool caughtMissingBank = false;
- if((bank & ~static_cast<uint16_t>(OPL3::PercussionTag)) > 0)
+ if((bank & ~static_cast<uint16_t>(Synth::PercussionTag)) > 0)
{
- OPL3::BankMap::iterator b = synth.m_insBanks.find(bank);
+ Synth::BankMap::iterator b = synth.m_insBanks.find(bank);
if(b != synth.m_insBanks.end())
bnk = &b->second;
if(bnk)
@@ -369,7 +369,7 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
size_t fallback = bank & ~(size_t)0x7F;
if(fallback != bank)
{
- OPL3::BankMap::iterator b = synth.m_insBanks.find(fallback);
+ Synth::BankMap::iterator b = synth.m_insBanks.find(fallback);
caughtMissingBank = false;
if(b != synth.m_insBanks.end())
bnk = &b->second;
@@ -390,14 +390,14 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
{
hooks.onDebugMessage(hooks.onDebugMessage_userData,
"[%i] Playing missing %s MIDI bank %i (patch %i)",
- channel, text, (bank & ~static_cast<uint16_t>(OPL3::PercussionTag)), midiins);
+ channel, text, (bank & ~static_cast<uint16_t>(Synth::PercussionTag)), midiins);
}
}
//Or fall back to first bank
if((ains->flags & adlinsdata::Flag_NoSound) != 0)
{
- OPL3::BankMap::iterator b = synth.m_insBanks.find(bank & OPL3::PercussionTag);
+ Synth::BankMap::iterator b = synth.m_insBanks.find(bank & Synth::PercussionTag);
if(b != synth.m_insBanks.end())
bnk = &b->second;
if(bnk)
@@ -519,7 +519,7 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
if(ccount == 0)
{
// Only use four-op master channels
- if(synth.m_channelCategory[a] != OPL3::ChanCat_4op_Master)
+ if(synth.m_channelCategory[a] != Synth::ChanCat_4op_Master)
continue;
}
else
@@ -654,7 +654,7 @@ void MIDIplay::realTime_ChannelAfterTouch(uint8_t channel, uint8_t atVal)
void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
if(static_cast<size_t>(channel) > m_midiChannels.size())
channel = channel % 16;
switch(type)
@@ -791,7 +791,7 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value)
break;
case 103:
- if(synth.m_musicMode == OPL3::MODE_CMF)
+ if(synth.m_musicMode == Synth::MODE_CMF)
m_cmfPercussionMode = (value != 0);
break; // CMF (ctrl 0x67) rhythm mode
@@ -1087,7 +1087,7 @@ size_t MIDIplay::realTime_currentDevice(size_t track)
void MIDIplay::realTime_rawOPL(uint8_t reg, uint8_t value)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
if((reg & 0xF0) == 0xC0)
value |= 0x30;
//std::printf("OPL poke %02X, %02X\n", reg, value);
@@ -1119,7 +1119,7 @@ void MIDIplay::noteUpdate(size_t midCh,
unsigned props_mask,
int32_t select_adlchn)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
MIDIchannel::NoteInfo &info = *i;
const int16_t noteTone = info.noteTone;
const double currentTone = info.currentTone;
@@ -1231,7 +1231,7 @@ void MIDIplay::noteUpdate(size_t midCh,
switch(synth.m_volumeScale)
{
default:
- case OPL3::VOLUME_Generic:
+ case Synth::VOLUME_Generic:
{
volume = vol * m_masterVolume * m_midiChannels[midCh].volume * m_midiChannels[midCh].expression;
@@ -1251,7 +1251,7 @@ void MIDIplay::noteUpdate(size_t midCh,
}
break;
- case OPL3::VOLUME_NATIVE:
+ case Synth::VOLUME_NATIVE:
{
volume = vol * m_midiChannels[midCh].volume * m_midiChannels[midCh].expression;
// volume = volume * m_masterVolume / (127 * 127 * 127) / 2;
@@ -1259,7 +1259,7 @@ void MIDIplay::noteUpdate(size_t midCh,
}
break;
- case OPL3::VOLUME_DMX:
+ case Synth::VOLUME_DMX:
{
volume = 2 * (m_midiChannels[midCh].volume * m_midiChannels[midCh].expression * m_masterVolume / 16129) + 1;
//volume = 2 * (Ch[MidCh].volume) + 1;
@@ -1267,7 +1267,7 @@ void MIDIplay::noteUpdate(size_t midCh,
}
break;
- case OPL3::VOLUME_APOGEE:
+ case Synth::VOLUME_APOGEE:
{
volume = (m_midiChannels[midCh].volume * m_midiChannels[midCh].expression * m_masterVolume / 16129);
volume = ((64 * (vol + 0x80)) * volume) >> 15;
@@ -1275,7 +1275,7 @@ void MIDIplay::noteUpdate(size_t midCh,
}
break;
- case OPL3::VOLUME_9X:
+ case Synth::VOLUME_9X:
{
//volume = 63 - W9X_volume_mapping_table[(((vol * Ch[MidCh].volume /** Ch[MidCh].expression*/) * m_masterVolume / 16129 /*2048383*/) >> 2)];
volume = 63 - W9X_volume_mapping_table[((vol * m_midiChannels[midCh].volume * m_midiChannels[midCh].expression * m_masterVolume / 2048383) >> 2)];
@@ -1360,7 +1360,7 @@ void MIDIplay::setErrorString(const std::string &err)
int64_t MIDIplay::calculateChipChannelGoodness(size_t c, const MIDIchannel::NoteInfo::Phys &ins) const
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
const AdlChannel &chan = m_chipChannels[c];
int64_t koff_ms = chan.koff_time_until_neglible_us / 1000;
int64_t s = -koff_ms;
@@ -1371,7 +1371,7 @@ int64_t MIDIplay::calculateChipChannelGoodness(size_t c, const MIDIchannel::Note
s -= 40000;
// If it's same instrument, better chance to get it when no free channels
if(chan.recent_ins == ins)
- s = (synth.m_musicMode == OPL3::MODE_CMF) ? 0 : -koff_ms;
+ s = (synth.m_musicMode == Synth::MODE_CMF) ? 0 : -koff_ms;
return s;
}
@@ -1443,7 +1443,7 @@ void MIDIplay::prepareChipChannelForNewNote(size_t c, const MIDIchannel::NoteInf
{
if(m_chipChannels[c].users_empty()) return; // Nothing to do
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
//bool doing_arpeggio = false;
for(AdlChannel::LocationData *jnext = m_chipChannels[c].users_first; jnext;)
@@ -1488,7 +1488,7 @@ void MIDIplay::killOrEvacuate(size_t from_channel,
AdlChannel::LocationData *j,
MIDIplay::MIDIchannel::activenoteiterator i)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
uint32_t maxChannels = ADL_MAX_CHIPS * 18;
// Before killing the note, check if it can be
@@ -1564,7 +1564,7 @@ void MIDIplay::panic()
void MIDIplay::killSustainingNotes(int32_t midCh, int32_t this_adlchn, uint32_t sustain_type)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
uint32_t first = 0, last = synth.m_numChannels;
if(this_adlchn >= 0)
@@ -1603,7 +1603,7 @@ void MIDIplay::killSustainingNotes(int32_t midCh, int32_t this_adlchn, uint32_t
void MIDIplay::markSostenutoNotes(int32_t midCh)
{
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
uint32_t first = 0, last = synth.m_numChannels;
for(uint32_t c = first; c < last; ++c)
{
@@ -1713,7 +1713,7 @@ void MIDIplay::updateArpeggio(double) // amount = amount of time passed
// If there is an adlib channel that has multiple notes
// simulated on the same channel, arpeggio them.
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
#if 0
const unsigned desired_arpeggio_rate = 40; // Hz (upper limit)
@@ -1819,7 +1819,7 @@ void MIDIplay::describeChannels(char *str, char *attr, size_t size)
if (!str || size <= 0)
return;
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
uint32_t numChannels = synth.m_numChannels;
uint32_t index = 0;
@@ -1840,11 +1840,11 @@ void MIDIplay::describeChannels(char *str, char *attr, size_t size)
{
switch(synth.m_channelCategory[index])
{
- case OPL3::ChanCat_Regular:
+ case Synth::ChanCat_Regular:
str[index] = '+';
break;
- case OPL3::ChanCat_4op_Master:
- case OPL3::ChanCat_4op_Slave:
+ case Synth::ChanCat_4op_Master:
+ case Synth::ChanCat_4op_Slave:
str[index] = '#';
break;
default: // rhythm-mode percussion
@@ -1872,7 +1872,7 @@ struct AdlInstrumentTester::Impl
uint32_t cur_gm;
uint32_t ins_idx;
std::vector<uint32_t> adl_ins_list;
- OPL3 *opl;
+ Synth *opl;
MIDIplay *play;
};
@@ -1914,8 +1914,8 @@ ADLMIDI_EXPORT void AdlInstrumentTester::FindAdlList()
ADLMIDI_EXPORT void AdlInstrumentTester::Touch(unsigned c, unsigned volume) // Volume maxes at 127*127*127
{
#ifndef DISABLE_EMBEDDED_BANKS
- OPL3 *opl = P->opl;
- if(opl->m_volumeScale == OPL3::VOLUME_NATIVE)
+ Synth *opl = P->opl;
+ if(opl->m_volumeScale == Synth::VOLUME_NATIVE)
opl->touchNote(c, static_cast<uint8_t>(volume * 127 / (127 * 127 * 127) / 2));
else
{
@@ -1934,7 +1934,7 @@ ADLMIDI_EXPORT void AdlInstrumentTester::DoNote(int note)
{
#ifndef DISABLE_EMBEDDED_BANKS
MIDIplay *play = P->play;
- OPL3 *opl = P->opl;
+ Synth *opl = P->opl;
if(P->adl_ins_list.empty()) FindAdlList();
const unsigned meta = P->adl_ins_list[P->ins_idx];
const adlinsdata2 ains = adlinsdata2::from_adldata(::adlins[meta]);
@@ -2000,7 +2000,7 @@ ADLMIDI_EXPORT void AdlInstrumentTester::NextGM(int offset)
ADLMIDI_EXPORT void AdlInstrumentTester::NextAdl(int offset)
{
#ifndef DISABLE_EMBEDDED_BANKS
- //OPL3 *opl = P->opl;
+ //Synth *opl = P->opl;
if(P->adl_ins_list.empty()) FindAdlList();
const unsigned NumBanks = (unsigned)adl_getBanksCount();
P->ins_idx = (uint32_t)((int32_t)P->ins_idx + (int32_t)P->adl_ins_list.size() + offset) % (int32_t)P->adl_ins_list.size();
diff --git a/src/adlmidi_midiplay.hpp b/src/adlmidi_midiplay.hpp
index 5df639b..02a45a9 100644
--- a/src/adlmidi_midiplay.hpp
+++ b/src/adlmidi_midiplay.hpp
@@ -607,7 +607,7 @@ public:
void setErrorString(const std::string &err);
//! OPL3 Chip manager
- AdlMIDI_UPtr<OPL3> m_synth;
+ AdlMIDI_UPtr<Synth> m_synth;
//! Generator output buffer
int32_t m_outBuf[1024];
diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp
index 8c9e769..b2c9b8d 100644
--- a/src/adlmidi_private.cpp
+++ b/src/adlmidi_private.cpp
@@ -38,21 +38,21 @@ void adl_audioTickHandler(void *instance, uint32_t chipId, uint32_t rate)
int adlCalculateFourOpChannels(MIDIplay *play, bool silent)
{
- OPL3 &synth = *play->m_synth;
+ Synth &synth = *play->m_synth;
size_t n_fourop[2] = {0, 0}, n_total[2] = {0, 0};
//Automatically calculate how much 4-operator channels is necessary
#ifndef DISABLE_EMBEDDED_BANKS
- if(synth.m_embeddedBank == OPL3::CustomBankTag)
+ if(synth.m_embeddedBank == Synth::CustomBankTag)
#endif
{
//For custom bank
- OPL3::BankMap::iterator it = synth.m_insBanks.begin();
- OPL3::BankMap::iterator end = synth.m_insBanks.end();
+ Synth::BankMap::iterator it = synth.m_insBanks.begin();
+ Synth::BankMap::iterator end = synth.m_insBanks.end();
for(; it != end; ++it)
{
size_t bank = it->first;
- size_t div = (bank & OPL3::PercussionTag) ? 1 : 0;
+ size_t div = (bank & Synth::PercussionTag) ? 1 : 0;
for(size_t i = 0; i < 128; ++i)
{
adlinsdata2 &ins = it->second.ins[i];
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index d16c8f6..62b6223 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -142,6 +142,8 @@ typedef struct BW_MidiRtInterface BW_MidiRtInterface;
class OPL3;
class OPLChipBase;
+typedef class OPL3 Synth;
+
#include "adldata.hh"
#define ADLMIDI_BUILD
diff --git a/src/adlmidi_sequencer.cpp b/src/adlmidi_sequencer.cpp
index bb9cec0..a1fe5ab 100644
--- a/src/adlmidi_sequencer.cpp
+++ b/src/adlmidi_sequencer.cpp
@@ -141,7 +141,7 @@ double MIDIplay::Tick(double s, double granularity)
MidiSequencer &seqr = *m_sequencer;
double ret = seqr.Tick(s, granularity);
- OPL3 &synth = *m_synth;
+ Synth &synth = *m_synth;
s *= seqr.getTempoMultiplier();
for(uint16_t c = 0; c < synth.m_numChannels; ++c)
m_chipChannels[c].addAge(static_cast<int64_t>(s * 1e6));