Skip to content
Permalink
Browse files

follow up pr #4535: display patches in mixer in order of preset numbe…

…r rather than bank
  • Loading branch information...
jthistle committed Jan 25, 2019
1 parent d04aedc commit 6521082292e2662d4f22a10de1b22ff7842f971a
Showing with 34 additions and 20 deletions.
  1. +1 −1 aeolus/aeolus.cpp
  2. +4 −9 fluid/fluid.cpp
  3. +27 −8 mscore/mixerdetails.cpp
  4. +1 −1 synthesizer/midipatch.h
  5. +1 −1 zerberus/zerberus.cpp
@@ -55,7 +55,7 @@ Synthesizer* createAeolus()
Aeolus::Aeolus()
{
model = 0;
patchList.append(new MidiPatch { false, "Aeolus", 0, 0, "Aeolus" });
patchList.append(new MidiPatch { false, "Aeolus", 0, 0, 0, "Aeolus" });

_sc_cmode = 0;
_sc_group = 0;
@@ -571,9 +571,8 @@ void Fluid::updatePatchList()
qDeleteAll(patches);
patches.clear();

QMap<int, QList<MidiPatch*>> patchNums;

int bankOffset = 0;
int sfid = 0;
for (SFont* sf : sfonts) {
sf->setBankOffset(bankOffset);
int banks = 0;
@@ -586,17 +585,13 @@ void Fluid::updatePatchList()
patch->bank = p->get_banknum() + bankOffset;
patch->prog = p->get_num();
patch->name = p->get_name();
patchNums[patch->prog].append(patch);
patch->sfid = sfid;
patches.append(patch);
}
sfid++;
bankOffset += (banks + 1);
}

// Order by patch number first instead of by bank first
for (QList<MidiPatch*> num : patchNums) {
for (MidiPatch* p : num)
patches.append(p);
}

/* try to set the correct presets */
int n = channel.size();
for (int i = 0; i < n; i++)
@@ -166,20 +166,39 @@ void MixerDetails::updateFromTrack()
drumkitCheck->setChecked(drum);
drumkitCheck->blockSignals(false);


//Populate patch combo
patchCombo->blockSignals(true);
patchCombo->clear();
const auto& pl = synti->getPatchInfo();
int patchIndex = 0;

for (const MidiPatch* p : pl) {
if (p->drum == drum || p->synti != "Fluid") {
patchCombo->addItem(p->name, QVariant::fromValue<void*>((void*)p));
if (p->synti == chan->synti() &&
p->bank == chan->bank() &&
p->prog == chan->program())
patchIndex = patchCombo->count() - 1;
// Order by program number instead of bank, so similar instruments
// appear next to each other, but ordered primarily by soundfont
std::map<int, std::map<int, std::vector<const MidiPatch*>>> orderedPl;

for (const MidiPatch* p : pl)
orderedPl[p->sfid][p->prog].push_back(p);

std::vector<QString> usedNames;
for (auto const& sf : orderedPl) {
for (auto const& pn : sf.second) {
for (const MidiPatch* p : pn.second) {
if (p->drum == drum || p->synti != "Fluid") {
QString pName = p->name;
if (std::find(usedNames.begin(), usedNames.end(), p->name) != usedNames.end()) {
QString addNum = QString(" (%1)").arg(p->sfid);
pName.append(addNum);
}
else
usedNames.push_back(p->name);

patchCombo->addItem(pName, QVariant::fromValue<void*>((void*)p));
if (p->synti == chan->synti() &&
p->bank == chan->bank() &&
p->prog == chan->program())
patchIndex = patchCombo->count() - 1;
}
}
}
}
patchCombo->setCurrentIndex(patchIndex);
@@ -29,7 +29,7 @@ namespace Ms {
struct MidiPatch {
bool drum;
QString synti;
int bank, prog;
int bank, prog, sfid;
QString name;
};

@@ -257,7 +257,7 @@ void Zerberus::updatePatchList()
patches.clear();
int idx = 0;
for (ZInstrument* i : instruments) {
Ms::MidiPatch* p = new Ms::MidiPatch { false, name(), 0, idx, i->name() };
Ms::MidiPatch* p = new Ms::MidiPatch { false, name(), 0, idx, 0, i->name() };
patches.append(p);
++idx;
}

0 comments on commit 6521082

Please sign in to comment.
You can’t perform that action at this time.