aboutsummaryrefslogtreecommitdiffstats
path: root/lvz
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-20 18:52:14 +0000
committerDavid Robillard <d@drobilla.net>2012-04-20 18:52:14 +0000
commitba1917edea8f3b0eaf5aafdc2a7827ab076c61b4 (patch)
tree9d73c2ab8862e80867bafa0f3ce5dd92f616ff7e /lvz
parent19cba7fcbbcfcedbd45cef80e6c7c11ee2e98068 (diff)
downloadmda.lv2-ba1917edea8f3b0eaf5aafdc2a7827ab076c61b4.tar.gz
mda.lv2-ba1917edea8f3b0eaf5aafdc2a7827ab076c61b4.tar.bz2
mda.lv2-ba1917edea8f3b0eaf5aafdc2a7827ab076c61b4.zip
Make instrument plugins work.
git-svn-id: http://svn.drobilla.net/lad/trunk/plugins/mda.lv2@4215 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'lvz')
-rw-r--r--lvz/audioeffectx.h38
-rw-r--r--lvz/wrapper.cpp24
2 files changed, 43 insertions, 19 deletions
diff --git a/lvz/audioeffectx.h b/lvz/audioeffectx.h
index e4a7fb9..d457074 100644
--- a/lvz/audioeffectx.h
+++ b/lvz/audioeffectx.h
@@ -22,6 +22,9 @@
#include <stdint.h>
#include <string.h>
+#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
+
class AudioEffect;
typedef int (*audioMasterCallback)(int, int ver, int, int, int, int);
@@ -75,6 +78,7 @@ public:
AudioEffectX(audioMasterCallback audioMaster, int32_t progs, int32_t params)
: URI("NIL")
, uniqueID("NIL")
+ , eventInput(NULL)
, sampleRate(44100)
, curProgram(0)
, numInputs(0)
@@ -84,9 +88,12 @@ public:
{
}
- virtual void process (float **inputs, float **outputs, int32_t nframes) = 0;
+ virtual void process (float **inputs, float **outputs, int32_t nframes) {}
virtual void processReplacing(float **inputs, float **outputs, int32_t nframes) = 0;
+ void setMidiEventType(LV2_URID urid) { midiEventType = urid; }
+ void setEventInput(const LV2_Atom_Sequence* seq) { eventInput = seq; }
+
virtual int32_t processEvents(LvzEvents* ev) { return 0; }
virtual const char* getURI() { return URI; }
@@ -99,11 +106,12 @@ public:
virtual void getParameterName(int32_t index, char *label) = 0;
virtual bool getProductString(char* text) = 0;
- virtual bool canHostDo(const char* act) { return false; }
- virtual void canMono() {}
- virtual void canProcessReplacing() {}
- virtual void isSynth() {}
- virtual void wantEvents() {}
+ virtual int32_t canDo(const char* text) { return false; }
+ virtual bool canHostDo(const char* act) { return false; }
+ virtual void canMono() {}
+ virtual void canProcessReplacing() {}
+ virtual void isSynth() {}
+ virtual void wantEvents() {}
virtual void setBlockSize(int32_t size) {}
virtual void setNumInputs(int32_t num) { numInputs = num; }
@@ -121,14 +129,16 @@ public:
}
protected:
- const char* URI;
- const char* uniqueID;
- float sampleRate;
- int32_t curProgram;
- int32_t numInputs;
- int32_t numOutputs;
- int32_t numParams;
- int32_t numPrograms;
+ const char* URI;
+ const char* uniqueID;
+ const LV2_Atom_Sequence* eventInput;
+ LV2_URID midiEventType;
+ float sampleRate;
+ int32_t curProgram;
+ int32_t numInputs;
+ int32_t numOutputs;
+ int32_t numParams;
+ int32_t numPrograms;
};
#endif // LVZ_AUDIOEFFECTX_H
diff --git a/lvz/wrapper.cpp b/lvz/wrapper.cpp
index b8b9624..6d265a7 100644
--- a/lvz/wrapper.cpp
+++ b/lvz/wrapper.cpp
@@ -32,6 +32,9 @@
#include <stdlib.h>
#include "audioeffectx.h"
#include "lv2.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"
#include PLUGIN_HEADER
extern "C" {
@@ -61,17 +64,19 @@ lvz_cleanup(LV2_Handle instance)
static void
lvz_connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- LVZPlugin* plugin = (LVZPlugin*)instance;
-
- uint32_t num_params = plugin->effect->getNumParameters();
- uint32_t num_inputs = plugin->effect->getNumInputs();
+ LVZPlugin* plugin = (LVZPlugin*)instance;
+ const uint32_t num_params = plugin->effect->getNumParameters();
+ const uint32_t num_inputs = plugin->effect->getNumInputs();
+ const uint32_t num_outputs = plugin->effect->getNumOutputs();
if (port < num_params) {
plugin->control_buffers[port] = (float*)data;
} else if (port < num_params + num_inputs) {
plugin->inputs[port - num_params] = (float*)data;
- } else {
+ } else if (port < num_params + num_inputs + num_outputs) {
plugin->outputs[port - num_params - num_inputs] = (float*)data;
+ } else if (port == num_params + num_inputs + num_outputs) {
+ plugin->effect->setEventInput((LV2_Atom_Sequence*)data);
}
}
@@ -98,6 +103,15 @@ lvz_instantiate(const LV2_Descriptor* descriptor,
LVZPlugin* plugin = (LVZPlugin*)malloc(sizeof(LVZPlugin));
plugin->effect = effect;
+ for (int i = 0; features[i]; ++i) {
+ if (!strcmp(features[i]->URI, LV2_URID__map)) {
+ LV2_URID_Map* map = (LV2_URID_Map*)features[i]->data;
+ plugin->effect->setMidiEventType(
+ map->map(map->handle, LV2_MIDI__MidiEvent));
+ break;
+ }
+ }
+
if (num_params > 0) {
plugin->controls = (float*)malloc(sizeof(float) * num_params);
plugin->control_buffers = (float**)malloc(sizeof(float*) * num_params);