don't assume plugin presets start their numbering at zero.

This commit is contained in:
Robin Gareus 2015-12-25 16:20:53 +01:00
parent a8159326b8
commit b92f208b52
4 changed files with 9 additions and 13 deletions

View File

@ -144,17 +144,17 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
void monitoring_changed ();
struct PresetRecord {
PresetRecord () : number (-1), user (true) {}
PresetRecord (const std::string& u, const std::string& l, int n = -1, bool s = true) : uri (u), label (l), number (n), user (s) {}
PresetRecord () : valid (false) {}
PresetRecord (const std::string& u, const std::string& l, bool s = true) : uri (u), label (l), user (s), valid (true) {}
bool operator!= (PresetRecord const & a) const {
return number != a.number || uri != a.uri || label != a.label;
return uri != a.uri || label != a.label;
}
std::string uri;
std::string label;
int number; // if <0, invalid
bool user;
bool valid;
};
PresetRecord save_preset (std::string);
@ -335,8 +335,8 @@ struct PluginPreset {
if (preset) {
_preset.uri = preset->uri;
_preset.label = preset->label;
_preset.number = preset->number;
_preset.user = preset->user;
_preset.valid = preset->valid;
}
}
};

View File

@ -2327,7 +2327,7 @@ AUPlugin::find_presets ()
for (FactoryPresetMap::iterator i = factory_preset_map.begin(); i != factory_preset_map.end(); ++i) {
/* XXX: dubious */
string const uri = string_compose ("%1", _presets.size ());
_presets.insert (make_pair (uri, Plugin::PresetRecord (uri, i->first, i->second)));
_presets.insert (make_pair (uri, Plugin::PresetRecord (uri, i->first, false)));
DEBUG_TRACE (DEBUG::AudioUnits, string_compose("AU Adding Factory Preset: %1 > %2\n", i->first, i->second));
}
}

View File

@ -175,12 +175,8 @@ InstrumentInfo::plugin_programs_to_channel_name_set (boost::shared_ptr<Processor
std::vector<Plugin::PresetRecord>::iterator i;
int n;
/* XXX note the assumption that plugin presets start their numbering at
* zero
*/
for (n = 0, i = presets.begin(); i != presets.end(); ++i, ++n) {
if ((*i).number >= 0) {
if ((*i).valid) {
patch_list.push_back (boost::shared_ptr<Patch> (new Patch ((*i).label, n)));
} else {
patch_list.push_back (boost::shared_ptr<Patch> (new Patch (string_compose ("program %1", n), n)));

View File

@ -679,7 +679,7 @@ VSTPlugin::find_presets ()
int const vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, NULL, 0);
for (int i = 0; i < _plugin->numPrograms; ++i) {
PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", -1, false);
PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", false);
if (vst_version >= 2) {
char buf[256];
@ -709,7 +709,7 @@ VSTPlugin::find_presets ()
assert (uri);
assert (label);
PresetRecord r (uri->value(), label->value(), -1, true);
PresetRecord r (uri->value(), label->value(), true);
_presets.insert (make_pair (r.uri, r));
}
}