[SCM] calf/master: mono and stereo input modules new vu meter: centered style (for future phase meters)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:40:43 UTC 2013
The following commit has been merged in the master branch:
commit 4401c227d200fa8eeeef3163267b774644110e2f
Author: Markus Schmidt <schmidt at boomshop.net>
Date: Thu Dec 8 09:58:00 2011 +0100
mono and stereo input modules
new vu meter: centered style (for future phase meters)
diff --git a/gui/gui-mono.xml b/gui/gui-mono.xml
new file mode 100644
index 0000000..67bd0d8
--- /dev/null
+++ b/gui/gui-mono.xml
@@ -0,0 +1,85 @@
+<hbox spacing="5">
+ <frame label="Input" expand="1" fill="1">
+ <vbox spacing="8">
+ <table rows="1" cols="2">
+ <vumeter param="meter_in" position="2" hold="1.5" falloff="2.5" attach-x="0" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_in" attach-x="1" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+ </table>
+ <hbox spacing="8">
+ <vbox>
+ <label param="level_in" />
+ <knob param="level_in" size="3" />
+ <value param="level_in" />
+ </vbox>
+ <vbox spacing="4">
+ <vbox spacing="5">
+
+ <label param="softclip" />
+ <toggle param="softclip"/>
+ </vbox>
+ <vbox expand="0" spacing="5">
+
+ <toggle param="bypass" />
+ <label param="bypass" />
+ </vbox>
+ </vbox>
+ </hbox>
+ </vbox>
+ </frame>
+
+ <hbox>
+ <frame label="Left" expand="1" fill="1">
+ <vbox>
+ <label /><label />
+ <vbox>
+ <label param="mutel"/>
+ <toggle param="mutel"/>
+ </vbox>
+ <vbox>
+ <toggle param="phasel"/>
+ <label param="phasel"/>
+ </vbox>
+ </vbox>
+ </frame>
+ <frame label="Right" expand="1" fill="1">
+ <vbox>
+ <label /><label />
+ <vbox>
+ <label param="muter"/>
+ <toggle param="muter"/>
+ </vbox>
+ <vbox>
+ <toggle param="phaser"/>
+ <label param="phaser"/>
+ </vbox>
+ </vbox>
+ </frame>
+
+ </hbox>
+ <frame label="Output" expnad="1" fill="1">
+ <vbox spacing="8">
+ <table rows="3" cols="3">
+ <label param="meter_outL" attach-x="0" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="L"/>
+ <vumeter param="meter_outL" position="2" hold="1.5" falloff="2.5" attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_outL" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+
+ <label param="meter_outR" attach-x="0" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="R"/>
+ <vumeter param="meter_outR" position="2" hold="1.5" falloff="2.5" attach-x="1" attach-y="1" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_outR" attach-x="2" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0"/>
+ </table>
+ <hbox spacing="8">
+ <vbox spacing="12">
+ <label param="balance_out" />
+ <knob param="balance_out" size="2" type="1" />
+ <value param="balance_out" />
+ </vbox>
+ <vbox>
+ <label param="level_out" />
+ <knob param="level_out" size="3" />
+ <value param="level_out" />
+ </vbox>
+ </hbox>
+ </vbox>
+ </frame>
+</hbox>
+
diff --git a/gui/gui-stereo.xml b/gui/gui-stereo.xml
new file mode 100644
index 0000000..9f81602
--- /dev/null
+++ b/gui/gui-stereo.xml
@@ -0,0 +1,124 @@
+<hbox spacing="5">
+ <frame label="Input" expand="1" fill="1">
+ <vbox spacing="8">
+ <table rows="3" cols="3">
+ <label param="bypass" attach-y="2" attach-x="0" fill-x="0" expand-x="0" />
+ <toggle param="bypass" attach-y="0" attach-x="0" attach-h="2" fill-x="0" expand-x="0"/>
+
+ <label param="meter_inL" attach-x="1" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="L"/>
+ <vumeter param="meter_inL" position="2" hold="1.5" falloff="2.5" attach-x="2" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_inL" attach-x="3" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+
+ <label param="meter_inR" attach-x="1" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="R"/>
+ <vumeter param="meter_inR" position="2" hold="1.5" falloff="2.5" attach-x="2" attach-y="1" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_inR" attach-x="3" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0"/>
+ </table>
+ <hbox spacing="8">
+ <vbox expand="0" fill="0">
+ <knob param="level_in" size="5" />
+ <value param="level_in" />
+ </vbox>
+ <vbox expand="0" spacing="15">
+ <label param="balance_in" />
+ <knob param="balance_in" size="3" type="1" />
+ <value param="balance_in" />
+ </vbox>
+ <vbox expand="0" spacing="5">
+ <label param="flip" />
+ <align><toggle param="flip"/></align>
+ <align><toggle param="softclip"/></align>
+ <label param="softclip" />
+ </vbox>
+ </hbox>
+ </vbox>
+ </frame>
+
+ <vbox>
+ <frame label="Stereo Matrix" expand="1" fill="1">
+ <table rows="7" cols="2">
+
+ <label param="mode" attach-x="0" attach-y="3" />
+ <combo param="mode" attach-x="1" attach-y="3" attach-w="3" />
+
+ <label param="slev" attach-x="0" attach-y="0" />
+ <knob param="slev" type="1" size="2" attach-x="0" attach-y="1" />
+ <value param="slev" attach-x="0" attach-y="2" />
+
+ <label param="sbal" attach-x="1" attach-y="0" />
+ <knob param="sbal" type="1" size="2" attach-x="1" attach-y="1" />
+ <value param="sbal" attach-x="1" attach-y="2" />
+
+ <label param="mlev" attach-x="2" attach-y="0" />
+ <knob param="mlev" type="1" size="2" attach-x="2" attach-y="1" />
+ <value param="mlev" attach-x="2" attach-y="2" />
+
+ <label param="mpan" attach-x="3" attach-y="0" />
+ <knob param="mpan" type="1" size="2" attach-x="3" attach-y="1" />
+ <value param="mpan" attach-x="3" attach-y="2" />
+
+ </table>
+ </frame>
+
+ <hbox spacing="3">
+ <frame label="Left" expand="1" fill="1">
+ <hbox>
+ <vbox>
+
+ <align><toggle param="mutel"/></align>
+ <label param="mutel"/>
+
+ </vbox>
+ <vbox>
+
+ <align><toggle param="phasel"/></align>
+ <label param="phasel"/>
+
+ </vbox>
+ </hbox>
+ </frame>
+ <frame label="Right" expand="1" fill="1">
+ <hbox>
+ <vbox>
+
+ <align><toggle param="muter"/></align>
+ <label param="muter"/>
+
+ </vbox>
+ <vbox>
+
+ <align><toggle param="phaser"/></align>
+ <label param="phaser"/>
+
+ </vbox>
+ </hbox>
+ </frame>
+ </hbox>
+
+ </vbox>
+ <frame label="Output" expnad="1" fill="1">
+ <vbox spacing="8">
+ <table rows="3" cols="3">
+ <label attach-x="0" attach-y="2" fill-x="0" expand-x="0" />
+ <label param="meter_outL" attach-x="0" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="L"/>
+ <vumeter param="meter_outL" position="2" hold="1.5" falloff="2.5" attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_outL" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+
+ <label param="meter_outR" attach-x="0" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="R"/>
+ <vumeter param="meter_outR" position="2" hold="1.5" falloff="2.5" attach-x="1" attach-y="1" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+ <led param="clip_outR" attach-x="2" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0"/>
+ </table>
+ <hbox spacing="8">
+ <vbox expand="0" spacing="12">
+ <label param="balance_out" />
+ <knob param="balance_out" size="3" type="1" />
+ <value param="balance_out" />
+ </vbox>
+ <vbox expand="0" fill="0">
+ <knob param="level_out" size="5" />
+ <value param="level_out" />
+ </vbox>
+ </hbox>
+ </vbox>
+ </frame>
+</hbox>
+
diff --git a/src/calf/ctl_vumeter.h b/src/calf/ctl_vumeter.h
index f70713a..9d851c1 100644
--- a/src/calf/ctl_vumeter.h
+++ b/src/calf/ctl_vumeter.h
@@ -38,7 +38,9 @@ enum CalfVUMeterMode
{
VU_STANDARD,
VU_MONOCHROME,
- VU_MONOCHROME_REVERSE
+ VU_MONOCHROME_REVERSE,
+ VU_STANDARD_CENTER,
+ VU_MONOCHROME_CENTER
};
struct CalfVUMeter
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 6e974c1..3339681 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -355,6 +355,28 @@ struct bassenhancer_metadata: public plugin_metadata<bassenhancer_metadata>
param_freq, param_listen, param_count };
PLUGIN_NAME_ID_LABEL("bassenhancer", "bassenhancer", "Bass Enhancer")
};
+/// Markus's Mono Module - metadata
+struct stereo_metadata: public plugin_metadata<stereo_metadata>
+{
+ enum { in_count = 2, out_count = 2, ins_optional = 1, outs_optional = 1, support_midi = false, require_midi = false, rt_capable = true };
+ enum { param_bypass, param_level_in, param_level_out,
+ STEREO_VU_METER_PARAMS, param_balance_in, param_balance_out, param_flip, param_softclip,
+ param_mute_l, param_mute_r, param_phase_l, param_phase_r,
+ param_mode, param_slev, param_sbal, param_mlev, param_mpan,
+ param_count };
+ PLUGIN_NAME_ID_LABEL("stereo", "stereo", "Stereo Input")
+};
+/// Markus's Mono Module - metadata
+struct mono_metadata: public plugin_metadata<mono_metadata>
+{
+ enum { in_count = 1, out_count = 2, ins_optional = 1, outs_optional = 1, support_midi = false, require_midi = false, rt_capable = true };
+ enum { param_bypass, param_level_in, param_level_out,
+ param_meter_in, param_meter_outL, param_meter_outR, param_clip_in,param_clip_outL, param_clip_outR,
+ param_balance_out, param_softclip,
+ param_mute_l, param_mute_r, param_phase_l, param_phase_r,
+ param_count };
+ PLUGIN_NAME_ID_LABEL("mono", "mono", "Mono Input")
+};
/// Organ - enums for parameter IDs etc. (this mess is caused by organ split between plugin and generic class - which was
/// a bad design decision and should be sorted out some day) XXXKF @todo
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index 780beff..3e6d6f7 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -24,6 +24,8 @@
PER_MODULE_ITEM(saturator, false, "saturator")
PER_MODULE_ITEM(exciter, false, "exciter")
PER_MODULE_ITEM(bassenhancer, false, "bassenhancer")
+ PER_MODULE_ITEM(mono, false, "mono")
+ PER_MODULE_ITEM(stereo, false, "stereo")
#ifdef ENABLE_EXPERIMENTAL
PER_MODULE_ITEM(fluidsynth, true, "fluidsynth")
PER_MODULE_ITEM(wavetable, true, "wavetable")
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 19d67e2..24491fc 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -239,6 +239,44 @@ private:
void adjust_gain_according_to_filter_mode(int velocity);
};
+
+#define MATH_E 2.718281828
+class mono_audio_module:
+ public audio_module<mono_metadata>
+{
+ uint32_t srate;
+ bool active;
+ void softclip(float &s) {
+ int ph = s / fabs(s);
+ s = s > 0.63 ? ((0.63 + 0.36) * ph * (1 - pow(MATH_E, (1.f / 3) * (0.63 + s * ph)))) : s;
+ }
+public:
+ mono_audio_module();
+ void params_changed();
+ void activate();
+ void set_sample_rate(uint32_t sr);
+ void deactivate();
+ uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
+};
+class stereo_audio_module:
+ public audio_module<stereo_metadata>
+{
+ float LL, LR, RL, RR;
+ uint32_t srate;
+ bool active;
+ void softclip(float &s) {
+ int ph = s / fabs(s);
+ s = s > 0.63 ? ((0.63 + 0.36) * ph * (1 - pow(MATH_E, (1.f / 3) * (0.63 + s * ph)))) : s;
+ }
+public:
+ stereo_audio_module();
+ void params_changed();
+ void activate();
+ void set_sample_rate(uint32_t sr);
+ void deactivate();
+ uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
};
+
+};
#endif
diff --git a/src/ctl_vumeter.cpp b/src/ctl_vumeter.cpp
index 42399ae..ca50a73 100644
--- a/src/ctl_vumeter.cpp
+++ b/src/ctl_vumeter.cpp
@@ -152,6 +152,30 @@ calf_vumeter_expose (GtkWidget *widget, GdkEventExpose *event)
// if (vu->value < ts || vu->value <= 0)
// r *= 0.5, g *= 0.5, b *= 0.5;
break;
+ case VU_STANDARD_CENTER:
+ if (ts < 0.25)
+ // 0.0 -> 0.25
+ // green: 0.f -> 1.f
+ r = 1, g = (ts) / 0.25, b = 0;
+ else if (ts > 0.75)
+ // 0.75 -> 1.0
+ // green: 1.f -> 0.f
+ r = 1, g = 1 - (ts - 0.75) / 0.25, b = 0;
+ else if (ts > 0.5)
+ // 0.5 -> 0.75
+ // red: 0.f -> 1.f
+ // green: 0.5 -> 1.f
+ // blue: 1.f -> 0.f
+ r = (ts - 0.5) / 0.25, g = 0.5 + (ts - 0.5) * 2.f, b = 1 - (ts - 0.5) / 0.25;
+ else
+ // 0.25 -> 0.5
+ // red: 1.f -> 0.f
+ // green: 1.f -> 0.5
+ // blue: 0.f -> 1.f
+ r = 1 - (ts - 0.25) / 0.25, g = 1.f - ts * 2.f, b = (ts - 0.25) / 0.25;
+ // if (vu->value < ts || vu->value <= 0)
+ // r *= 0.5, g *= 0.5, b *= 0.5;
+ break;
case VU_MONOCHROME_REVERSE:
r = 0, g = 170.0 / 255.0, b = 1;
// if (!(vu->value < ts) || vu->value >= 1.0)
@@ -162,6 +186,11 @@ calf_vumeter_expose (GtkWidget *widget, GdkEventExpose *event)
// if (vu->value < ts || vu->value <= 0)
// r *= 0.5, g *= 0.5, b *= 0.5;
break;
+ case VU_MONOCHROME_CENTER:
+ r = 0, g = 170.0 / 255.0, b = 1;
+ // if (vu->value < ts || vu->value <= 0)
+ // r *= 0.5, g *= 0.5, b *= 0.5;
+ break;
}
GdkColor sc2 = { 0, (guint16)(65535 * r + 0.2), (guint16)(65535 * g), (guint16)(65535 * b) };
GdkColor sc3 = { 0, (guint16)(65535 * r * 0.7), (guint16)(65535 * g * 0.7), (guint16)(65535 * b * 0.7) };
diff --git a/src/metadata.cpp b/src/metadata.cpp
index c3dcd65..a4da798 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -787,6 +787,74 @@ CALF_PLUGIN_INFO(bassenhancer) = { 0x8532, "BassEnhancer", "Calf Bass Enhancer",
////////////////////////////////////////////////////////////////////////////
+CALF_PORT_NAMES(mono) = {"In", "Out L", "Out R"};
+CALF_PORT_PROPS(mono) = {
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
+ { 1, 0, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
+ { 1, 0, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_in", "Input" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "Output L" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "Output R" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_in", "0dB-In" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
+
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "balance_out", "Balance" },
+
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "softclip", "Softclip" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "mutel", "Mute L" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "muter", "Mute R" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "phasel", "Phase L" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "phaser", "Phase R" },
+
+ {}
+};
+
+CALF_PLUGIN_INFO(mono) = { 0x8589, "MonoInput", "Calf Mono Input", "Markus Schmidt", calf_plugins::calf_copyright_info, "Utility" };
+
+
+////////////////////////////////////////////////////////////////////////////
+
+CALF_PORT_NAMES(stereo) = {"In L", "In R", "Out L", "Out R"};
+const char *stereo_mode_names[] = { "LR - LR", "LR - MS", "MS - LR" };
+CALF_PORT_PROPS(stereo) = {
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
+ { 1, 0, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
+ { 1, 0, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inL", "Input L" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inR", "Input R" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "Output L" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "Output R" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
+ { 0, 0, 1, 0, PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
+
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "balance_in", "Balance In" },
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "balance_out", "Balance Out" },
+
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "flip", "Flip L/R" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "softclip", "Softclip" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "mutel", "Mute L" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "muter", "Mute R" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "phasel", "Phase L" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "phaser", "Phase R" },
+
+ { 0, 0, 2, 0, PF_ENUM | PF_CTL_COMBO, stereo_mode_names, "mode", "Mode" },
+
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "slev", "S Level" },
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sbal", "S Balance" },
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "mlev", "M Level" },
+ { 0.f, -1.f, 1.f, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "mpan", "M Panorama" },
+
+ {}
+};
+
+CALF_PLUGIN_INFO(stereo) = { 0x8588, "StereoInput", "Calf Stereo Input", "Markus Schmidt", calf_plugins::calf_copyright_info, "Utility" };
+
+
+////////////////////////////////////////////////////////////////////////////
+
CALF_PORT_NAMES(monosynth) = {
"Out L", "Out R",
};
diff --git a/src/modules.cpp b/src/modules.cpp
index c10e0e0..3e31270 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -445,3 +445,178 @@ bool filterclavier_audio_module::get_graph(int index, int subindex, float *data,
return false;
}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+stereo_audio_module::stereo_audio_module() {
+ active = false;
+}
+
+void stereo_audio_module::activate() {
+ active = true;
+}
+
+void stereo_audio_module::deactivate() {
+ active = false;
+}
+
+void stereo_audio_module::params_changed() {
+ float slev = 2 * *params[param_slev]; // stereo level ( -2 -> 2 )
+ float sbal = 1 + *params[param_sbal]; // stereo balance ( 0 -> 2 )
+ float mlev = 2 * *params[param_mlev]; // mono level ( -2 -> 2 )
+ float mpan = 1 + *params[param_mpan]; // mono pan ( 0 -> 2 )
+
+ switch((int)*params[param_mode])
+ {
+ case 0:
+ //LR->LR
+ LL = (mlev * (2.f - mpan) + slev * (2.f - sbal));
+ LR = (mlev * mpan - slev * sbal);
+ RL = (mlev * (2.f - mpan) - slev * (2.f - sbal));
+ RR = (mlev * mpan + slev * sbal);
+ break;
+ case 1:
+ //LR->MS
+ LL = (2.f - mpan) * (2.f - sbal);
+ LR = mpan * (2.f - sbal) * -1;
+ RL = (2.f - mpan) * sbal;
+ RR = mpan * sbal;
+ break;
+ case 2:
+ //MS->LR
+ LL = mlev * (2.f - sbal);
+ LR = mlev * mpan;
+ RL = slev * (2.f - sbal);
+ RR = slev * sbal * -1;
+ break;
+
+ }
+}
+
+uint32_t stereo_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+ for(uint32_t i = offset; i < offset + numsamples; i++) {
+ if(*params[param_bypass] > 0.5) {
+ outs[0][i] = ins[0][i];
+ outs[1][i] = ins[1][i];
+ } else {
+ float L, R;
+ if(*params[param_flip] > 0.5) {
+ // flip
+ L = ins[1][i];
+ R = ins[0][i];
+ } else {
+ // no flip
+ L = ins[0][i];
+ R = ins[1][i];
+ }
+ // mute
+ L *= (1 - floor(*params[param_mute_l] + 0.5));
+ R *= (1 - floor(*params[param_mute_r] + 0.5));
+
+ // levels in
+ L *= *params[param_level_in];
+ R *= *params[param_level_in];
+
+ // softclip
+ if(*params[param_softclip]) {
+ int ph;
+ ph = L / fabs(L);
+ L = L > 0.63 ? ph * (0.63 + 0.36 * (1 - pow(MATH_E, (1.f / 3) * (0.63 + L * ph)))) : L;
+ ph = R / fabs(R);
+ R = R > 0.63 ? ph * (0.63 + 0.36 * (1 - pow(MATH_E, (1.f / 3) * (0.63 + R * ph)))) : R;
+ }
+
+ // balance in
+ L *= (1.f - std::max(0.f, *params[param_balance_in]));
+ R *= (1.f + std::min(0.f, *params[param_balance_in]));
+
+ // phase
+ L *= (2 * (1 - floor(*params[param_phase_l] + 0.5))) - 1;
+ R *= (2 * (1 - floor(*params[param_phase_r] + 0.5))) - 1;
+
+ // LR/MS
+ L += LL*L + RL*R;
+ R += RR*R + LR*L;
+
+ // balance out
+ L *= (1.f - std::max(0.f, *params[param_balance_out]));
+ R *= (1.f + std::min(0.f, *params[param_balance_out]));
+
+ //output
+ outs[0][i] = L * *params[param_level_out];
+ outs[1][i] = R * *params[param_level_out];
+ }
+ }
+ return outputs_mask;
+}
+
+void stereo_audio_module::set_sample_rate(uint32_t sr)
+{
+ srate = sr;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+mono_audio_module::mono_audio_module() {
+ active = false;
+}
+
+void mono_audio_module::activate() {
+ active = true;
+}
+
+void mono_audio_module::deactivate() {
+ active = false;
+}
+
+void mono_audio_module::params_changed() {
+
+}
+
+uint32_t mono_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+ for(uint32_t i = offset; i < offset + numsamples; i++) {
+ if(*params[param_bypass] > 0.5) {
+ outs[0][i] = ins[0][i];
+ outs[1][i] = ins[0][i];
+ } else {
+ float L, R;
+ L = ins[0][i];
+ R = ins[0][i];
+
+ // mute
+ L *= (1 - floor(*params[param_mute_l] + 0.5));
+ R *= (1 - floor(*params[param_mute_r] + 0.5));
+
+ // levels in
+ L *= *params[param_level_in];
+ R *= *params[param_level_in];
+
+ // softclip
+ if(*params[param_softclip]) {
+ int ph;
+ ph = L / fabs(L);
+ L = L > 0.63 ? ph * (0.63 + 0.36 * (1 - pow(MATH_E, (1.f / 3) * (0.63 + L * ph)))) : L;
+ ph = R / fabs(R);
+ R = R > 0.63 ? ph * (0.63 + 0.36 * (1 - pow(MATH_E, (1.f / 3) * (0.63 + R * ph)))) : R;
+ }
+
+ // phase
+ L *= (2 * (1 - floor(*params[param_phase_l] + 0.5))) - 1;
+ R *= (2 * (1 - floor(*params[param_phase_r] + 0.5))) - 1;
+
+ // balance out
+ L *= (1.f - std::max(0.f, *params[param_balance_out]));
+ R *= (1.f + std::min(0.f, *params[param_balance_out]));
+
+ //output
+ outs[0][i] = L * *params[param_level_out];
+ outs[1][i] = R * *params[param_level_out];
+ }
+ }
+ return outputs_mask;
+}
+
+void mono_audio_module::set_sample_rate(uint32_t sr)
+{
+ srate = sr;
+}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list