From b68a212e2d1a400145cc8010f74c0b15fe2ce284 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Tue, 3 Jan 2012 20:16:20 +0000 Subject: reverted commit #1350 ("removed silly song-type-depencency...") i still think it's silly, but there needs to be a proper solution... --- muse2/muse/instruments/minstrument.cpp | 53 ++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp index bd4b3bd4..1349c9c9 100644 --- a/muse2/muse/instruments/minstrument.cpp +++ b/muse2/muse/instruments/minstrument.cpp @@ -49,6 +49,8 @@ namespace MusECore { MidiInstrumentList midiInstruments; MidiInstrument* genericMidiInstrument; +static const char* gmdrumname = "GM-drums"; + //--------------------------------------------------------- // string2sysex //--------------------------------------------------------- @@ -1075,6 +1077,8 @@ QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool dru tmask = 4; break; case MT_GM: + if(drumchan) + return gmdrumname; tmask = 1; break; default: @@ -1086,8 +1090,10 @@ QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool dru const PatchList& pl = (*i)->patches; for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) { const Patch* mp = *ipl; - if ( (pr == mp->prog) - && (mp->drum == drum) + if ((mp->typ & tmask) + && (pr == mp->prog) + && ((drum && mode != MT_GM) || + (mp->drum == drumchan)) && (hbank == mp->hbank || !hb || mp->hbank == -1) && (lbank == mp->lbank || !lb || mp->lbank == -1)) @@ -1101,35 +1107,49 @@ QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool dru // populatePatchPopup //--------------------------------------------------------- -void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int, MType, bool drum) +void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int chan, MType songType, bool drum) { menu->clear(); - + int mask = 0; + bool drumchan = chan == 9; + switch (songType) { + case MT_XG: mask = 4; break; + case MT_GS: mask = 2; break; + case MT_GM: + if(drumchan) + { + int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch + QAction* act = menu->addAction(gmdrumname); + //act->setCheckable(true); + act->setData(id); + return; + } + mask = 1; + break; + case MT_UNKNOWN: mask = 7; break; + } if (pg.size() > 1) { for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) { PatchGroup* pgp = *i; + //QMenu* pm = menu->addMenu(pgp->name); MusEGui::PopupMenu* pm = new MusEGui::PopupMenu(pgp->name, menu, menu->stayOpen()); // Use the parent stayOpen here. + menu->addMenu(pm); + pm->setFont(MusEGlobal::config.fonts[0]); const PatchList& pl = pgp->patches; - bool added=false; for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) { const Patch* mp = *ipl; - if (mp->drum == drum) + if ((mp->typ & mask) && + ((drum && songType != MT_GM) || + (mp->drum == drumchan)) ) { int id = ((mp->hbank & 0xff) << 16) + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff); QAction* act = pm->addAction(mp->name); + //act->setCheckable(true); act->setData(id); - added=true; } + } - if (added) - { - menu->addMenu(pm); - pm->setFont(MusEGlobal::config.fonts[0]); - } - else - delete pm; - } } else if (pg.size() == 1 ){ @@ -1137,10 +1157,11 @@ void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int, MType, bo const PatchList& pl = pg.front()->patches; for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) { const Patch* mp = *ipl; - if (mp->drum == drum) { + if (mp->typ & mask) { int id = ((mp->hbank & 0xff) << 16) + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff); QAction* act = menu->addAction(mp->name); + //act->setCheckable(true); act->setData(id); } } -- cgit v1.2.3