diff options
Diffstat (limited to 'lvz')
-rw-r--r-- | lvz/audioeffectx.h | 104 | ||||
-rw-r--r-- | lvz/lvzgui.h | 85 | ||||
-rw-r--r-- | lvz/wrapper.cpp | 115 |
3 files changed, 304 insertions, 0 deletions
diff --git a/lvz/audioeffectx.h b/lvz/audioeffectx.h new file mode 100644 index 0000000..f2f696b --- /dev/null +++ b/lvz/audioeffectx.h @@ -0,0 +1,104 @@ +/* LVZ - A C++ interface for writing LV2 plugins. + * Copyright (C) 2008 Dave Robillard <http://drobilla.net> + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __lvz_audioeffectx_h +#define __lvz_audioeffectx_h + +#include <stdint.h> +#include <string.h> + +typedef int16_t LvzInt16; +typedef int32_t LvzInt32; +typedef void* audioMasterCallback; + +class AEffGUIEditor; + +enum LvzPinFlags { + kLvzPinIsActive = 1<<0, + kLvzPinIsStereo = 1<<1 +}; + +struct LvzPinProperties { + LvzPinProperties() : label(NULL), flags(0) {} + char* label; + int flags; + +}; + +enum LvzEventTypes { + kLvzMidiType = 0 +}; + +struct LvzEvent { + int type; +}; + +struct LvzMidiEvent : public LvzEvent { + char* midiData; + long deltaFrames; +}; + +struct LvzEvents { + long numEvents; + LvzEvent** events; +}; + +#define DECLARE_LVZ_DEPRECATED(x) x + +class AudioEffect { +}; + +class AudioEffectX : public AudioEffect { +public: + AudioEffectX(audioMasterCallback audioMaster, int progs, int params) + : curProgram(0) + , numPrograms(progs) + , numInputs(0) + , numOutputs(0) + { + } + + float getSampleRate() { return sampleRate; } + uint32_t getNumInputs() { return numInputs; } + uint32_t getNumOutputs() { return numOutputs; } + void setNumInputs(uint32_t num) { numInputs = num; } + void setNumOutputs(uint32_t num) { numOutputs = num;} + void setUniqueID(const char* id) {} + void setSampleRate(float rate) { sampleRate = rate; } + void canMono() {} + void wantEvents() {} + void canProcessReplacing() {} + void isSynth() {} + void suspend() {} + void setBlockSize(uint32_t blockSize) {} + void setParameter(uint32_t index, float value) {} + + void process(float **inputs, float **outputs, uint32_t nframes) {} + +protected: + uint32_t curProgram; + uint32_t numPrograms; + uint32_t numInputs; + uint32_t numOutputs; + float sampleRate; + + AEffGUIEditor* editor; +}; + +#endif // __lvz_audioeffectx_h + diff --git a/lvz/lvzgui.h b/lvz/lvzgui.h new file mode 100644 index 0000000..c28c2a6 --- /dev/null +++ b/lvz/lvzgui.h @@ -0,0 +1,85 @@ +/* LVZ - A C++ interface for writing LV2 plugins. + * Copyright (C) 2008 Dave Robillard <http://drobilla.net> + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __lvz_gui_h +#define __lvz_gui_h + +#include "audioeffectx.h" + +static const uint32_t kBlackCColor = 0x00000000; + + +class CRect { +public: + CRect(long x=0, long y=0, long w=0, long h=0) + : left(x), top(y), right(x+w), bottom(y+h) + {} + void offset(long x, long y) {} + long left, top, right, bottom; +}; + +class CControl { +public: + CControl(CRect& size) {} + void setDirty(bool dirty) {} + void setValue(float value) {} +}; + +class CPoint { +public: + CPoint(long a_x, long a_y) : x(a_x), y(a_y) {} + long x, y; +}; + +class CFrame { +public: + CFrame(CRect& size, void* ptr, void* editor) {} + void addView(CControl* control) {} +}; + +class CDrawContext { +public: + void setFillColor(uint32_t color) {} + void fillRect(CRect& rect); +}; + +class CBitmap { +public: + CBitmap(long something) {} + + long getWidth() { return 0; } + long getHeight() { return 0; } + + void draw(CDrawContext* context, CRect& rect) {} +}; + +class AEffGUIEditor { +public: + AEffGUIEditor(AudioEffect* eff) : effect(eff), rect(0, 0, 0, 0) {} + void open(void* ptr) {} + + void idle() {} + +protected: + AudioEffect* effect; + CRect rect; + CFrame* frame; +}; + +#endif // __lvz_gui_h + diff --git a/lvz/wrapper.cpp b/lvz/wrapper.cpp new file mode 100644 index 0000000..5916b13 --- /dev/null +++ b/lvz/wrapper.cpp @@ -0,0 +1,115 @@ +/* LVZ - A C++ interface for writing LV2 plugins. + * Copyright (C) 2008 Dave Robillard <http://drobilla.net> + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef PLUGIN_URI +#error "This file requires PLUGIN_URI to be defined" +#endif + +#ifndef PLUGIN_CLASS +#error "This file requires PLUGIN_CLASS to be defined" +#endif + +#include <stdlib.h> +#include "audioeffectx.h" +#include "lv2.h" +#include PLUGIN_HEADER + +extern "C" { + +/* Plugin */ + +typedef struct { + PLUGIN_CLASS* effect; + float** inputs; + float** outputs; +} MDAPlugin; + + +static void mda_cleanup(LV2_Handle instance) +{ + free(instance); +} + + +static void mda_connect_port(LV2_Handle instance, uint32_t port, void* data) +{ + MDAPlugin* plugin = (MDAPlugin*)instance; + plugin->effect->setParameter(port, *(float*)data); +} + + +static LV2_Handle +mda_instantiate(const LV2_Descriptor* descriptor, + double rate, + const char* bundle_path, + const LV2_Feature*const* features) +{ + PLUGIN_CLASS* effect = new PLUGIN_CLASS(NULL); + effect->setSampleRate(rate); + + MDAPlugin* plugin = (MDAPlugin*)malloc(sizeof(MDAPlugin)); + plugin->effect = effect; + plugin->inputs = (float**)malloc(sizeof(float*) * effect->getNumInputs()); + plugin->outputs = (float**)malloc(sizeof(float*) * effect->getNumOutputs()); + + return (LV2_Handle)plugin; +} + + +static void +mda_run(LV2_Handle instance, uint32_t sample_count) +{ + MDAPlugin* plugin = (MDAPlugin*)instance; + plugin->effect->process(plugin->inputs, plugin->outputs, sample_count); +} + +/* Library */ + +static LV2_Descriptor *mda_descriptor = NULL; + +static void +init_descriptor() +{ + mda_descriptor = (LV2_Descriptor*)malloc(sizeof(LV2_Descriptor)); + + mda_descriptor->URI = PLUGIN_URI; + mda_descriptor->activate = NULL; + mda_descriptor->cleanup = mda_cleanup; + mda_descriptor->connect_port = mda_connect_port; + mda_descriptor->deactivate = NULL; + mda_descriptor->instantiate = mda_instantiate; + mda_descriptor->run = mda_run; +} + + +LV2_SYMBOL_EXPORT +const LV2_Descriptor* +lv2_descriptor(uint32_t index) +{ + if (!mda_descriptor) + init_descriptor(); + + switch (index) { + case 0: + return mda_descriptor; + default: + return NULL; + } +} + +} // extern "C" |