--- mda-lv2-1.0.0.orig/mda.lv2/Piano.ttl +++ mda-lv2-1.0.0/mda.lv2/Piano.ttl @@ -21,6 +21,7 @@ mda:Piano doap:license ; lv2:optionalFeature lv2:hardRTCapable ; lv2:requiredFeature ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; lv2:port [ --- mda-lv2-1.0.0.orig/mda.lv2/Detune.ttl +++ mda-lv2-1.0.0/mda.lv2/Detune.ttl @@ -13,6 +13,7 @@ mda:Detune doap:shortdesc "Simple up/down pitch shifting thickener" ; doap:license ; lv2:optionalFeature lv2:hardRTCapable ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment "A low-quality stereo pitch shifter for the sort of chorus and detune effects found on multi-effects hardware." ; --- mda-lv2-1.0.0.orig/mda.lv2/EPiano.ttl +++ mda-lv2-1.0.0/mda.lv2/EPiano.ttl @@ -13,6 +13,7 @@ mda:EPiano doap:license ; lv2:optionalFeature lv2:hardRTCapable ; lv2:requiredFeature ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; lv2:port [ --- mda-lv2-1.0.0.orig/mda.lv2/Leslie.ttl +++ mda-lv2-1.0.0/mda.lv2/Leslie.ttl @@ -14,6 +14,7 @@ mda:Leslie doap:shortdesc "Rotary speaker simulator" ; doap:license ; lv2:optionalFeature lv2:hardRTCapable ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment "No overdrive or speaker cabinet simulation is added - you may want to combine this plug-in with Combo. For a much thicker sound try combining two Leslie plug-ins in series!" ; --- mda-lv2-1.0.0.orig/mda.lv2/Vocoder.ttl +++ mda-lv2-1.0.0/mda.lv2/Vocoder.ttl @@ -14,6 +14,7 @@ mda:Vocoder doap:shortdesc "Switchable 8 or 16 band vocoder" ; doap:license ; lv2:optionalFeature lv2:hardRTCapable ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment """16-band vocoder for applying the spectrum of one sound (the modulator, usually a voice or rhythm part) to the waveform of another (the carrier, usually a synth pad or sawtooth wave). --- mda-lv2-1.0.0.orig/mda.lv2/JX10.ttl +++ mda-lv2-1.0.0/mda.lv2/JX10.ttl @@ -28,6 +28,7 @@ mda:JX10 doap:license ; lv2:optionalFeature lv2:hardRTCapable ; lv2:requiredFeature ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment """When Vibrato is set to PWM, the two oscillators are phase-locked and will produce a square wave if set to the same pitch. Pitch modulation of one oscillator then causes Pulse Width Modulation. (pitch modulation of both oscillators for vibrato is still available from the modulation wheel). Unlike other synths, in PWM mode the oscillators can still be detuned to give a wider range of PWM effects. --- mda-lv2-1.0.0.orig/mda.lv2/ThruZero.ttl +++ mda-lv2-1.0.0/mda.lv2/ThruZero.ttl @@ -13,6 +13,7 @@ mda:ThruZero doap:shortdesc "Classic tape-flanging simulation" ; doap:license ; lv2:optionalFeature lv2:hardRTCapable ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment """Tape flanger and ADT --- mda-lv2-1.0.0.orig/mda.lv2/DX10.ttl +++ mda-lv2-1.0.0/mda.lv2/DX10.ttl @@ -21,6 +21,7 @@ mda:DX10 doap:license ; lv2:optionalFeature lv2:hardRTCapable ; lv2:requiredFeature ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment "Sounds similar to the later Yamaha DX synths including the heavy bass but with a warmer, cleaner tone. This plug-in is 8-voice polyphonic." ; --- mda-lv2-1.0.0.orig/mda.lv2/Splitter.ttl +++ mda-lv2-1.0.0/mda.lv2/Splitter.ttl @@ -14,6 +14,7 @@ mda:Splitter doap:shortdesc "Frequency/level crossover for setting up dynamic processing" ; doap:license ; lv2:optionalFeature lv2:hardRTCapable ; + lv2:extensionData ; pg:mainInput mda:mainIn ; pg:mainOutput mda:mainOut ; rdfs:comment """This plug-in can split a signal based on frequency or level, for example for producing dynamic effects where only loud drum hits are sent to a reverb. Other functions include a simple "spectral gate" in INVERSE mode and a conventional gate and filter for separating drum sounds in NORMAL mode.""" ; --- mda-lv2-1.0.0.orig/lvz/wrapper.cpp +++ mda-lv2-1.0.0/lvz/wrapper.cpp @@ -32,6 +32,7 @@ #include #include "audioeffectx.h" #include "lv2.h" +#include "lv2_programs.h" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/midi/midi.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" @@ -161,9 +162,47 @@ lvz_run(LV2_Handle instance, uint32_t sa plugin->effect->processReplacing(plugin->inputs, plugin->outputs, sample_count); } +static const LV2_Program_Descriptor* +lv2_get_program(LV2_Handle handle, uint32_t index) +{ + static LV2_Program_Descriptor desc = { 0, 0, NULL }; + static char name[256] = { 0 }; + + LVZPlugin* plugin = (LVZPlugin*)handle; + + if ((int)index < plugin->effect->getNumPrograms() && plugin->effect->getProgramNameIndexed(0, index, name)) + { + desc.bank = index / 128; + desc.program = index % 128; + desc.name = name; + return &desc; + } + + return NULL; +} + +static void +lv2_select_program(LV2_Handle handle, uint32_t bank, uint32_t program) +{ + LVZPlugin* plugin = (LVZPlugin*)handle; + + int realProgram = bank * 128 + program; + + if (realProgram < plugin->effect->getNumPrograms()) + { + plugin->effect->setProgram(realProgram); + + for (int32_t i = 0; i < plugin->effect->getNumParameters(); ++i) + plugin->controls[i] = plugin->control_buffers[i][0] = plugin->effect->getParameter(i); + } +} + static const void* lvz_extension_data(const char* uri) { + static const LV2_Programs_Interface programs = { lv2_get_program, lv2_select_program }; + if (strcmp(uri, LV2_PROGRAMS__Interface) == 0) + return &programs; return NULL; } --- mda-lv2-1.0.0.orig/lvz/audioeffectx.h +++ mda-lv2-1.0.0/lvz/audioeffectx.h @@ -106,6 +106,7 @@ public: virtual void getParameterName(int32_t index, char *label) = 0; virtual bool getProductString(char* text) = 0; virtual void getProgramName(char *name) { name[0] = '\0'; } + virtual bool getProgramNameIndexed (int32_t, int32_t, char*) { return false; } virtual int32_t canDo(const char* text) { return false; } virtual bool canHostDo(const char* act) { return false; } --- /dev/null +++ mda-lv2-1.0.0/src/lv2_programs.h @@ -0,0 +1,174 @@ +/* + LV2 Programs Extension + Copyright 2012 Filipe Coelho + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/** + @file lv2_programs.h + C header for the LV2 programs extension . +*/ + +#ifndef LV2_PROGRAMS_H +#define LV2_PROGRAMS_H + +#include "lv2/lv2plug.in/ns/lv2core/lv2.h" +#include "lv2/lv2plug.in/ns/extensions/ui/ui.h" + +#define LV2_PROGRAMS_URI "http://kxstudio.sf.net/ns/lv2ext/programs" +#define LV2_PROGRAMS_PREFIX LV2_PROGRAMS_URI "#" + +#define LV2_PROGRAMS__Host LV2_PROGRAMS_PREFIX "Host" +#define LV2_PROGRAMS__Interface LV2_PROGRAMS_PREFIX "Interface" +#define LV2_PROGRAMS__UIInterface LV2_PROGRAMS_PREFIX "UIInterface" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* LV2_Programs_Handle; + +typedef struct _LV2_Program_Descriptor { + + /** Bank number for this program. Note that this extension does not + support MIDI-style separation of bank LSB and MSB values. There is + no restriction on the set of available banks: the numbers do not + need to be contiguous, there does not need to be a bank 0, etc. */ + uint32_t bank; + + /** Program number (unique within its bank) for this program. There is + no restriction on the set of available programs: the numbers do not + need to be contiguous, there does not need to be a program 0, etc. */ + uint32_t program; + + /** Name of the program. */ + const char * name; + +} LV2_Program_Descriptor; + +/** + Programs extension, plugin data. + + When the plugin's extension_data is called with argument LV2_PROGRAMS__Interface, + the plugin MUST return an LV2_Programs_Instance structure, which remains valid + for the lifetime of the plugin. +*/ +typedef struct _LV2_Programs_Interface { + /** + * get_program() + * + * This member is a function pointer that provides a description + * of a program (named preset sound) available on this plugin. + * + * The index argument is an index into the plugin's list of + * programs, not a program number as represented by the Program + * field of the LV2_Program_Descriptor. (This distinction is + * needed to support plugins that use non-contiguous program or + * bank numbers.) + * + * This function returns a LV2_Program_Descriptor pointer that is + * guaranteed to be valid only until the next call to get_program + * or deactivate, on the same plugin instance. This function must + * return NULL if passed an index argument out of range, so that + * the host can use it to query the number of programs as well as + * their properties. + */ + const LV2_Program_Descriptor *(*get_program)(LV2_Handle handle, + uint32_t index); + + /** + * select_program() + * + * This member is a function pointer that selects a new program + * for this plugin. The program change should take effect + * immediately at the start of the next run() call. (This + * means that a host providing the capability of changing programs + * between any two notes on a track must vary the block size so as + * to place the program change at the right place. A host that + * wanted to avoid this would probably just instantiate a plugin + * for each program.) + * + * Plugins should ignore a select_program() call with an invalid + * bank or program. + * + * A plugin is not required to select any particular default + * program on activate(): it's the host's duty to set a program + * explicitly. + * + * A plugin is permitted to re-write the values of its input + * control ports when select_program is called. The host should + * re-read the input control port values and update its own + * records appropriately. (This is the only circumstance in which + * a LV2 plugin is allowed to modify its own control-input ports.) + */ + void (*select_program)(LV2_Handle handle, + uint32_t bank, + uint32_t program); + +} LV2_Programs_Interface; + +/** + Programs extension, UI data. + + When the UI's extension_data is called with argument LV2_PROGRAMS__UIInterface, + the UI MUST return an LV2_Programs_UI_Interface structure, which remains valid + for the lifetime of the UI. +*/ +typedef struct _LV2_Programs_UI_Interface { + /** + * select_program() + * + * This is exactly the same as select_program in LV2_Programs_Instance, + * but this struct relates to the UI instead of the plugin. + * + * When called, UIs should update their state to match the selected program. + */ + void (*select_program)(LV2UI_Handle handle, + uint32_t bank, + uint32_t program); + +} LV2_Programs_UI_Interface; + +/** + Feature data for LV2_PROGRAMS__Host. +*/ +typedef struct _LV2_Programs_Host { + /** + * Opaque host data. + */ + LV2_Programs_Handle handle; + + /** + * program_changed() + * + * Tell the host to reload a plugin's program. + * Parameter handle MUST be the 'handle' member of this struct. + * Parameter index is program index to change. + * When index is -1, host should reload all the programs. + * + * The plugin MUST NEVER call this function on a RT context or during run(). + * + * NOTE: This call is to inform the host about a program's bank, program or name change. + * It DOES NOT change the current selected program. + */ + void (*program_changed)(LV2_Programs_Handle handle, + int32_t index); + +} LV2_Programs_Host; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* LV2_PROGRAMS_H */