13
0

triggers: code to dump MIDI learn-ed bindings as a binding map

This commit is contained in:
Paul Davis 2022-11-16 16:25:09 -07:00
parent 93adb3fe1f
commit 5a07da9255
2 changed files with 24 additions and 0 deletions

View File

@ -819,6 +819,7 @@ class LIBARDOUR_API TriggerBox : public Processor
static void add_custom_midi_binding (int id, int x, int y);
static void remove_custom_midi_binding (int x, int y);
static void clear_custom_midi_bindings ();
static int dump_custom_midi_bindings (std::string const & path);
void begin_midi_learn (int index);
void midi_unlearn (int index);

View File

@ -18,6 +18,7 @@
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <memory>
#include <sstream>
@ -3968,6 +3969,28 @@ TriggerBox::clear_custom_midi_bindings ()
_custom_midi_map.clear ();
}
int
TriggerBox::dump_custom_midi_bindings (std::string const & path)
{
std::ofstream f (path.c_str());
if (!f) {
return -1;
}
f << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <ArdourMIDIBindings version=\"1.0.0\" name=\"The name of this set of bindings\">\n";
for (CustomMidiMap::iterator i = _custom_midi_map.begin(); i != _custom_midi_map.end(); ++i) {
string str = string_compose (X_("\t<Binding msg note=\"%1\" channel=\"%2\" action=\"Cues/trigger-slot-%1-%2\"/>\n"),
i->first % 16, /* note number */
i->first / 16, /* channel */
i->second.first,
i->second.second);
}
f << "</ArdourMIDIBindings>\n";
}
void
TriggerBox::add_custom_midi_binding (int id, int x, int y)
{