commit e998c7fe673adf8a3156e382bf83f7f75b0c7089
parent d0b2a7bbcde3a48eb4a10e5d3f9dc97467ab3617
Author: Matt Demanett <matt@demanett.net>
Date: Fri, 15 Nov 2019 22:36:45 -0500
Add output invert toggles to S&H. #75
Diffstat:
22 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -402,7 +402,9 @@ A dual sample-and-hold and trigger-and-hold. Sampling may be triggered by CV (o
If nothing is connected to an IN port, sampling for that channel is normalled to an internal white noise source with range 0-10V. Alternative options for the normal source noise type and range are available on the context (right-click) menu. The normal source selection applies to both channels.
-Each channel can be independently toggled into track-and-hold mode. In this mode, when the input at GATE is high, or the button is held, the input is copied to the output. When the gate goes low, the input is sampled and held until the next gate.
+Each channel can be independently toggled into track-and-hold mode with the corresponding TRK button. In this mode, when the input at GATE is high, or the button is held, the input is copied to the output. When the gate goes low, the input is sampled and held until the next gate.
+
+[New in version 1.1.24:] Each channel may also be have its output inverted with the INV button.
The GATE input on the lower section is normalled to GATE in the top section (but a press on the top button does not trigger the lower section).
diff --git a/doc/www/effects.png b/doc/www/effects.png
Binary files differ.
diff --git a/doc/www/envelopes1.png b/doc/www/envelopes1.png
Binary files differ.
diff --git a/doc/www/envelopes2.png b/doc/www/envelopes2.png
Binary files differ.
diff --git a/doc/www/lfos.png b/doc/www/lfos.png
Binary files differ.
diff --git a/doc/www/misc.png b/doc/www/misc.png
Binary files differ.
diff --git a/doc/www/mixers1.png b/doc/www/mixers1.png
Binary files differ.
diff --git a/doc/www/mixers2.png b/doc/www/mixers2.png
Binary files differ.
diff --git a/doc/www/modules1.png b/doc/www/modules1.png
Binary files differ.
diff --git a/doc/www/modules2.png b/doc/www/modules2.png
Binary files differ.
diff --git a/doc/www/modules3.png b/doc/www/modules3.png
Binary files differ.
diff --git a/doc/www/modules4.png b/doc/www/modules4.png
Binary files differ.
diff --git a/doc/www/noise.png b/doc/www/noise.png
Binary files differ.
diff --git a/doc/www/oscillators.png b/doc/www/oscillators.png
Binary files differ.
diff --git a/doc/www/pitch.png b/doc/www/pitch.png
Binary files differ.
diff --git a/doc/www/sequencers.png b/doc/www/sequencers.png
Binary files differ.
diff --git a/doc/www/utilities.png b/doc/www/utilities.png
Binary files differ.
diff --git a/doc/www/visualizers.png b/doc/www/visualizers.png
Binary files differ.
diff --git a/res-src/SampleHold-src.svg b/res-src/SampleHold-src.svg
@@ -82,8 +82,8 @@
<g transform="translate(0 65)">
<g transform="translate(5.5 0)">
- <rect width="34" height="10" fill="#fafafa" transform="translate(0 41)" />
- <rect width="34" height="48" rx="5" fill="#fafafa" />
+ <rect width="34" height="10" fill="#fafafa" transform="translate(0 51)" />
+ <rect width="34" height="58" rx="5" fill="#fafafa" />
<use id="IN1_INPUT" xlink:href="#input" transform="translate(5 3)" />
<text font-size="5pt" letter-spacing="2px" transform="translate(12.5 35)">IN</text>
</g>
@@ -96,7 +96,15 @@
<!-- <rect width="90" height="5" fill="#0f0" transform="translate(0 -6)" /> -->
</g>
- <g transform="translate(5.5 54)">
+ <g transform="translate(7 52)">
+ <!-- <polyline points="0,3.2 70,3.2" stroke="#0f0" stroke-width="1" fill="none" /> -->
+ <use id="INVERT1_PARAM" xlink:href="#button-small" transform="translate(22 -1.3)" />
+ <use id="INVERT1_LIGHT" xlink:href="#light-small" transform="translate(0 0)" />
+ <text font-size="5pt" letter-spacing="1.2px" transform="translate(7.3 5.5)">INV</text>
+ <!-- <rect width="90" height="5" fill="#0f0" transform="translate(0 -6)" /> -->
+ </g>
+
+ <g transform="translate(5.5 64)">
<rect width="34" height="10" fill="#bbb" transform="translate(0 -3)" />
<rect width="34" height="35" rx="5" fill="#bbb" />
<use id="OUT1_OUTPUT" xlink:href="#output" transform="translate(5 0)" />
@@ -120,8 +128,8 @@
<g transform="translate(0 65)">
<g transform="translate(5.5 0)">
- <rect width="34" height="10" fill="#fafafa" transform="translate(0 41)" />
- <rect width="34" height="48" rx="5" fill="#fafafa" />
+ <rect width="34" height="10" fill="#fafafa" transform="translate(0 51)" />
+ <rect width="34" height="58" rx="5" fill="#fafafa" />
<use id="IN2_INPUT" xlink:href="#input" transform="translate(5 3)" />
<text font-size="5pt" letter-spacing="2px" transform="translate(12.5 35)">IN</text>
</g>
@@ -134,7 +142,15 @@
<!-- <rect width="90" height="5" fill="#0f0" transform="translate(0 -6)" /> -->
</g>
- <g transform="translate(5.5 54)">
+ <g transform="translate(7 52)">
+ <!-- <polyline points="0,3.2 70,3.2" stroke="#0f0" stroke-width="1" fill="none" /> -->
+ <use id="INVERT2_PARAM" xlink:href="#button-small" transform="translate(22 -1.3)" />
+ <use id="INVERT2_LIGHT" xlink:href="#light-small" transform="translate(0 0)" />
+ <text font-size="5pt" letter-spacing="1.2px" transform="translate(7.3 5.5)">INV</text>
+ <!-- <rect width="90" height="5" fill="#0f0" transform="translate(0 -6)" /> -->
+ </g>
+
+ <g transform="translate(5.5 64)">
<rect width="34" height="10" fill="#bbb" transform="translate(0 -3)" />
<rect width="34" height="35" rx="5" fill="#bbb" />
<use id="OUT2_OUTPUT" xlink:href="#output" transform="translate(5 0)" />
diff --git a/res/SampleHold.svg b/res/SampleHold.svg
Binary files differ.
diff --git a/src/SampleHold.cpp b/src/SampleHold.cpp
@@ -45,6 +45,8 @@ void SampleHold::processChannel(const ProcessArgs& args, int c) {
processChannel(
lights[TRACK1_LIGHT],
params[TRACK1_PARAM],
+ lights[INVERT1_LIGHT],
+ params[INVERT1_PARAM],
_trigger1,
params[TRIGGER1_PARAM],
inputs[TRIGGER1_INPUT],
@@ -56,6 +58,8 @@ void SampleHold::processChannel(const ProcessArgs& args, int c) {
processChannel(
lights[TRACK2_LIGHT],
params[TRACK2_PARAM],
+ lights[INVERT2_LIGHT],
+ params[INVERT2_PARAM],
_trigger2,
params[TRIGGER2_PARAM],
inputs[TRIGGER2_INPUT],
@@ -69,6 +73,8 @@ void SampleHold::processChannel(const ProcessArgs& args, int c) {
void SampleHold::processChannel(
Light& trackLight,
Param& trackParam,
+ Light& invertLight,
+ Param& invertParam,
Trigger* trigger,
Param& triggerParam,
Input& triggerInput,
@@ -78,6 +84,7 @@ void SampleHold::processChannel(
Output& out
) {
trackLight.value = trackParam.getValue();
+ invertLight.value = invertParam.getValue();
int n = std::max(1, std::max(triggerInput.getChannels(), in.getChannels()));
out.setChannels(n);
@@ -88,6 +95,7 @@ void SampleHold::processChannel(
} else if (altTriggerInput) {
triggerIn = altTriggerInput->getPolyVoltage(i);
}
+
bool triggered = trigger[i].process(triggerParam.getValue() + triggerIn);
if (trackParam.getValue() > 0.5f ? trigger[i].isHigh() : triggered) {
if (in.isConnected()) {
@@ -97,7 +105,12 @@ void SampleHold::processChannel(
value[i] = (noise() + _rangeOffset) * _rangeScale;
}
}
- out.setVoltage(value[i], i);
+
+ float o = value[i];
+ if (invertParam.getValue() > 0.5f) {
+ o = -o;
+ }
+ out.setVoltage(o, i);
}
}
@@ -138,25 +151,31 @@ struct SampleHoldWidget : ModuleWidget {
// generated by svg_widgets.rb
auto trigger1ParamPosition = Vec(13.5, 27.0);
auto track1ParamPosition = Vec(29.0, 122.7);
+ auto invert1ParamPosition = Vec(29.0, 133.7);
auto trigger2ParamPosition = Vec(13.5, 190.0);
auto track2ParamPosition = Vec(29.0, 285.7);
+ auto invert2ParamPosition = Vec(29.0, 296.7);
auto trigger1InputPosition = Vec(10.5, 49.0);
auto in1InputPosition = Vec(10.5, 86.0);
auto trigger2InputPosition = Vec(10.5, 212.0);
auto in2InputPosition = Vec(10.5, 249.0);
- auto out1OutputPosition = Vec(10.5, 137.0);
- auto out2OutputPosition = Vec(10.5, 300.0);
+ auto out1OutputPosition = Vec(10.5, 147.0);
+ auto out2OutputPosition = Vec(10.5, 310.0);
auto track1LightPosition = Vec(7.0, 124.0);
+ auto invert1LightPosition = Vec(7.0, 135.0);
auto track2LightPosition = Vec(7.0, 287.0);
+ auto invert2LightPosition = Vec(7.0, 298.0);
// end generated by svg_widgets.rb
addParam(createParam<Button18>(trigger1ParamPosition, module, SampleHold::TRIGGER1_PARAM));
addParam(createParam<Button18>(trigger2ParamPosition, module, SampleHold::TRIGGER2_PARAM));
addParam(createParam<StatefulButton9>(track1ParamPosition, module, SampleHold::TRACK1_PARAM));
addParam(createParam<StatefulButton9>(track2ParamPosition, module, SampleHold::TRACK2_PARAM));
+ addParam(createParam<StatefulButton9>(invert1ParamPosition, module, SampleHold::INVERT1_PARAM));
+ addParam(createParam<StatefulButton9>(invert2ParamPosition, module, SampleHold::INVERT2_PARAM));
addInput(createInput<Port24>(trigger1InputPosition, module, SampleHold::TRIGGER1_INPUT));
addInput(createInput<Port24>(in1InputPosition, module, SampleHold::IN1_INPUT));
@@ -168,6 +187,8 @@ struct SampleHoldWidget : ModuleWidget {
addChild(createLight<SmallLight<GreenLight>>(track1LightPosition, module, SampleHold::TRACK1_LIGHT));
addChild(createLight<SmallLight<GreenLight>>(track2LightPosition, module, SampleHold::TRACK2_LIGHT));
+ addChild(createLight<SmallLight<GreenLight>>(invert1LightPosition, module, SampleHold::INVERT1_LIGHT));
+ addChild(createLight<SmallLight<GreenLight>>(invert2LightPosition, module, SampleHold::INVERT2_LIGHT));
}
struct NoiseTypeMenuItem : MenuItem {
diff --git a/src/SampleHold.hpp b/src/SampleHold.hpp
@@ -15,6 +15,8 @@ struct SampleHold : BGModule {
TRIGGER2_PARAM,
TRACK1_PARAM,
TRACK2_PARAM,
+ INVERT1_PARAM,
+ INVERT2_PARAM,
NUM_PARAMS
};
@@ -35,6 +37,8 @@ struct SampleHold : BGModule {
enum LightsIds {
TRACK1_LIGHT,
TRACK2_LIGHT,
+ INVERT1_LIGHT,
+ INVERT2_LIGHT,
NUM_LIGHTS
};
@@ -63,6 +67,8 @@ struct SampleHold : BGModule {
configParam(TRIGGER2_PARAM, 0.0f, 10.0f, 0.0f, "Trigger 2");
configParam(TRACK1_PARAM, 0.0f, 1.0f, 0.0f, "Track 1");
configParam(TRACK2_PARAM, 0.0f, 1.0f, 0.0f, "Track 2");
+ configParam(INVERT1_PARAM, 0.0f, 1.0f, 0.0f, "Invert 1");
+ configParam(INVERT2_PARAM, 0.0f, 1.0f, 0.0f, "Invert 2");
reset();
}
@@ -74,6 +80,8 @@ struct SampleHold : BGModule {
void processChannel(
Light& trackLight,
Param& trackParam,
+ Light& invertLight,
+ Param& invertParam,
Trigger* trigger,
Param& triggerParam,
Input& triggerInput,