aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2018-07-03 18:50:49 +0200
committerJP Cimalando <jpcima@users.noreply.github.com>2018-07-03 19:49:00 +0200
commiteecf8221aeac7097b971d585140850d45271e7a0 (patch)
treef34817c9d2878a89880d376a2ee5e68fae0cb7a5 /src
parent96960d1dd9ff21adfc4e5171f4a6ef4f2a3e57a6 (diff)
downloadlibADLMIDI-eecf8221aeac7097b971d585140850d45271e7a0.tar.gz
libADLMIDI-eecf8221aeac7097b971d585140850d45271e7a0.tar.bz2
libADLMIDI-eecf8221aeac7097b971d585140850d45271e7a0.zip
embedded bank loading API into multi-bank
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 32872ef..6252df3 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -123,8 +123,8 @@ ADLMIDI_EXPORT int adl_setBank(ADL_MIDIPlayer *device, int bank)
ADL_UNUSED(bank);
MidiPlayer *play = GET_MIDI_PLAYER(device);
play->setErrorString("This build of libADLMIDI has no embedded banks. "
- "Please load bank by using of adl_openBankFile() or "
- "adl_openBankData() functions instead of adl_setBank()");
+ "Please load banks by using adl_openBankFile() or "
+ "adl_openBankData() functions instead of adl_setBank().");
return -1;
#else
const uint32_t NumBanks = static_cast<uint32_t>(maxAdlBanks());
@@ -304,6 +304,37 @@ ADLMIDI_EXPORT int adl_setInstrument(ADL_MIDIPlayer *device, ADL_Bank *bank, uns
return 0;
}
+ADLMIDI_EXPORT int adl_loadEmbeddedBank(struct ADL_MIDIPlayer *device, ADL_Bank *bank, int num)
+{
+ if(!device)
+ return -1;
+ MidiPlayer *play = GET_MIDI_PLAYER(device);
+ if (!play)
+ return -1;
+
+#ifdef DISABLE_EMBEDDED_BANKS
+ ADL_UNUSED(bank);
+ ADL_UNUSED(num);
+ play->setErrorString("This build of libADLMIDI has no embedded banks. "
+ "Please load banks by using adl_openBankFile() or "
+ "adl_openBankData() functions instead of adl_loadEmbeddedBank().");
+ return -1;
+#else
+ if(num < 0 || num >= maxAdlBanks())
+ return -1;
+
+ OPL3::BankMap::iterator it = OPL3::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 adlmeta = ::banks[num][insno];
+ it->second.ins[i] = adlinsdata2(::adlins[adlmeta]);
+ }
+ return 0;
+#endif
+}
+
ADLMIDI_EXPORT int adl_setNumFourOpsChn(ADL_MIDIPlayer *device, int ops4)
{
if(!device)