diff options
Diffstat (limited to 'pluginlv2.cc')
-rw-r--r-- | pluginlv2.cc | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/pluginlv2.cc b/pluginlv2.cc index fd0bfbf..46ef83b 100644 --- a/pluginlv2.cc +++ b/pluginlv2.cc @@ -26,7 +26,6 @@ */ #include "pluginlv2.h" -#include <iostream> #include <sstream> #include <assert.h> @@ -122,7 +121,7 @@ LV2_Handle PluginLV2::instantiate(const struct _LV2_Descriptor* descriptor, } #endif -#ifdef DISPLAY_INTERFACE +#ifdef MIDNAM_INTERFACE if(uri == LV2_MIDNAM__update) { plugin_lv2->midnam = (LV2_Midnam*)data; @@ -363,10 +362,11 @@ void PluginLV2::run(LV2_Handle instance, uint32_t sample_count) plugin_lv2->pos += sample_count; -#ifdef MIDNAME_INTERFACE - if (0) // XXX drumkit changed +#ifdef MIDNAM_INTERFACE + if(plugin_lv2->midnam_changed) { - plugin_lv2->midnam->update (plugin_lv2->midnam->handle); + plugin_lv2->midnam->update(plugin_lv2->midnam->handle); + plugin_lv2->midnam_changed = false; } #endif @@ -485,7 +485,22 @@ LV2_Inline_Display_Image_Surface* PluginLV2::inlineRender(LV2_Handle instance, return &plugin_lv2->surf; } -#ifdef MIDNAME_INTERFACE +void PluginLV2::setMidnamData(const std::vector<std::pair<int, std::string>>& midnam) +{ + auto idx = 0u; + for(const auto& m : midnam) + { + this->midnamData[idx] = m; + idx++; + } + for(;idx < this->midnamData.size(); ++idx) + { + this->midnamData[idx] = {-1, {}}; + } + midnam_changed = true; +} + +#ifdef MIDNAM_INTERFACE char* PluginLV2::MidnamFile (LV2_Handle instance) { PluginLV2* plugin_lv2 = (PluginLV2*)instance; @@ -496,8 +511,8 @@ char* PluginLV2::MidnamFile (LV2_Handle instance) "<MIDINameDocument>\n" " <Author/>\n" " <MasterDeviceNames>\n" - " <Manufacturer>The Drum Gizmo Foundation</Manufacturer>\n" - " <Model>Drumgizmo:" << ((const void *) instance) << "</Model>\n"; //<< needs to match MidnamModel() + " <Manufacturer>" << plugin_lv2->getVendorString() << "</Manufacturer>\n" + " <Model>" << plugin_lv2->getProductString() << ":" << ((const void *) instance) << "</Model>\n"; //<< needs to match MidnamModel() ss << " <CustomDeviceMode Name=\"Default\">\n"; ss << " <ChannelNameSetAssignments>\n"; @@ -523,11 +538,17 @@ char* PluginLV2::MidnamFile (LV2_Handle instance) " </PatchBank>\n" " </ChannelNameSet>\n" " <NoteNameList Name=\"Notes\">\n"; - - // XXX TODO ask plugin_lv2, iterate over mapped samples - ss << " <Note Number=\"36\" Name=\"KickDrum\"/>\n"; - ss << " <Note Number=\"38\" Name=\"Snare\"/>\n"; - // XXX + // TODO: Fill in empty slots for the notes that are not in the map + // Does Ardour preserve the note names for the unspecified notes? + // ... and is this a bug?? + for(const auto& m : plugin_lv2->midnamData) + { + if(m.first == -1) + { + continue; + } + ss << " <Note Number=\"" << m.first << "\" Name=\""<< m.second << "\"/>\n"; + } ss << " </NoteNameList>\n" @@ -537,10 +558,12 @@ char* PluginLV2::MidnamFile (LV2_Handle instance) return strdup (ss.str().c_str()); } -char* PluginLV2::MidnamModel (LV2_Handle instance) +char* PluginLV2::MidnamModel(LV2_Handle instance) { + PluginLV2* plugin_lv2 = (PluginLV2*)instance; char* rv = (char*) malloc (64 * sizeof (char)); - snprintf (rv, 64, "Drumgizmo:%p", (void*) instance); + snprintf(rv, 64, "%s:%p", + plugin_lv2->getProductString().data(), (void*) instance); rv[63] = 0; return rv; } @@ -566,7 +589,7 @@ const void* PluginLV2::extensionData(const char *uri) } #endif -#ifdef MIDNAME_INTERFACE +#ifdef MIDNAM_INTERFACE static const LV2_Midnam_Interface midnam = { MidnamFile, MidnamModel, MidnamFree }; if (!strcmp (uri, LV2_MIDNAM__interface)) { |