diff options
-rw-r--r-- | core/qmpmidioutfluid.cpp | 8 | ||||
-rw-r--r-- | core/qmpmidioutfluid.hpp | 1 | ||||
-rw-r--r-- | core/qmpmidioutrtmidi.cpp | 5 | ||||
-rw-r--r-- | core/qmpmidioutrtmidi.hpp | 1 | ||||
-rw-r--r-- | core/qmpmidiplay.cpp | 16 | ||||
-rw-r--r-- | include/qmpcorepublic.hpp | 1 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmppresetselect.cpp | 28 |
7 files changed, 31 insertions, 29 deletions
diff --git a/core/qmpmidioutfluid.cpp b/core/qmpmidioutfluid.cpp index 2abdc5c..a0586ae 100644 --- a/core/qmpmidioutfluid.cpp +++ b/core/qmpmidioutfluid.cpp @@ -206,6 +206,14 @@ void qmpMidiOutFluid::onMapped(uint8_t, int) void qmpMidiOutFluid::onUnmapped(uint8_t, int) { } + +bool qmpMidiOutFluid::selectPreset(uint8_t ch, uint16_t bank, uint8_t prog) +{ + fluid_synth_set_channel_type(synth, ch, bank == 128 ? CHANNEL_TYPE_DRUM : CHANNEL_TYPE_MELODIC); + fluid_synth_bank_select(synth, ch, bank); + fluid_synth_program_change(synth, ch, prog); + return true; +} std::vector<std::pair<uint16_t, std::string>> qmpMidiOutFluid::getBankList() { return bnk; diff --git a/core/qmpmidioutfluid.hpp b/core/qmpmidioutfluid.hpp index f194c17..8cf6686 100644 --- a/core/qmpmidioutfluid.hpp +++ b/core/qmpmidioutfluid.hpp @@ -46,6 +46,7 @@ public: void reset(uint8_t ch); void onMapped(uint8_t ch, int refcnt); void onUnmapped(uint8_t ch, int refcnt); + bool selectPreset(uint8_t ch, uint16_t bank, uint8_t prog); std::vector<std::pair<uint16_t, std::string>> getBankList(); std::vector<std::pair<uint8_t, std::string>> getPresets(uint16_t bank); std::string getPresetName(uint16_t bank, uint8_t preset); diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index b677c9f..d39b838 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -343,6 +343,11 @@ void qmpMidiOutRtMidi::onUnmapped(uint8_t ch, int refcnt) if (!refcnt && outport) outport->closePort(); } + +bool qmpMidiOutRtMidi::selectPreset(uint8_t ch, uint16_t bank, uint8_t prog) +{ + return false; +} std::vector<std::pair<uint16_t, std::string>> qmpMidiOutRtMidi::getBankList() { if (!devinit) diff --git a/core/qmpmidioutrtmidi.hpp b/core/qmpmidioutrtmidi.hpp index 8276cce..715cb3f 100644 --- a/core/qmpmidioutrtmidi.hpp +++ b/core/qmpmidioutrtmidi.hpp @@ -39,6 +39,7 @@ public: void reset(uint8_t ch); void onMapped(uint8_t ch, int refcnt); void onUnmapped(uint8_t ch, int refcnt); + bool selectPreset(uint8_t ch, uint16_t bank, uint8_t prog); std::vector<std::pair<uint16_t, std::string>> getBankList(); std::vector<std::pair<uint8_t, std::string>> getPresets(uint16_t bank); std::string getPresetName(uint16_t bank, uint8_t preset); diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 2693307..c3c52ca 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -387,8 +387,11 @@ void CMidiPlayer::playerPanic(bool reset) for (auto &i : mididev) if (i.refcnt) { - for (uint8_t j = 0; j < 16; ++j) - reset ? i.dev->reset(j) : i.dev->panic(j); + if (reset) + i.dev->reset(0xff); + else + for (uint8_t j = 0; j < 16; ++j) + i.dev->panic(j); } } bool CMidiPlayer::playerLoadFile(const char *fn) @@ -596,9 +599,12 @@ void CMidiPlayer::setChannelPreset(int ch, int b, int p) chstatus[ch][0] = b >> 7; chstatus[ch][32] = b & 0x7F; qmpMidiOutDevice *d = mididev[mappedoutput[ch]].dev; - d->basicMessage(0xB0 | ch, 0x00, b >> 7); - d->basicMessage(0xB0 | ch, 0x20, b & 0x7F); - d->basicMessage(0xC0 | ch, p, 0); + if (!d->selectPreset(ch, b, p)) + { + d->basicMessage(0xB0 | ch, 0x00, b >> 7); + d->basicMessage(0xB0 | ch, 0x20, b & 0x7F); + d->basicMessage(0xC0 | ch, p, 0); + } } void CMidiPlayer::dumpFile() { diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 3c72ad9..9e3e9e7 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -128,6 +128,7 @@ public: virtual void reset(uint8_t ch) = 0; virtual void onMapped(uint8_t ch, int refcnt) = 0; virtual void onUnmapped(uint8_t ch, int refcnt) = 0; + virtual bool selectPreset(uint8_t ch, uint16_t bank, uint8_t prog) = 0; virtual std::vector<std::pair<uint16_t, std::string>> getBankList() = 0; virtual std::vector<std::pair<uint8_t, std::string>> getPresets(uint16_t bank) = 0; virtual std::string getPresetName(uint16_t bank, uint8_t preset) = 0; diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp index 1eb5282..973cf30 100644 --- a/qmidiplayer-desktop/qmppresetselect.cpp +++ b/qmidiplayer-desktop/qmppresetselect.cpp @@ -82,34 +82,14 @@ void qmpPresetSelector::on_pbCancel_clicked() void qmpPresetSelector::on_pbOk_clicked() { CMidiPlayer *plyr = qmpMainWindow::getInstance()->getPlayer(); - if (plyr->getChannelOutput(ch)) - { - if (ui->spCustomMSB->isEnabled()) - plyr->setChannelPreset(ch, (ui->spCustomMSB->value() << 7) | ui->spCustomLSB->value(), ui->spCustomPC->value()); - else - { - if (!ui->lwBankSelect->currentItem() || !ui->lwPresetSelect->currentItem()) - return (void)close(); - int b = ui->lwBankSelect->currentItem()->text().split(' ').first().toInt(); - int p = ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt(); - plyr->setChannelPreset(ch, b, p); - } - } + if (ui->spCustomMSB->isEnabled()) + plyr->setChannelPreset(ch, (ui->spCustomMSB->value() << 7) | ui->spCustomLSB->value(), ui->spCustomPC->value()); else { if (!ui->lwBankSelect->currentItem() || !ui->lwPresetSelect->currentItem()) return (void)close(); - int b, p; - b = ui->lwBankSelect->currentItem()->text().toInt(); - p = ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt(); - std::string s = qmpMainWindow::getInstance()->getSettings()->getOptionEnumIntOptName("FluidSynth/BankSelect"); - if (s == "XG") - { - if (b == 128) - b = 127 << 7; - } - else if (s == "GS") - b <<= 7; + int b = ui->lwBankSelect->currentItem()->text().split(' ').first().toInt(); + int p = ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt(); plyr->setChannelPreset(ch, b, p); } qmpMainWindow::getInstance()->invokeCallback("preset.set", nullptr); |