From 28fb4417b0f84c7c1d0b999acb116cd32c62736d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 23 Sep 2016 14:45:26 +0200 Subject: [PATCH] Added demo plugin beep - trying to use it as a start for dexed-lv2. --- .gitignore | 1 + beep/Makefile | 23 +++++++++++ beep/beep.cpp | 59 ++++++++++++++++++++++++++++ beep/beep.peg | 35 +++++++++++++++++ beep/beep.ttl | 46 ++++++++++++++++++++++ beep/lv2pftci-beep.lv2/beep.ttl | 46 ++++++++++++++++++++++ beep/lv2pftci-beep.lv2/manifest.ttl | 5 +++ beep/manifest.ttl | 5 +++ src/.Makefile.swp | Bin 12288 -> 12288 bytes src/.project | 27 ------------- src/Makefile | 2 +- src/PluginProcessor.h | 2 +- 12 files changed, 222 insertions(+), 29 deletions(-) create mode 100644 beep/Makefile create mode 100644 beep/beep.cpp create mode 100644 beep/beep.peg create mode 100644 beep/beep.ttl create mode 100644 beep/lv2pftci-beep.lv2/beep.ttl create mode 100644 beep/lv2pftci-beep.lv2/manifest.ttl create mode 100644 beep/manifest.ttl delete mode 100644 src/.project diff --git a/.gitignore b/.gitignore index 9d22eb4..283611c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o *.so +*.gch diff --git a/beep/Makefile b/beep/Makefile new file mode 100644 index 0000000..022905f --- /dev/null +++ b/beep/Makefile @@ -0,0 +1,23 @@ +BUNDLE = lv2pftci-beep.lv2 +INSTALL_DIR = /usr/local/lib/lv2 + + +$(BUNDLE): manifest.ttl beep.ttl beep.so + rm -rf $(BUNDLE) + mkdir $(BUNDLE) + cp $^ $(BUNDLE) + +beep.so: beep.cpp beep.peg + g++ -shared -fPIC -DPIC beep.cpp `pkg-config --cflags --libs lv2-plugin` -o beep.so + +beep.peg: beep.ttl + lv2peg beep.ttl beep.peg + +install: $(BUNDLE) + mkdir -p $(INSTALL_DIR) + rm -rf $(INSTALL_DIR)/$(BUNDLE) + cp -R $(BUNDLE) $(INSTALL_DIR) + +clean: + rm -rf $(BUNDLE) beep.so beep.peg + diff --git a/beep/beep.cpp b/beep/beep.cpp new file mode 100644 index 0000000..ee22fb6 --- /dev/null +++ b/beep/beep.cpp @@ -0,0 +1,59 @@ +#include +#include "beep.peg" + + +class BeepVoice : public LV2::Voice { +public: + + BeepVoice(double rate) + : m_key(LV2::INVALID_KEY), m_rate(rate), m_period(10), m_counter(0) { + + } + + void on(unsigned char key, unsigned char velocity) { + m_key = key; + m_period = m_rate * 4.0 / LV2::key2hz(m_key); + } + + void off(unsigned char velocity) { + m_key = LV2::INVALID_KEY; + } + + unsigned char get_key() const { + return m_key; + } + + void render(uint32_t from, uint32_t to) { + if (m_key == LV2::INVALID_KEY) + return; + for (uint32_t i = from; i < to; ++i) { + float s = -0.25 + 0.5 * (m_counter > m_period / 2); + m_counter = (m_counter + 1) % m_period; + p(p_left)[i] += s; + p(p_right)[i] += s; + } + } + +protected: + + unsigned char m_key; + double m_rate; + uint32_t m_period; + uint32_t m_counter; + +}; + + +class Beep : public LV2::Synth { +public: + + Beep(double rate) + : LV2::Synth(p_n_ports, p_midi) { + add_voices(new BeepVoice(rate), new BeepVoice(rate), new BeepVoice(rate)); + add_audio_outputs(p_left, p_right); + } + +}; + + +static int _ = Beep::register_class(p_uri); diff --git a/beep/beep.peg b/beep/beep.peg new file mode 100644 index 0000000..daa5805 --- /dev/null +++ b/beep/beep.peg @@ -0,0 +1,35 @@ +#ifndef beep_peg +#define beep_peg + + +#ifndef PEG_STRUCT +#define PEG_STRUCT +typedef struct { + float min; + float max; + float default_value; + char toggled; + char integer; + char logarithmic; +} peg_data_t; +#endif + +/* */ + +static const char p_uri[] = "http://ll-plugins.nongnu.org/lv2/lv2pftci/beep"; + +enum p_port_enum { + p_midi, + p_left, + p_right, + p_n_ports +}; + +static const peg_data_t p_ports[] = { + { -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 }, + { -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 }, + { -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 }, +}; + + +#endif /* beep_peg */ diff --git a/beep/beep.ttl b/beep/beep.ttl new file mode 100644 index 0000000..540fd56 --- /dev/null +++ b/beep/beep.ttl @@ -0,0 +1,46 @@ +@prefix lv2: . +@prefix doap: . +@prefix rdf: . +@prefix rdfs: . +@prefix ll: . +@prefix pg: . +@prefix ev: . + + a pg:StereoGroup. + + + a lv2:Plugin, lv2:InstrumentPlugin; + lv2:binary ; + doap:name "Beep"; + doap:license ; + ll:pegName "p"; + + lv2:port [ + a ev:EventPort, lv2:InputPort; + lv2:index 0; + ev:supportsEvent ; + lv2:symbol "midi"; + lv2:name "MIDI"; + ], + + [ + a lv2:AudioPort, lv2:OutputPort; + lv2:index 1; + lv2:symbol "left"; + lv2:name "Left"; + pg:membership [ + pg:group ; + pg:role pg:leftChannel; + ]; + ], + + [ + a lv2:AudioPort, lv2:OutputPort; + lv2:index 2; + lv2:symbol "right"; + lv2:name "Right"; + pg:membership [ + pg:group ; + pg:role pg:rightChannel; + ]; + ]. diff --git a/beep/lv2pftci-beep.lv2/beep.ttl b/beep/lv2pftci-beep.lv2/beep.ttl new file mode 100644 index 0000000..540fd56 --- /dev/null +++ b/beep/lv2pftci-beep.lv2/beep.ttl @@ -0,0 +1,46 @@ +@prefix lv2: . +@prefix doap: . +@prefix rdf: . +@prefix rdfs: . +@prefix ll: . +@prefix pg: . +@prefix ev: . + + a pg:StereoGroup. + + + a lv2:Plugin, lv2:InstrumentPlugin; + lv2:binary ; + doap:name "Beep"; + doap:license ; + ll:pegName "p"; + + lv2:port [ + a ev:EventPort, lv2:InputPort; + lv2:index 0; + ev:supportsEvent ; + lv2:symbol "midi"; + lv2:name "MIDI"; + ], + + [ + a lv2:AudioPort, lv2:OutputPort; + lv2:index 1; + lv2:symbol "left"; + lv2:name "Left"; + pg:membership [ + pg:group ; + pg:role pg:leftChannel; + ]; + ], + + [ + a lv2:AudioPort, lv2:OutputPort; + lv2:index 2; + lv2:symbol "right"; + lv2:name "Right"; + pg:membership [ + pg:group ; + pg:role pg:rightChannel; + ]; + ]. diff --git a/beep/lv2pftci-beep.lv2/manifest.ttl b/beep/lv2pftci-beep.lv2/manifest.ttl new file mode 100644 index 0000000..8511bab --- /dev/null +++ b/beep/lv2pftci-beep.lv2/manifest.ttl @@ -0,0 +1,5 @@ +@prefix lv2: . +@prefix rdfs: . + + a lv2:Plugin; + rdfs:seeAlso . diff --git a/beep/manifest.ttl b/beep/manifest.ttl new file mode 100644 index 0000000..8511bab --- /dev/null +++ b/beep/manifest.ttl @@ -0,0 +1,5 @@ +@prefix lv2: . +@prefix rdfs: . + + a lv2:Plugin; + rdfs:seeAlso . diff --git a/src/.Makefile.swp b/src/.Makefile.swp index 3f857ffb38eaeca3f13dcc069c1d5e17fe322245..6b3f35f36399e5e1a54c6f4a87b8f566f09e3ce6 100644 GIT binary patch delta 88 zcmZojXh;xBG6?hZRWR2xVE_UF28N#s8-+f}v%ckJU?`l-sSquBj*o%iED-Mm;@Lnv k3yAxHxNvi=!WZ7j3-#nCPt^-zQ_#{&PtMrq#;K0AZgMJpcdz diff --git a/src/.project b/src/.project deleted file mode 100644 index 9b260f8..0000000 --- a/src/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Source - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/src/Makefile b/src/Makefile index 19c8a14..8c5edfa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,7 +17,7 @@ all: \ SysexComm.o \ clean: - rm -f *.o *~ *.bak + rm -f *.o *~ *.bak *.gch msfa/%.o: msfa/%.cc $(CXX) $(CFLAGS) -Wall -c $< diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h index 8e41a4d..7e06968 100644 --- a/src/PluginProcessor.h +++ b/src/PluginProcessor.h @@ -228,7 +228,7 @@ public : static File dexedCartDir; private: //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DexedAudioProcessor) + DexedAudioProcessor; };