################################################################################
# wombtone - Chase Bliss Audio Wombtone MK II model for MOD Devices
################################################################################

WOMP_VERSION = main
WOMP_SITE = https://github.com/DISTRHO/DPF.git
WOMP_SITE_METHOD = git
WOMP_BUNDLES = wombtone.lv2

define WOMP_PLUGIN_INFO_H
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_BRAND   "Chase Bliss Audio"
#define DISTRHO_PLUGIN_NAME    "Wombtone MK II"
#define DISTRHO_PLUGIN_URI     "https://github.com/austin-dsp/lv2-plugins/wombtone"
#define DISTRHO_PLUGIN_CLAP_ID "com.chasebliss.wombtone"

#define DISTRHO_PLUGIN_NUM_INPUTS   2
#define DISTRHO_PLUGIN_NUM_OUTPUTS  2
#define DISTRHO_PLUGIN_IS_RT_SAFE   1
#define DISTRHO_PLUGIN_IS_SYNTH     0
#define DISTRHO_PLUGIN_HAS_UI       0
#define DISTRHO_PLUGIN_WANT_STATE   0
#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_TIMEPOS 0
#define DISTRHO_PLUGIN_WANT_MIDI_INPUT  0
#define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 0

enum Parameters {
    pMix = 0,
    pRate,
    pDepth,
    pWaveform,
    pStages,
    pFeedback,
    pRamp,
    pTone,

    kParameterCount
};

#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED
endef

define WOMP_PLUGIN_CPP
#include "DistrhoPlugin.hpp"
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdlib>

START_NAMESPACE_DISTRHO

class WombtonePlugin : public Plugin {
public:
    WombtonePlugin() : Plugin(kParameterCount, 0, 0), fSampleRate(48000.0f), fPhase(0.0f), fRampPhase(0.0f), fSmoothFreq(500.0f), fSmoothLfo(0.0f), fRandomTarget(0.5f), fRandomCurrent(0.5f) {
        fParams[pMix] = 0.5f;
        fParams[pRate] = 0.5f;
        fParams[pDepth] = 0.7f;
        fParams[pWaveform] = 0.0f;
        fParams[pStages] = 4.0f;
        fParams[pFeedback] = 0.3f;
        fParams[pRamp] = 0.0f;
        fParams[pTone] = 0.5f;

        clearBuffers();
    }

protected:
    const char* getLabel() const override { return "Wombtone"; }
    const char* getDescription() const override {
        return "True analog-style multi-stage phaser based on Chase Bliss Audio Wombtone MK II.";
    }
    const char* getMaker() const override { return "Chase Bliss Audio / AustinDSP"; }
    const char* getLicense() const override { return "MIT"; }
    uint32_t getVersion() const override { return d_version(1, 0, 0); }
    int64_t getUniqueId() const override { return d_cconst('C', 'B', 'W', 'T'); }

    void sampleRateChanged(double newSampleRate) override {
        fSampleRate = (float)newSampleRate;
        clearBuffers();
    }

    void clearBuffers() {
        for (int i = 0; i < 16; ++i) {
            fStateL[i] = 0.0f;
            fStateR[i] = 0.0f;
            fOutStateL[i] = 0.0f;
            fOutStateR[i] = 0.0f;
        }
        fLastOutL = 0.0f;
        fLastOutR = 0.0f;
        fRampPhase = 0.0f;
        fSmoothFreq = 500.0f;
        fSmoothLfo = 0.0f;
        fRandomTarget = 0.5f;
        fRandomCurrent = 0.5f;
    }

    void initParameter(uint32_t index, Parameter& parameter) override {
        parameter.hints = kParameterIsAutomatable;
        switch(index) {
            case pMix:
                parameter.name = "Mix";
                parameter.symbol = "mix";
                parameter.ranges.def = 0.5f;
                parameter.ranges.min = 0.0f;
                parameter.ranges.max = 1.0f;
                break;
            case pRate:
                parameter.name = "Rate";
                parameter.symbol = "rate";
                parameter.unit = "Hz";
                parameter.ranges.def = 0.5f;
                parameter.ranges.min = 0.05f;
                parameter.ranges.max = 10.0f;
                break;
            case pDepth:
                parameter.name = "Depth";
                parameter.symbol = "depth";
                parameter.ranges.def = 0.7f;
                parameter.ranges.min = 0.0f;
                parameter.ranges.max = 1.0f;
                break;
            case pWaveform:
                parameter.name = "Waveform";
                parameter.symbol = "waveform";
                parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
                parameter.ranges.def = 0.0f;
                parameter.ranges.min = 0.0f;
                parameter.ranges.max = 5.0f;
                break;
            case pStages:
                parameter.name = "Stages";
                parameter.symbol = "stages";
                parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
                parameter.ranges.def = 4.0f;
                parameter.ranges.min = 2.0f;
                parameter.ranges.max = 6.0f;
                break;
            case pFeedback:
                parameter.name = "Feedback";
                parameter.symbol = "feedback";
                parameter.ranges.def = 0.3f;
                parameter.ranges.min = -0.95f;
                parameter.ranges.max = 0.95f;
                break;
            case pRamp:
                parameter.name = "Ramp";
                parameter.symbol = "ramp";
                parameter.ranges.def = 0.0f;
                parameter.ranges.min = 0.0f;
                parameter.ranges.max = 1.0f;
                break;
            case pTone:
                parameter.name = "Tone";
                parameter.symbol = "tone";
                parameter.ranges.def = 0.5f;
                parameter.ranges.min = 0.0f;
                parameter.ranges.max = 1.0f;
                break;
        }
    }

    float getParameterValue(uint32_t index) const override { return fParams[index]; }
    void setParameterValue(uint32_t index, float value) override { fParams[index] = value; }

    void run(const float** inputs, float** outputs, uint32_t frames) override {
        const float* inL = inputs[0];
        const float* inR = inputs[1];
        float* outL = outputs[0];
        float* outR = outputs[1];

        float mix = fParams[pMix];
        float rate = fParams[pRate];
        float depth = fParams[pDepth];
        int waveform = (int)(fParams[pWaveform] + 0.5f);
        int stages = (int)(fParams[pStages] + 0.5f);
        if (stages < 2) stages = 2;
        if (stages > 6) stages = 6;
        int numAllpass = stages * 2;

        float feedback = fParams[pFeedback];
        float ramp = fParams[pRamp];
        float tone = fParams[pTone];

        // Ramp calculations
        float rampModVal = 1.0f;
        if (ramp > 0.001f) {
            float rampFreq = 0.05f + ramp * 1.95f;
            fRampPhase += (rampFreq * frames) / fSampleRate;
            if (fRampPhase >= 1.0f) fRampPhase -= 1.0f;
            rampModVal = (fRampPhase < 0.5f) ? (fRampPhase * 2.0f) : ((1.0f - fRampPhase) * 2.0f);
        } else {
            fRampPhase = 0.0f;
        }

        float effectiveDepth = depth * (0.1f + 0.9f * rampModVal);
        float lfoInc = rate / fSampleRate;

        // Expanded frequency range mapped to Tone
        float baseMinFreq = 30.0f + tone * 120.0f;
        float baseMaxFreq = 300.0f + tone * 5200.0f;

        for (uint32_t i = 0; i < frames; ++i) {
            fPhase += lfoInc;
            if (fPhase >= 1.0f) {
                fPhase -= 1.0f;
                if (waveform == 5) { // Random (Sample and Hold per cycle)
                    fRandomCurrent = fRandomTarget;
                    fRandomTarget = (float)std::rand() / (float)RAND_MAX;
                }
            }

            float rawLfo = 0.0f;
            switch (waveform) {
                case 0: // Sine
                    rawLfo = 0.5f - 0.5f * std::cos(fPhase * 6.2831853f);
                    break;
                case 1: // Triangle
                    rawLfo = (fPhase < 0.5f) ? (fPhase * 2.0f) : ((1.0f - fPhase) * 2.0f);
                    break;
                case 2: // Square
                    rawLfo = (fPhase < 0.5f) ? 0.0f : 1.0f;
                    break;
                case 3: // Ramp Up (Sawtooth)
                    rawLfo = fPhase;
                    break;
                case 4: // Ramp Down (Reverse Sawtooth)
                    rawLfo = 1.0f - fPhase;
                    break;
                case 5: // Random (Sample and Hold interpolated smoothly)
                    rawLfo = fRandomCurrent + (fRandomTarget - fRandomCurrent) * fPhase;
                    break;
            }

            // Tailored smoothing per waveform to maintain sharpness for continuous shapes and completely banish clicks for square/random steps
            float smoothingFactor = (waveform == 2 || waveform == 5) ? 0.02f : 0.45f;
            fSmoothLfo += (rawLfo - fSmoothLfo) * smoothingFactor;

            float targetFreq = baseMinFreq + fSmoothLfo * effectiveDepth * (baseMaxFreq - baseMinFreq);
            if (targetFreq < 20.0f) targetFreq = 20.0f;
            if (targetFreq > fSampleRate * 0.45f) targetFreq = fSampleRate * 0.45f;

            fSmoothFreq += (targetFreq - fSmoothFreq) * 0.1f;

            float g = std::tan(3.14159265f * fSmoothFreq / fSampleRate);
            float coeff = (g - 1.0f) / (g + 1.0f);

            float inSampleL = inL[i];
            float inSampleR = inR[i];

            float fbL = std::max(-0.95f, std::min(0.95f, fLastOutL * feedback));
            float fbR = std::max(-0.95f, std::min(0.95f, fLastOutR * feedback));

            float xL = inSampleL + fbL;
            float xR = inSampleR + fbR;

            for (int s = 0; s < numAllpass; ++s) {
                float yL = coeff * xL + fStateL[s] - coeff * fOutStateL[s];
                fStateL[s] = xL;
                fOutStateL[s] = yL;
                xL = yL;

                float yR = coeff * xR + fStateR[s] - coeff * fOutStateR[s];
                fStateR[s] = xR;
                fOutStateR[s] = yR;
                xR = yR;
            }

            if (std::isnan(xL) || std::isinf(xL)) { xL = inSampleL; clearBuffers(); }
            if (std::isnan(xR) || std::isinf(xR)) { xR = inSampleR; clearBuffers(); }

            fLastOutL = xL;
            fLastOutR = xR;

            outL[i] = inSampleL * (1.0f - mix) + xL * mix;
            outR[i] = inSampleR * (1.0f - mix) + xR * mix;
        }
    }

private:
    float fParams[kParameterCount];
    float fSampleRate;
    float fPhase;
    float fRampPhase;
    float fSmoothFreq;
    float fSmoothLfo;
    float fRandomTarget;
    float fRandomCurrent;
    float fStateL[16];
    float fStateR[16];
    float fOutStateL[16];
    float fOutStateR[16];
    float fLastOutL;
    float fLastOutR;

    DISTRHO_DECLARE_NON_COPYABLE(WombtonePlugin)
};

Plugin* createPlugin() { return new WombtonePlugin(); }

END_NAMESPACE_DISTRHO
endef

define WOMP_PLUGIN_MAKEFILE
#!/usr/bin/make -f
NAME      = wombtone
FILES_DSP = Plugin.cpp
include ../../Makefile.plugins.mk
TARGETS = lv2_dsp
all: $(TARGETS)
endef

define WOMP_MANIFEST_TTL
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone>
    a lv2:Plugin ;
    lv2:binary <wombtone_dsp.so> ;
    rdfs:seeAlso <wombtone.ttl> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-classic-sweep>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:seeAlso <classic-sweep.ttl> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-vortex-resonance>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:seeAlso <vortex-resonance.ttl> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-deep-phase>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:seeAlso <deep-phase.ttl> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-step-filter>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:seeAlso <step-filter.ttl> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-phaser-drone>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:seeAlso <phaser-drone.ttl> .
endef

define WOMP_PLUGIN_TTL
@prefix lv2:   <http://lv2plug.in/ns/lv2core#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix doap:  <http://usefulinc.com/ns/doap#> .
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
@prefix pset:  <http://lv2plug.in/ns/ext/presets#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone>
    a lv2:Plugin ;
    doap:name "Chase Bliss Audio Wombtone MK II" ;
    doap:license <https://opensource.org/licenses/MIT> ;
    lv2:project <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    lv2:optionalFeature lv2:hardRTCapable ;
    lv2:port
    [
        a lv2:InputPort, lv2:AudioPort ;
        lv2:index 0 ;
        lv2:symbol "audio_in_l" ;
        lv2:name "Audio Input L" ;
    ] ,
    [
        a lv2:InputPort, lv2:AudioPort ;
        lv2:index 1 ;
        lv2:symbol "audio_in_r" ;
        lv2:name "Audio Input R" ;
    ] ,
    [
        a lv2:OutputPort, lv2:AudioPort ;
        lv2:index 2 ;
        lv2:symbol "audio_out_l" ;
        lv2:name "Audio Output L" ;
    ] ,
    [
        a lv2:OutputPort, lv2:AudioPort ;
        lv2:index 3 ;
        lv2:symbol "audio_out_r" ;
        lv2:name "Audio Output R" ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 4 ;
        lv2:symbol "mix" ;
        lv2:name "Mix" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 5 ;
        lv2:symbol "rate" ;
        lv2:name "Rate" ;
        lv2:default 0.5 ;
        lv2:minimum 0.05 ;
        lv2:maximum 10.0 ;
        units:unit units:hz ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 6 ;
        lv2:symbol "depth" ;
        lv2:name "Depth" ;
        lv2:default 0.7 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 7 ;
        lv2:symbol "waveform" ;
        lv2:name "Waveform" ;
        lv2:default 0 ;
        lv2:minimum 0 ;
        lv2:maximum 5 ;
        lv2:portProperty lv2:enumeration ;
        lv2:scalePoint [ rdfs:label "Sine" ; rdf:value 0 ] ;
        lv2:scalePoint [ rdfs:label "Triangle" ; rdf:value 1 ] ;
        lv2:scalePoint [ rdfs:label "Square" ; rdf:value 2 ] ;
        lv2:scalePoint [ rdfs:label "Ramp Up" ; rdf:value 3 ] ;
        lv2:scalePoint [ rdfs:label "Ramp Down" ; rdf:value 4 ] ;
        lv2:scalePoint [ rdfs:label "Random" ; rdf:value 5 ] ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 8 ;
        lv2:symbol "stages" ;
        lv2:name "Stages" ;
        lv2:default 4 ;
        lv2:minimum 2 ;
        lv2:maximum 6 ;
        lv2:portProperty lv2:integer ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 9 ;
        lv2:symbol "feedback" ;
        lv2:name "Feedback" ;
        lv2:default 0.3 ;
        lv2:minimum -0.95 ;
        lv2:maximum 0.95 ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 10 ;
        lv2:symbol "ramp" ;
        lv2:name "Ramp" ;
        lv2:default 0.0 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort, lv2:ControlPort ;
        lv2:index 11 ;
        lv2:symbol "tone" ;
        lv2:name "Tone" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] .
endef

define WOMP_PRESET_1
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-classic-sweep>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:label "Classic Sweep" ;
    lv2:port
    [ lv2:symbol "mix" ; pset:value 0.5 ] ,
    [ lv2:symbol "rate" ; pset:value 0.4 ] ,
    [ lv2:symbol "depth" ; pset:value 0.7 ] ,
    [ lv2:symbol "waveform" ; pset:value 0 ] ,
    [ lv2:symbol "stages" ; pset:value 4 ] ,
    [ lv2:symbol "feedback" ; pset:value 0.3 ] ,
    [ lv2:symbol "ramp" ; pset:value 0.0 ] ,
    [ lv2:symbol "tone" ; pset:value 0.5 ] .
endef

define WOMP_PRESET_2
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-vortex-resonance>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:label "Vortex Resonance" ;
    lv2:port
    [ lv2:symbol "mix" ; pset:value 0.7 ] ,
    [ lv2:symbol "rate" ; pset:value 1.2 ] ,
    [ lv2:symbol "depth" ; pset:value 0.9 ] ,
    [ lv2:symbol "waveform" ; pset:value 1 ] ,
    [ lv2:symbol "stages" ; pset:value 6 ] ,
    [ lv2:symbol "feedback" ; pset:value 0.75 ] ,
    [ lv2:symbol "ramp" ; pset:value 0.2 ] ,
    [ lv2:symbol "tone" ; pset:value 0.8 ] .
endef

define WOMP_PRESET_3
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-deep-phase>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:label "Deep Phase" ;
    lv2:port
    [ lv2:symbol "mix" ; pset:value 0.6 ] ,
    [ lv2:symbol "rate" ; pset:value 0.2 ] ,
    [ lv2:symbol "depth" ; pset:value 1.0 ] ,
    [ lv2:symbol "waveform" ; pset:value 0 ] ,
    [ lv2:symbol "stages" ; pset:value 4 ] ,
    [ lv2:symbol "feedback" ; pset:value -0.6 ] ,
    [ lv2:symbol "ramp" ; pset:value 0.0 ] ,
    [ lv2:symbol "tone" ; pset:value 0.3 ] .
endef

define WOMP_PRESET_4
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-step-filter>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:label "Step Filter Sweep" ;
    lv2:port
    [ lv2:symbol "mix" ; pset:value 0.7 ] ,
    [ lv2:symbol "rate" ; pset:value 2.5 ] ,
    [ lv2:symbol "depth" ; pset:value 0.8 ] ,
    [ lv2:symbol "waveform" ; pset:value 2 ] ,
    [ lv2:symbol "stages" ; pset:value 4 ] ,
    [ lv2:symbol "feedback" ; pset:value 0.4 ] ,
    [ lv2:symbol "ramp" ; pset:value 0.5 ] ,
    [ lv2:symbol "tone" ; pset:value 0.6 ] .
endef

define WOMP_PRESET_5
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://github.com/austin-dsp/lv2-plugins/wombtone#preset-phaser-drone>
    a pset:Preset ;
    lv2:appliesTo <https://github.com/austin-dsp/lv2-plugins/wombtone> ;
    rdfs:label "Phaser Drone" ;
    lv2:port
    [ lv2:symbol "mix" ; pset:value 0.8 ] ,
    [ lv2:symbol "rate" ; pset:value 0.05 ] ,
    [ lv2:symbol "depth" ; pset:value 0.5 ] ,
    [ lv2:symbol "waveform" ; pset:value 0 ] ,
    [ lv2:symbol "stages" ; pset:value 6 ] ,
    [ lv2:symbol "feedback" ; pset:value 0.6 ] ,
    [ lv2:symbol "ramp" ; pset:value 0.0 ] ,
    [ lv2:symbol "tone" ; pset:value 0.7 ] .
endef

export WOMP_PLUGIN_INFO_H
export WOMP_PLUGIN_CPP
export WOMP_PLUGIN_MAKEFILE
export WOMP_MANIFEST_TTL
export WOMP_PLUGIN_TTL
export WOMP_PRESET_1
export WOMP_PRESET_2
export WOMP_PRESET_3
export WOMP_PRESET_4
export WOMP_PRESET_5

define WOMP_CONFIGURE_CMDS
	mkdir -p $(@D)/examples/wombtone
	printf '%s' "$$WOMP_PLUGIN_INFO_H" > $(@D)/examples/wombtone/DistrhoPluginInfo.h
	printf '%s' "$$WOMP_PLUGIN_CPP" > $(@D)/examples/wombtone/Plugin.cpp
	printf '%s' "$$WOMP_PLUGIN_MAKEFILE" > $(@D)/examples/wombtone/Makefile
endef

define WOMP_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) NOOPT=true -C $(@D)/examples/wombtone lv2_dsp
endef

define WOMP_INSTALL_TARGET_CMDS
	mkdir -p $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2
	cp $(@D)/bin/wombtone.lv2/wombtone_dsp.so $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/
	printf '%s' "$$WOMP_MANIFEST_TTL" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/manifest.ttl
	printf '%s' "$$WOMP_PLUGIN_TTL" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/wombtone.ttl
	printf '%s' "$$WOMP_PRESET_1" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/classic-sweep.ttl
	printf '%s' "$$WOMP_PRESET_2" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/vortex-resonance.ttl
	printf '%s' "$$WOMP_PRESET_3" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/deep-phase.ttl
	printf '%s' "$$WOMP_PRESET_4" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/step-filter.ttl
	printf '%s' "$$WOMP_PRESET_5" > $(TARGET_DIR)/usr/lib/lv2/wombtone.lv2/phaser-drone.ttl
endef

$(eval $(generic-package))