Consistent AU factory Preset IDs
authorRobin Gareus <robin@gareus.org>
Mon, 3 Dec 2018 19:45:06 +0000 (20:45 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 3 Dec 2018 19:45:06 +0000 (20:45 +0100)
Use AU's preset->presetNumber as identifier since std::map are sorted
this also indirectly sorts presets by preset-number. (user presets
start with a '/' and are listed first, sorted by name).

Since Presets are now identified by URI on session load (53a0199a0)
and AU user-presets can added/be removed (since ae4604a24b7), simple
sequential numbering is no longer an option.

libs/ardour/audio_unit.cc

index 559961b0b28c415c75369eabdf9ffa03342aff5a..31ef2c470e791f97a1b8803b071dd344229c14a0 100644 (file)
@@ -2604,10 +2604,7 @@ AUPlugin::find_presets ()
        /* add factory presets */
 
        for (FactoryPresetMap::iterator i = factory_preset_map.begin(); i != factory_preset_map.end(); ++i) {
-               /* XXX: dubious -- deleting & re-adding a preset -> same URI
-                * good that we don't support deleting AU presets :)
-                */
-               string const uri = PBD::to_string<uint32_t> (_presets.size ());
+               string const uri = string_compose ("AU2:%1", std::setw(4), std::setfill('0'), 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));
        }