From 4049b7a2d4980ed7ac1e4c8c08914203df32121d Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 26 Jul 2015 17:06:37 +0200 Subject: [PATCH] Start work on carla-lv2 presets export, commented out for now --- source/plugin/carla-lv2-export.cpp | 65 +++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/source/plugin/carla-lv2-export.cpp b/source/plugin/carla-lv2-export.cpp index 8c1977039..b8f4c68cb 100644 --- a/source/plugin/carla-lv2-export.cpp +++ b/source/plugin/carla-lv2-export.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2013-2014 Filipe Coelho + * Copyright (C) 2013-2015 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -554,6 +554,69 @@ static void writePluginFile(const NativePluginDescriptor* const pluginDesc) text += " doap:name \"" + String(pluginDesc->name) + "\" ;\n"; text += " doap:maintainer [ foaf:name \"" + String(pluginDesc->maker) + "\" ] .\n"; +#if 0 + // ------------------------------------------------------------------- + // Presets + + if (pluginDesc->get_midi_program_count != nullptr && pluginDesc->get_midi_program_info != nullptr && pluginHandle != nullptr) + { + if (const uint32_t presetCount = pluginDesc->get_midi_program_count(pluginHandle)) + { + const String presetsFile("carla.lv2/" + pluginLabel + "-presets.ttl"); + std::fstream presetsStream(presetsFile.toRawUTF8(), std::ios::out); + + String presetId, presetText; + + presetText += "@prefix lv2: .\n"; + presetText += "@prefix pset: .\n"; + presetText += "@prefix rdfs: .\n"; + + for (uint32_t i=0; iget_midi_program_info(pluginHandle, i)); + pluginDesc->set_midi_program(pluginHandle, 0, midiProg->bank, midiProg->program); + + presetId = String::formatted("%03i", i+1); + + text += "\n\n"; + text += " a pset:Preset ;\n"; + text += " lv2:appliesTo ;\n"; + text += " rdfs:seeAlso <" + pluginLabel + "-presets.ttl> .\n"; + + presetText += "\n\n"; + presetText += " a pset:Preset ;\n"; + presetText += " lv2:appliesTo ;\n"; + presetText += " rdfs:label \"" + String(midiProg->name) + "\" ;\n"; + + for (uint32_t j=0; j < paramCount; ++j) + { + const NativeParameter* paramInfo(pluginDesc->get_parameter_info(pluginHandle, j)); + const String paramName(paramInfo->name != nullptr ? paramInfo->name : ""); + const String paramUnit(paramInfo->unit != nullptr ? paramInfo->unit : ""); + + CARLA_SAFE_ASSERT_RETURN(paramInfo != nullptr,) + + if (j == 0) + presetText += " lv2:port [\n"; + + presetText += " lv2:symbol \"" + nameToSymbol(paramName, j) + "\" ;\n"; + presetText += " pset:value " + String::formatted("%f", pluginDesc->get_parameter_value(pluginHandle, j)) + " ;\n"; + + if (j+1 == paramCount) + presetText += " ] ;\n\n"; + else + presetText += " ] , [\n"; + } + + presetsStream << presetText.toRawUTF8(); + presetText.clear(); + } + + presetsStream.close(); + } + } +#endif + // ------------------------------------------------------------------- // Write file now