################################################################################
#
# BIGMUFF_GERMANIUM4
#
# LV2 plugin built from the MOD Audio Cookbook workflow: DPF source is embedded
# below and compiled against a pinned DPF checkout, producing an .lv2 bundle
# that the builder.mod.audio cloud builder can compile and package for the
# MOD Dwarf.
#
################################################################################

BIGMUFF_GERMANIUM4_VERSION = 61d38eb638449647fb8395a35c5b8dab7e981ba7
BIGMUFF_GERMANIUM4_SITE = https://github.com/DISTRHO/DPF.git
BIGMUFF_GERMANIUM4_SITE_METHOD = git
BIGMUFF_GERMANIUM4_GIT_SUBMODULES = YES
BIGMUFF_GERMANIUM4_INSTALL_STAGING = NO
BIGMUFF_GERMANIUM4_BUNDLES = bigmuff-germanium4.lv2

define BIGMUFF_GERMANIUM4_PLUGIN_CPP
#include "DistrhoPlugin.hpp"
#include <cmath>

// ---- Shared Big Muff DSP core (identical across all variant plugins) ----
#include <cmath>

// One-pole highpass (models an input/interstage coupling capacitor)
class OnePoleHP {
public:
    void setup(float sr, float fc) {
        const float x = expf(-2.0f * (float)M_PI * fc / sr);
        a1 = x; b0 = (1.0f + x) * 0.5f; b1 = -(1.0f + x) * 0.5f;
    }
    inline float process(float in) {
        const float out = b0 * in + b1 * xz1 + a1 * yz1;
        xz1 = in; yz1 = out;
        return out;
    }
    void reset() { xz1 = 0.f; yz1 = 0.f; }
private:
    float a1 = 0.f, b0 = 1.f, b1 = 0.f;
    float xz1 = 0.f, yz1 = 0.f;
};

// One-pole lowpass (models a Miller / feedback capacitor limiting stage bandwidth)
class OnePoleLP {
public:
    void setup(float sr, float fc) {
        a = 1.0f - expf(-2.0f * (float)M_PI * fc / sr);
    }
    inline float process(float in) {
        yz1 += a * (in - yz1);
        return yz1;
    }
    void reset() { yz1 = 0.f; }
private:
    float a = 1.f;
    float yz1 = 0.f;
};

// Simple one-pole peaking (parametric) filter used for the Deluxe MIDS EQ section
class PeakingEQ {
public:
    void setup(float sr, float fc, float gainDb, float q) {
        const float A = powf(10.0f, gainDb / 40.0f);
        const float w0 = 2.0f * (float)M_PI * fc / sr;
        const float alpha = sinf(w0) / (2.0f * q);
        const float cosw0 = cosf(w0);
        const float b0 =  1.0f + alpha * A;
        const float b1 = -2.0f * cosw0;
        const float b2 =  1.0f - alpha * A;
        const float a0 =  1.0f + alpha / A;
        const float a1 = -2.0f * cosw0;
        const float a2 =  1.0f - alpha / A;
        nb0 = b0 / a0; nb1 = b1 / a0; nb2 = b2 / a0;
        na1 = a1 / a0; na2 = a2 / a0;
    }
    inline float process(float in) {
        const float out = nb0 * in + nb1 * x1 + nb2 * x2 - na1 * y1 - na2 * y2;
        x2 = x1; x1 = in; y2 = y1; y1 = out;
        return out;
    }
    void reset() { x1 = x2 = y1 = y2 = 0.f; }
private:
    float nb0 = 1.f, nb1 = 0.f, nb2 = 0.f, na1 = 0.f, na2 = 0.f;
    float x1 = 0.f, x2 = 0.f, y1 = 0.f, y2 = 0.f;
};

// Soft clipper approximating a back-to-back diode pair to ground in the transistor's
// feedback loop. vfPos/vfNeg set how much drive is needed before the knee saturates
// (silicon ~0.6V needs more drive than germanium ~0.3V), and hardness sets the knee
// steepness. The output always saturates toward +/-1 (full scale) once driven hard,
// matching how a real clipping stage is run well past its threshold in normal use.
static inline float diodeClip(float x, float vfPos, float vfNeg, float hardness) {
    const float xp = x >= 0.f ? x : -x;
    const float vf = x >= 0.f ? vfPos : vfNeg;
    const float driven = xp * hardness / vf;
    const float shaped = tanhf(driven);
    return x >= 0.f ? shaped : -shaped;
}

// One transistor common-emitter clipping stage: gain -> bandwidth-limit -> diode clip
class ClipStage {
public:
    void setup(float sr, float fcLowpass) { lp.setup(sr, fcLowpass); }
    inline float process(float in, float gain, float vfPos, float vfNeg, float hardness) {
        const float driven = lp.process(in * gain);
        return diodeClip(driven, vfPos, vfNeg, hardness);
    }
    void reset() { lp.reset(); }
private:
    OnePoleLP lp;
};

// The classic Big Muff passive "scoop" tone stack: crossfade between a lowpass path
// (bass side of the pot) and a highpass path (treble side), with scoopDepth controlling
// how deep the mid notch is (a shallower depth blends some of the dry mid content back in,
// matching the "less scooped" character of e.g. Civil War / op-amp variants).
class ToneStack {
public:
    void setup(float sr, float fcLow, float fcHigh) {
        lp.setup(sr, fcLow);
        hp.setup(sr, fcHigh);
    }
    inline float process(float in, float tonePot, float scoopDepth) {
        const float lo = lp.process(in);
        const float hi = hp.process(in);
        const float scooped = tonePot * hi + (1.0f - tonePot) * lo;
        return scoopDepth * scooped + (1.0f - scoopDepth) * in;
    }
    void reset() { lp.reset(); hp.reset(); }
private:
    OnePoleLP lp;
    OnePoleHP hp;
};

// Simple RMS-ish envelope follower, used for noise gates and the Deluxe Attack circuit
class EnvFollower {
public:
    void setup(float sr, float attackMs, float releaseMs) {
        aCoef = expf(-1.0f / (0.001f * attackMs * sr));
        rCoef = expf(-1.0f / (0.001f * releaseMs * sr));
    }
    inline float process(float in) {
        const float rectified = in >= 0.f ? in : -in;
        const float coef = rectified > env ? aCoef : rCoef;
        env = coef * env + (1.0f - coef) * rectified;
        return env;
    }
    void reset() { env = 0.f; }
private:
    float aCoef = 0.f, rCoef = 0.f, env = 0.f;
};

START_NAMESPACE_DISTRHO

// Circuit: Germanium 4 Big Muff Pi
// Independent stackable Distortion and Overdrive sections, each with 2 germanium transistors.
// Two independent germanium clipping sections (2 transistors each per the manual),
// each with its own footswitch-style on/off, Gain and Bias. DISTORTION additionally
// has a Volts control (emulating a starved/sagging supply -> lower clip ceiling and
// extra compression as the knob is lowered); OVERDRIVE has a single-knob Tone instead.
// When both sides are engaged, DISTORTION precedes OVERDRIVE in the chain, matching
// the documented signal order.
class BigMuffGermanium4 : public Plugin {
public:
    BigMuffGermanium4()
        : Plugin(10, 0, 0)
    {
        sampleRateChanged(getSampleRate());
    }

protected:
    const char* getLabel() const override { return "BMGe4"; }
    const char* getDescription() const override { return "Germanium 4 Big Muff Pi - MOD Audio Cookbook"; }
    const char* getMaker() const override { return "MODAudioCookbook"; }
    const char* getLicense() const override { return "ISC"; }
    uint32_t getVersion() const override { return d_version(1, 0, 0); }
    int64_t getUniqueId() const override { return d_cconst('B','M','G','4'); }

    void initParameter(uint32_t index, Parameter& parameter) override {
        switch (index) {
        case 0: parameter.hints = kParameterIsAutomatable; parameter.name = "Dist Gain";   parameter.symbol = "dist_gain";   parameter.ranges.def = 0.5f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 1: parameter.hints = kParameterIsAutomatable; parameter.name = "Dist Bias";   parameter.symbol = "dist_bias";   parameter.ranges.def = 0.5f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 2: parameter.hints = kParameterIsAutomatable; parameter.name = "Dist Volts";  parameter.symbol = "dist_volts";  parameter.ranges.def = 1.0f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 3: parameter.hints = kParameterIsAutomatable; parameter.name = "Dist Volume"; parameter.symbol = "dist_volume"; parameter.ranges.def = 0.6f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 4: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "Dist On"; parameter.symbol = "dist_on"; parameter.ranges.def = 1.0f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 5: parameter.hints = kParameterIsAutomatable; parameter.name = "OD Gain";    parameter.symbol = "od_gain";    parameter.ranges.def = 0.5f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 6: parameter.hints = kParameterIsAutomatable; parameter.name = "OD Bias";    parameter.symbol = "od_bias";    parameter.ranges.def = 0.5f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 7: parameter.hints = kParameterIsAutomatable; parameter.name = "OD Tone";    parameter.symbol = "od_tone";    parameter.ranges.def = 0.5f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 8: parameter.hints = kParameterIsAutomatable; parameter.name = "OD Volume";  parameter.symbol = "od_volume";  parameter.ranges.def = 0.6f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        case 9: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "OD On"; parameter.symbol = "od_on"; parameter.ranges.def = 1.0f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; break;
        }
    }

    float getParameterValue(uint32_t index) const override { return params[index]; }
    void  setParameterValue(uint32_t index, float value) override { params[index] = value; }

    void sampleRateChanged(double newSampleRate) override {
        const float sr = (float)newSampleRate;
        hpDist.setup(sr, 50.0f);
        clipDist1.setup(sr, 4200.0f);
        clipDist2.setup(sr, 4000.0f);
        hpOd.setup(sr, 60.0f);
        clipOd1.setup(sr, 5000.0f);
        odTone.setup(sr, 500.0f, 2500.0f);
    }

    void activate() override {
        hpDist.reset(); clipDist1.reset(); clipDist2.reset();
        hpOd.reset(); clipOd1.reset(); odTone.reset();
    }

    void run(const float** inputs, float** outputs, uint32_t frames) override {
        const float distGain   = params[0];
        const float distBias   = params[1];
        const float distVolts  = params[2];
        const float distVolume = params[3];
        const bool  distOn     = params[4] > 0.5f;
        const float odGain     = params[5];
        const float odBias     = params[6];
        const float odTone_    = params[7];
        const float odVolume   = params[8];
        const bool  odOn       = params[9] > 0.5f;

        // Bias shifts the effective clip ceiling asymmetry (germanium bias drift);
        // Volts scales the ceiling down and softens the knee as the knob is lowered,
        // emulating a starved/sagging supply.
        const float distVfPos = 0.20f + distVolts * 0.16f;
        const float distVfNeg = distVfPos * (0.7f + distBias * 0.6f);
        const float distHardness = 1.1f + (1.0f - distVolts) * 0.9f;
        const float distG1 = 2.0f + distGain * 7.0f;
        const float distG2 = 2.0f + distGain * 7.5f;

        const float odVfPos = 0.28f;
        const float odVfNeg = odVfPos * (0.7f + odBias * 0.6f);
        const float odG1 = 1.5f + odGain * 5.0f;

        for (uint32_t i = 0; i < frames; ++i) {
            float x = inputs[0][i];

            if (distOn) {
                float d = hpDist.process(x);
                float d1 = clipDist1.process(d, distG1, distVfPos, distVfNeg, distHardness);
                float d2 = clipDist2.process(d1, distG2, distVfPos, distVfNeg, distHardness);
                x = d2 * distVolume * 1.2f;
            }

            if (odOn) {
                float o = hpOd.process(x);
                float o1 = clipOd1.process(o, odG1, odVfPos, odVfNeg, 1.2f);
                float toned = odTone.process(o1, odTone_, 0.6f);
                x = toned * odVolume * 1.2f;
            }

            outputs[0][i] = x;
        }
    }

private:
    float params[10] = {0.5f, 0.5f, 1.0f, 0.6f, 1.0f, 0.5f, 0.5f, 0.5f, 0.6f, 1.0f};
    OnePoleHP hpDist, hpOd;
    ClipStage clipDist1, clipDist2, clipOd1;
    ToneStack odTone;

    BigMuffGermanium4(const BigMuffGermanium4&) = delete;
    BigMuffGermanium4& operator=(const BigMuffGermanium4&) = delete;
};

Plugin* createPlugin() { return new BigMuffGermanium4(); }

END_NAMESPACE_DISTRHO

endef
export BIGMUFF_GERMANIUM4_PLUGIN_CPP

define BIGMUFF_GERMANIUM4_PLUGIN_INFO_H
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED

#define DISTRHO_PLUGIN_BRAND   "MODAudioCookbook"
#define DISTRHO_PLUGIN_NAME    "Germanium 4 Big Muff Pi"
#define DISTRHO_PLUGIN_URI     "https://mod.audio/cookbook/bigmuff/germanium4"
#define DISTRHO_PLUGIN_NUM_INPUTS  1
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1
#define DISTRHO_PLUGIN_IS_RT_SAFE  1
#define DISTRHO_PLUGIN_WANT_STATE 0
#define DISTRHO_PLUGIN_HAS_UI     0

#endif

endef
export BIGMUFF_GERMANIUM4_PLUGIN_INFO_H

define BIGMUFF_GERMANIUM4_PLUGIN_TTL
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://mod.audio/cookbook/bigmuff/germanium4>
    a lv2:Plugin , lv2:DistortionPlugin ;
    doap:name "Germanium 4 Big Muff Pi" ;
    doap:license <http://opensource.org/licenses/isc> ;
    lv2:project <https://mod.audio/cookbook/bigmuff/germanium4> ;
    lv2:optionalFeature lv2:hardRTCapable ;
    lv2:port
    [
        a lv2:AudioPort , lv2:InputPort ;
        lv2:index 0 ;
        lv2:symbol "in" ;
        lv2:name "In" ;
    ] ,
    [
        a lv2:AudioPort , lv2:OutputPort ;
        lv2:index 1 ;
        lv2:symbol "out" ;
        lv2:name "Out" ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 2 ;
        lv2:symbol "dist_gain" ;
        lv2:name "DistGain" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 3 ;
        lv2:symbol "dist_bias" ;
        lv2:name "DistBias" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 4 ;
        lv2:symbol "dist_volts" ;
        lv2:name "DistVolts" ;
        lv2:default 1.0 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 5 ;
        lv2:symbol "dist_volume" ;
        lv2:name "DistVolume" ;
        lv2:default 0.6 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 6 ;
        lv2:symbol "dist_on" ;
        lv2:name "DistOn" ;
        lv2:default 1.0 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
        lv2:portProperty lv2:toggled ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 7 ;
        lv2:symbol "od_gain" ;
        lv2:name "ODGain" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 8 ;
        lv2:symbol "od_bias" ;
        lv2:name "ODBias" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 9 ;
        lv2:symbol "od_tone" ;
        lv2:name "ODTone" ;
        lv2:default 0.5 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 10 ;
        lv2:symbol "od_volume" ;
        lv2:name "ODVolume" ;
        lv2:default 0.6 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
    ] ,
    [
        a lv2:InputPort , lv2:ControlPort ;
        lv2:index 11 ;
        lv2:symbol "od_on" ;
        lv2:name "ODOn" ;
        lv2:default 1.0 ;
        lv2:minimum 0.0 ;
        lv2:maximum 1.0 ;
        lv2:portProperty lv2:toggled ;
    ] .

endef
export BIGMUFF_GERMANIUM4_PLUGIN_TTL

define BIGMUFF_GERMANIUM4_MANIFEST_TTL
@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://mod.audio/cookbook/bigmuff/germanium4>
    a lv2:Plugin ;
    lv2:binary <bigmuff-germanium4_dsp.so> ;
    rdfs:seeAlso <bigmuff-germanium4.ttl> .

<https://mod.audio/cookbook/bigmuff/germanium4#preset-clean-boost>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Clean Boost" ;
    rdfs:seeAlso <presets/clean-boost.ttl> .

<https://mod.audio/cookbook/bigmuff/germanium4#preset-classic-muff>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Classic Muff" ;
    rdfs:seeAlso <presets/classic-muff.ttl> .

<https://mod.audio/cookbook/bigmuff/germanium4#preset-full-sustain>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Full Sustain" ;
    rdfs:seeAlso <presets/full-sustain.ttl> .

<https://mod.audio/cookbook/bigmuff/germanium4#preset-scooped-lead>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Scooped Lead" ;
    rdfs:seeAlso <presets/scooped-lead.ttl> .

<https://mod.audio/cookbook/bigmuff/germanium4#preset-bright-rasp>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Bright Rasp" ;
    rdfs:seeAlso <presets/bright-rasp.ttl> .

endef
export BIGMUFF_GERMANIUM4_MANIFEST_TTL

define BIGMUFF_GERMANIUM4_PLUGIN_MAKEFILE
#!/usr/bin/make -f
# Makefile for bigmuff-germanium4 (MOD Audio Cookbook / DPF) #
# ------------------------------------------------ #

include ../../Makefile.base.mk

NAME = bigmuff-germanium4

all: lv2_dsp

BUILD_DIR = ../../build/bigmuff-germanium4

FILES_DSP = \
	DistrhoPluginBigMuffGermanium4.cpp

include ../../Makefile.plugins.mk

TARGETS += lv2_dsp

all: $(TARGETS)

endef
export BIGMUFF_GERMANIUM4_PLUGIN_MAKEFILE

define BIGMUFF_GERMANIUM4_PRESET_CLEAN_BOOST_TTL
@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://mod.audio/cookbook/bigmuff/germanium4#preset-clean-boost>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Clean Boost" ;
    lv2:port
        [ lv2:symbol "dist_gain" ; pset:value 0.15 ] ,
        [ lv2:symbol "dist_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_volts" ; pset:value 1.0 ] ,
        [ lv2:symbol "dist_volume" ; pset:value 0.55 ] ,
        [ lv2:symbol "dist_on" ; pset:value 1.0 ] ,
        [ lv2:symbol "od_gain" ; pset:value 0.12 ] ,
        [ lv2:symbol "od_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_tone" ; pset:value 0.55 ] ,
        [ lv2:symbol "od_volume" ; pset:value 0.55 ] ,
        [ lv2:symbol "od_on" ; pset:value 1.0 ] .

endef
export BIGMUFF_GERMANIUM4_PRESET_CLEAN_BOOST_TTL

define BIGMUFF_GERMANIUM4_PRESET_CLASSIC_MUFF_TTL
@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://mod.audio/cookbook/bigmuff/germanium4#preset-classic-muff>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Classic Muff" ;
    lv2:port
        [ lv2:symbol "dist_gain" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_volts" ; pset:value 1.0 ] ,
        [ lv2:symbol "dist_volume" ; pset:value 0.7 ] ,
        [ lv2:symbol "dist_on" ; pset:value 1.0 ] ,
        [ lv2:symbol "od_gain" ; pset:value 0.4 ] ,
        [ lv2:symbol "od_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_tone" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_volume" ; pset:value 0.7 ] ,
        [ lv2:symbol "od_on" ; pset:value 1.0 ] .

endef
export BIGMUFF_GERMANIUM4_PRESET_CLASSIC_MUFF_TTL

define BIGMUFF_GERMANIUM4_PRESET_FULL_SUSTAIN_TTL
@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://mod.audio/cookbook/bigmuff/germanium4#preset-full-sustain>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Full Sustain" ;
    lv2:port
        [ lv2:symbol "dist_gain" ; pset:value 0.95 ] ,
        [ lv2:symbol "dist_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_volts" ; pset:value 1.0 ] ,
        [ lv2:symbol "dist_volume" ; pset:value 0.8 ] ,
        [ lv2:symbol "dist_on" ; pset:value 1.0 ] ,
        [ lv2:symbol "od_gain" ; pset:value 0.76 ] ,
        [ lv2:symbol "od_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_tone" ; pset:value 0.45 ] ,
        [ lv2:symbol "od_volume" ; pset:value 0.8 ] ,
        [ lv2:symbol "od_on" ; pset:value 1.0 ] .

endef
export BIGMUFF_GERMANIUM4_PRESET_FULL_SUSTAIN_TTL

define BIGMUFF_GERMANIUM4_PRESET_SCOOPED_LEAD_TTL
@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://mod.audio/cookbook/bigmuff/germanium4#preset-scooped-lead>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Scooped Lead" ;
    lv2:port
        [ lv2:symbol "dist_gain" ; pset:value 0.75 ] ,
        [ lv2:symbol "dist_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_volts" ; pset:value 1.0 ] ,
        [ lv2:symbol "dist_volume" ; pset:value 0.75 ] ,
        [ lv2:symbol "dist_on" ; pset:value 1.0 ] ,
        [ lv2:symbol "od_gain" ; pset:value 0.6 ] ,
        [ lv2:symbol "od_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_tone" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_volume" ; pset:value 0.75 ] ,
        [ lv2:symbol "od_on" ; pset:value 1.0 ] .

endef
export BIGMUFF_GERMANIUM4_PRESET_SCOOPED_LEAD_TTL

define BIGMUFF_GERMANIUM4_PRESET_BRIGHT_RASP_TTL
@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://mod.audio/cookbook/bigmuff/germanium4#preset-bright-rasp>
    a pset:Preset ;
    lv2:appliesTo <https://mod.audio/cookbook/bigmuff/germanium4> ;
    rdfs:label "Bright Rasp" ;
    lv2:port
        [ lv2:symbol "dist_gain" ; pset:value 0.8 ] ,
        [ lv2:symbol "dist_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "dist_volts" ; pset:value 1.0 ] ,
        [ lv2:symbol "dist_volume" ; pset:value 0.65 ] ,
        [ lv2:symbol "dist_on" ; pset:value 1.0 ] ,
        [ lv2:symbol "od_gain" ; pset:value 0.64 ] ,
        [ lv2:symbol "od_bias" ; pset:value 0.5 ] ,
        [ lv2:symbol "od_tone" ; pset:value 0.9 ] ,
        [ lv2:symbol "od_volume" ; pset:value 0.65 ] ,
        [ lv2:symbol "od_on" ; pset:value 1.0 ] .

endef
export BIGMUFF_GERMANIUM4_PRESET_BRIGHT_RASP_TTL


define BIGMUFF_GERMANIUM4_CONFIGURE_CMDS
	mkdir -p $(@D)/examples/bigmuff-germanium4
	mkdir -p $(@D)/examples/bigmuff-germanium4/presets
	printf '%s' "$$BIGMUFF_GERMANIUM4_PLUGIN_CPP" > $(@D)/examples/bigmuff-germanium4/DistrhoPluginBigMuffGermanium4.cpp
	printf '%s' "$$BIGMUFF_GERMANIUM4_PLUGIN_INFO_H" > $(@D)/examples/bigmuff-germanium4/DistrhoPluginInfo.h
	printf '%s' "$$BIGMUFF_GERMANIUM4_PLUGIN_TTL" > $(@D)/examples/bigmuff-germanium4/bigmuff-germanium4.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_MANIFEST_TTL" > $(@D)/examples/bigmuff-germanium4/manifest.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_PLUGIN_MAKEFILE" > $(@D)/examples/bigmuff-germanium4/Makefile
	printf '%s' "$$BIGMUFF_GERMANIUM4_PRESET_CLEAN_BOOST_TTL" > $(@D)/examples/bigmuff-germanium4/presets/clean-boost.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_PRESET_CLASSIC_MUFF_TTL" > $(@D)/examples/bigmuff-germanium4/presets/classic-muff.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_PRESET_FULL_SUSTAIN_TTL" > $(@D)/examples/bigmuff-germanium4/presets/full-sustain.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_PRESET_SCOOPED_LEAD_TTL" > $(@D)/examples/bigmuff-germanium4/presets/scooped-lead.ttl
	printf '%s' "$$BIGMUFF_GERMANIUM4_PRESET_BRIGHT_RASP_TTL" > $(@D)/examples/bigmuff-germanium4/presets/bright-rasp.ttl
endef

define BIGMUFF_GERMANIUM4_BUILD_CMDS
	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) NOOPT=true -C $(@D)/examples/bigmuff-germanium4 lv2_dsp
endef

define BIGMUFF_GERMANIUM4_INSTALL_TARGET_CMDS
	cp $(@D)/examples/bigmuff-germanium4/manifest.ttl $(@D)/bin/bigmuff-germanium4.lv2/manifest.ttl
	cp $(@D)/examples/bigmuff-germanium4/bigmuff-germanium4.ttl $(@D)/bin/bigmuff-germanium4.lv2/bigmuff-germanium4.ttl
	mkdir -p $(@D)/bin/bigmuff-germanium4.lv2/presets
	cp $(@D)/examples/bigmuff-germanium4/presets/clean-boost.ttl $(@D)/bin/bigmuff-germanium4.lv2/presets/clean-boost.ttl
	cp $(@D)/examples/bigmuff-germanium4/presets/classic-muff.ttl $(@D)/bin/bigmuff-germanium4.lv2/presets/classic-muff.ttl
	cp $(@D)/examples/bigmuff-germanium4/presets/full-sustain.ttl $(@D)/bin/bigmuff-germanium4.lv2/presets/full-sustain.ttl
	cp $(@D)/examples/bigmuff-germanium4/presets/scooped-lead.ttl $(@D)/bin/bigmuff-germanium4.lv2/presets/scooped-lead.ttl
	cp $(@D)/examples/bigmuff-germanium4/presets/bright-rasp.ttl $(@D)/bin/bigmuff-germanium4.lv2/presets/bright-rasp.ttl
	mkdir -p $(TARGET_DIR)/usr/lib/lv2
	cp -r $(@D)/bin/bigmuff-germanium4.lv2 $(TARGET_DIR)/usr/lib/lv2/
endef

$(eval $(generic-package))
