Browse Source

Add CV Mix.

tags/v2.2.0
Andrew Belt 3 years ago
parent
commit
470ea24ba0
5 changed files with 465 additions and 0 deletions
  1. +10
    -0
      plugin.json
  2. +367
    -0
      res/CVMix.svg
  3. +86
    -0
      src/CVMix.cpp
  4. +1
    -0
      src/plugin.cpp
  5. +1
    -0
      src/plugin.hpp

+ 10
- 0
plugin.json View File

@@ -290,6 +290,16 @@
"Random",
"Sample and hold"
]
},
{
"slug": "CVMix",
"name": "CV Mix",
"description": "Mixes 3 CV signals with attenuverters",
"tags": [
"Utility",
"Polyphonic",
"Mixer"
]
}
]
}

+ 367
- 0
res/CVMix.svg View File

@@ -0,0 +1,367 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="45"
height="380"
viewBox="0 0 45 380"
version="1.1"
id="svg100"
sodipodi:docname="CVMIX.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata104">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview102"
showgrid="false"
inkscape:zoom="3.5132042"
inkscape:cx="27.086008"
inkscape:cy="227.72636"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="f45e0130-37b7-4f8b-95b3-6408baa23eb1" />
<defs
id="defs7">
<linearGradient
id="a8e142bb-541b-4903-be63-d5d069028a5d"
x1="22.5"
x2="22.5"
y2="380"
gradientUnits="userSpaceOnUse">
<stop
offset="0"
stop-color="#ebebeb"
id="stop2" />
<stop
offset="1"
stop-color="#e1e1e1"
id="stop4" />
</linearGradient>
</defs>
<g
id="aea613ef-74be-49bf-be45-c0734aee674b"
data-name="FND BG">
<rect
width="45"
height="380"
fill="url(#a8e142bb-541b-4903-be63-d5d069028a5d)"
id="rect9" />
</g>
<g
id="acbff6da-b0ab-490b-8f6a-39b69ff97c7f"
data-name="FND GRAPH">
<path
d="M22.822,210.73147l1.658-2.87167a.37186.37186,0,0,0-.322-.55779H20.842a.37186.37186,0,0,0-.322.55779l1.658,2.87167A.37186.37186,0,0,0,22.822,210.73147Z"
fill="#1f1f1f"
id="path12" />
<g
id="g20">
<line
x1="22.50002"
y1="60.47645"
x2="22.50002"
y2="56.75319"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="line14" />
<path
d="M31.13564,87.30507a16.71231,16.71231,0,1,0-17.21552.04578"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="path16" />
<circle
cx="22.5"
cy="72.9999"
r="20.69419"
fill="none"
opacity="0.69"
style="isolation: isolate"
id="circle18" />
</g>
<g
id="g28">
<line
x1="22.50002"
y1="109.47655"
x2="22.50002"
y2="105.75329"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="line22" />
<path
d="M31.13564,136.30517a16.71231,16.71231,0,1,0-17.21552.04578"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="path24" />
<circle
cx="22.5"
cy="122"
r="20.69419"
fill="none"
opacity="0.69"
style="isolation: isolate"
id="circle26" />
</g>
<g
id="g36">
<line
x1="22.50002"
y1="158.47655"
x2="22.50002"
y2="154.75329"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="line30" />
<path
d="M31.13564,185.30517a16.71231,16.71231,0,1,0-17.21552.04578"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="path32" />
<circle
cx="22.5"
cy="171"
r="20.69419"
fill="none"
opacity="0.69"
style="isolation: isolate"
id="circle34" />
</g>
<line
x1="22.5"
y1="43.95696"
x2="22.5"
y2="52.04472"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.8"
id="line38" />
<line
x1="22.5"
y1="141.3302"
x2="22.5"
y2="148.9148"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.666"
id="line40" />
<line
x1="22.5"
y1="92.33016"
x2="22.5"
y2="99.91476"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.666"
id="line42" />
<g
id="g52">
<circle
cx="23.00165"
cy="355.84251"
r="1.18571"
fill="#1f1f1f"
id="circle44" />
<path
d="M14.35927,359.76448a.91214.91214,0,0,1-.8158-.50418l-2.96428-5.92857a.91209.91209,0,0,1,1.6316-.8158l2.14848,4.297,2.14848-4.297a.91209.91209,0,0,1,1.6316.8158l-2.96428,5.92857A.91211.91211,0,0,1,14.35927,359.76448Z"
fill="#1f1f1f"
id="path46" />
<path
d="M30.64073,359.76448a.91211.91211,0,0,1-.8158-.50418l-2.96428-5.92857a.91209.91209,0,0,1,1.6316-.8158l2.14848,4.297,2.14848-4.297a.91209.91209,0,0,1,1.6316.8158l-2.96428,5.92857A.91214.91214,0,0,1,30.64073,359.76448Z"
fill="#1f1f1f"
id="path48" />
<path
d="M22.94242,359.76448a3.87637,3.87637,0,1,1,2.32653-6.97719.91209.91209,0,1,1-1.09557,1.45854,2.034,2.034,0,0,0-1.231-.40991,2.0522,2.0522,0,1,0,0,4.10439,2.034,2.034,0,0,0,1.231-.40991.91209.91209,0,1,1,1.09557,1.45854A3.8448,3.8448,0,0,1,22.94242,359.76448Z"
fill="#1f1f1f"
id="path50" />
</g>
<line
x1="22.5"
y1="226.01171"
x2="22.5"
y2="312.92473"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="0.666"
id="line54" />
<rect
x="8.22422"
y="309.05634"
width="28.55155"
height="39.15691"
rx="2.83465"
fill="#1f1f1f"
id="rect56" />
</g>
<g
id="bdbe9173-d9af-4105-b44b-baa84dafe49d"
data-name="FND TXT">
<g
id="g65">
<path
d="M17.31445,199.85938l-.48828.14892a.59633.59633,0,0,1-.14941.02051.36047.36047,0,0,1-.08789-.71143l.71777-.23047a1.45162,1.45162,0,0,1,.40625-.07421h.01367a.40616.40616,0,0,1,.41406.41308v4.01074a.41309.41309,0,1,1-.82617,0Z"
fill="#1f1f1f"
id="path59" />
<path
d="M19.38477,201.458v-.01319a2.22044,2.22044,0,0,1,2.07324-2.45263,2.2028,2.2028,0,0,1,2.05957,2.439v.01367a2.22045,2.22045,0,0,1-2.07324,2.45264A2.19819,2.19819,0,0,1,19.38477,201.458Zm3.27246,0v-.01319c0-.935-.48145-1.70068-1.21289-1.70068s-1.19922.74512-1.19922,1.687v.01367c0,.93506.47363,1.70069,1.21289,1.70069C22.19629,203.14551,22.65723,202.38672,22.65723,201.458Z"
fill="#1f1f1f"
id="path61" />
<path
d="M25.90625,203.54492l-1.65918-3.90234a.4637.4637,0,0,1-.04785-.19629.41134.41134,0,0,1,.41992-.40674.43777.43777,0,0,1,.42774.29834l1.36816,3.4209,1.38867-3.44824a.42988.42988,0,0,1,.39941-.271.40428.40428,0,0,1,.41407.3999.47424.47424,0,0,1-.041.17578l-1.666,3.92969a.49756.49756,0,0,1-.48145.33887h-.04785A.49524.49524,0,0,1,25.90625,203.54492Z"
fill="#1f1f1f"
id="path63" />
</g>
<path
d="M15.207,47.981a.47858.47858,0,0,1,.4707-.4795h1.50391a.47585.47585,0,0,1,0,.95166H15.67773A.47733.47733,0,0,1,15.207,47.981Z"
fill="#1f1f1f"
id="path67" />
<path
d="M28.0918,48.44141H26.957a.43762.43762,0,0,1-.43945-.43946.443.443,0,0,1,.43945-.43945H28.0918V46.45068a.45063.45063,0,0,1,.45605-.45556.45614.45614,0,0,1,.45606.45556V47.5625h1.13476a.443.443,0,0,1,.43945.43945.43761.43761,0,0,1-.43945.43946H29.00391v1.11181a.45615.45615,0,0,1-.45606.45557.45063.45063,0,0,1-.45605-.45557Z"
fill="#1f1f1f"
id="path69" />
<g
id="g81">
<path
d="M3.24023,23.93164v-.0249a4.45146,4.45146,0,0,1,4.56641-4.5293,4.638,4.638,0,0,1,2.92871.88818.96478.96478,0,0,1,.375.76368.93948.93948,0,0,1-.95019.93847,1.01258,1.01258,0,0,1-.57618-.188,2.88229,2.88229,0,0,0-1.78906-.62549,2.59489,2.59489,0,0,0-2.54,2.72754v.0249a2.60137,2.60137,0,0,0,2.54,2.75293,2.81637,2.81637,0,0,0,1.90235-.688A.892.892,0,1,1,10.84766,27.335a4.39911,4.39911,0,0,1-3.11524,1.10156A4.4212,4.4212,0,0,1,3.24023,23.93164Z"
fill="#1f1f1f"
id="path71" />
<path
d="M14.65234,27.66064l-2.84082-6.79443a1.19644,1.19644,0,0,1-.1123-.46289.94531.94531,0,0,1,.96289-.95068,1.00247,1.00247,0,0,1,.97656.67529l2.18945,5.668L18.043,20.06543a.99864.99864,0,0,1,.92578-.61279.92974.92974,0,0,1,.95117.92578,1.12328,1.12328,0,0,1-.10058.42529L16.9541,27.66064a1.13167,1.13167,0,0,1-1.08887.76319h-.125A1.12955,1.12955,0,0,1,14.65234,27.66064Z"
fill="#1f1f1f"
id="path73" />
<path
d="M20.68945,20.44092a.95618.95618,0,0,1,.96387-.96338h.21191a.99092.99092,0,0,1,.877.50049l2.32617,3.7915,2.33984-3.80371a.94508.94508,0,0,1,.86328-.48828h.2129a.95557.95557,0,0,1,.96386.96338v6.95654a.95754.95754,0,1,1-1.915,0V23.03125l-1.68847,2.60254a.9012.9012,0,0,1-1.60157,0L22.5791,23.06836v4.35449a.93972.93972,0,0,1-.95117.93848.92956.92956,0,0,1-.93848-.93848Z"
fill="#1f1f1f"
id="path75" />
<path
d="M31.14258,20.416a.96387.96387,0,0,1,1.92773,0v6.98144a.96387.96387,0,1,1-1.92773,0Z"
fill="#1f1f1f"
id="path77" />
<path
d="M34.39844,26.73438,36.7627,23.832,34.53516,21.1167a1.1825,1.1825,0,0,1-.28711-.71338.92731.92731,0,0,1,.95117-.95068,1.01094,1.01094,0,0,1,.88769.47509l1.915,2.55274L39.90332,19.978a1.09963,1.09963,0,0,1,.93848-.52539.87958.87958,0,0,1,.876.88818,1.14583,1.14583,0,0,1-.28808.73828l-2.22657,2.72754,2.35157,2.89063a1.175,1.175,0,0,1,.28808.71289.92772.92772,0,0,1-.95117.95117,1.01025,1.01025,0,0,1-.88769-.47559l-2.05274-2.69043-2.02734,2.64063a1.09681,1.09681,0,0,1-.9375.52539.88.88,0,0,1-.876-.88867A1.14683,1.14683,0,0,1,34.39844,26.73438Z"
fill="#1f1f1f"
id="path79" />
</g>
<g
id="g89">
<path
d="M16.38672,314.66113a.51759.51759,0,0,1,.52246-.52148h.11523a.534.534,0,0,1,.47364.27051l1.26074,2.05273,1.2666-2.05957a.51151.51151,0,0,1,.46777-.26367h.11524a.51738.51738,0,0,1,.52148.52148v3.7666a.51808.51808,0,1,1-1.03613,0v-2.36425l-.915,1.40918a.48793.48793,0,0,1-.86719,0l-.90136-1.38868v2.35743a.51173.51173,0,0,1-1.02344,0Z"
fill="#f0f0f0"
id="path83" />
<path
d="M22.55273,314.64746a.52149.52149,0,0,1,1.043,0v3.78027a.52149.52149,0,1,1-1.043,0Z"
fill="#f0f0f0"
id="path85" />
<path
d="M24.8252,318.06885l1.28027-1.57178-1.20508-1.47021a.63294.63294,0,0,1-.15625-.38624.50213.50213,0,0,1,.51465-.51464.54819.54819,0,0,1,.48144.25732l1.03614,1.38232,1.03027-1.35546a.59581.59581,0,0,1,.50781-.28418.47651.47651,0,0,1,.47461.48095.62159.62159,0,0,1-.15625.39991l-1.206,1.47656,1.27441,1.56543a.6435.6435,0,0,1,.15528.38574.50225.50225,0,0,1-.51465.51514.54926.54926,0,0,1-.48145-.25733l-1.11035-1.457L25.65234,318.665a.5975.5975,0,0,1-.50781.28467.47684.47684,0,0,1-.47461-.481A.61843.61843,0,0,1,24.8252,318.06885Z"
fill="#f0f0f0"
id="path87" />
</g>
</g>
<g
id="f45e0130-37b7-4f8b-95b3-6408baa23eb1"
data-name="components"
style="display:none"
inkscape:groupmode="layer">
<circle
id="a1c23d66-c252-4515-96a1-917337e8bedb"
data-name="In1#PJ301MPort"
cx="22.5"
cy="226"
r="5"
style="fill:#00ff00" />
<circle
id="a63e68d2-1ca8-4e05-b0d1-8b6f332b0e37"
data-name="Lev1#RoundBlackKnob"
cx="22.5"
cy="72.999901"
r="5"
style="fill:#ff0000" />
<circle
id="a36d22f7-2d0f-442d-90d7-0667ecca8733"
data-name="Lev2#RoundBlackKnob"
cx="22.5"
cy="122.02957"
r="5"
style="fill:#ff0000" />
<circle
id="b2ee54e9-17bb-44a2-8fa9-f1f5dfd502d3"
data-name="Lev3#RoundBlackKnob"
cx="22.5"
cy="171.02957"
r="5"
style="fill:#ff0000" />
<circle
id="a2b06e69-ffb0-4881-82df-d087f66de86e"
data-name="In2#PJ301MPort"
cx="22.5"
cy="256"
r="5"
style="fill:#00ff00" />
<circle
id="b27f5a6d-d286-4c64-8b15-5bc216721daf"
data-name="In3#PJ301MPort"
cx="22.5"
cy="286"
r="5"
style="fill:#00ff00" />
<circle
id="be215e83-67fa-4d0f-a299-89c18bd912d3"
data-name="Mix#PJ301MPort"
cx="22.5"
cy="334"
r="5"
style="fill:#0000ff"
inkscape:label="be215e83-67fa-4d0f-a299-89c18bd912d3" />
</g>
</svg>

+ 86
- 0
src/CVMix.cpp View File

@@ -0,0 +1,86 @@
#include "plugin.hpp"


struct CVMix : Module {
enum ParamId {
ENUMS(LEVEL_PARAMS, 3),
PARAMS_LEN
};
enum InputId {
ENUMS(CV_INPUTS, 3),
INPUTS_LEN
};
enum OutputId {
MIX_OUTPUT,
OUTPUTS_LEN
};
enum LightId {
LIGHTS_LEN
};

CVMix() {
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
for (int i = 0; i < 3; i++)
configParam(LEVEL_PARAMS + i, -1.f, 1.f, 0.f, string::f("Level %d", i + 1), "%", 0, 100);
for (int i = 0; i < 3; i++)
configInput(CV_INPUTS + i, string::f("CV %d", i + 1));
configOutput(MIX_OUTPUT, "Mix");
}

void process(const ProcessArgs& args) override {
if (!outputs[MIX_OUTPUT].isConnected())
return;

// Get number of channels
int channels = 1;
for (int i = 0; i < 3; i++)
channels = std::max(channels, inputs[CV_INPUTS + i].getChannels());

for (int c = 0; c < channels; c++) {
// Sum CV inputs
float mix = 0.f;
for (int i = 0; i < 3; i++) {
float cv;
// Normalize first input to 10V
if (i == 0)
cv = inputs[CV_INPUTS + i].getNormalVoltage(10.f, c);
else
cv = inputs[CV_INPUTS + i].getVoltage(c);

// Apply gain
cv *= params[LEVEL_PARAMS + i].getValue();
mix += cv;
}

// Set mix output
outputs[MIX_OUTPUT].setVoltage(mix, c);
}
outputs[MIX_OUTPUT].setChannels(channels);
}
};


struct CVMixWidget : ModuleWidget {
CVMixWidget(CVMix* module) {
setModule(module);
setPanel(createPanel(asset::plugin(pluginInstance, "res/CVMix.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(7.62, 24.723)), module, CVMix::LEVEL_PARAMS + 0));
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(7.62, 41.327)), module, CVMix::LEVEL_PARAMS + 1));
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(7.62, 57.922)), module, CVMix::LEVEL_PARAMS + 2));

addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.62, 76.539)), module, CVMix::CV_INPUTS + 0));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.62, 86.699)), module, CVMix::CV_INPUTS + 1));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.62, 96.859)), module, CVMix::CV_INPUTS + 2));

addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 113.115)), module, CVMix::MIX_OUTPUT));
}
};


Model* modelCVMix = createModel<CVMix, CVMixWidget>("CVMix");

+ 1
- 0
src/plugin.cpp View File

@@ -34,4 +34,5 @@ void init(Plugin* p) {
p->addModel(modelMidSide);
p->addModel(modelNoise);
p->addModel(modelRandom);
p->addModel(modelCVMix);
}

+ 1
- 0
src/plugin.hpp View File

@@ -34,6 +34,7 @@ extern Model* modelViz;
extern Model* modelMidSide;
extern Model* modelNoise;
extern Model* modelRandom;
extern Model* modelCVMix;


struct DigitalDisplay : Widget {


Loading…
Cancel
Save