Browse Source

Add Rescale module.

tags/v2.6.0
Andrew Belt 1 year ago
parent
commit
a86027448a
5 changed files with 515 additions and 0 deletions
  1. +9
    -0
      plugin.json
  2. +351
    -0
      res/Rescale.svg
  3. +153
    -0
      src/Rescale.cpp
  4. +1
    -0
      src/plugin.cpp
  5. +1
    -0
      src/plugin.hpp

+ 9
- 0
plugin.json View File

@@ -362,6 +362,15 @@
"Utility",
"Polyphonic"
]
},
{
"slug": "Rescale",
"name": "Rescale",
"description": "Rescales voltages with gain and offset",
"tags": [
"Utility",
"Polyphonic"
]
}
]
}

+ 351
- 0
res/Rescale.svg View File

@@ -0,0 +1,351 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="45"
height="380"
viewBox="0 0 45 380"
version="1.1"
id="svg6589"
sodipodi:docname="RESCALE.svg"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview6591"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="2.1815789"
inkscape:cx="22.689988"
inkscape:cy="190.22919"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg6589" />
<defs
id="defs6478">
<linearGradient
id="uuid-7519d4f7-6407-4c72-b34d-73628dbd4d80"
x1="22.5"
y1="0"
x2="22.5"
y2="380"
gradientUnits="userSpaceOnUse">
<stop
offset="0"
stop-color="#ebebeb"
id="stop6473" />
<stop
offset="1"
stop-color="#e1e1e1"
id="stop6475" />
</linearGradient>
</defs>
<g
id="uuid-7ff80f40-97dc-492e-8d52-829bd0761691"
data-name="FND BG">
<rect
width="45"
height="380"
fill="url(#uuid-7519d4f7-6407-4c72-b34d-73628dbd4d80)"
id="rect6480" />
</g>
<g
id="uuid-fd6320f7-8c0a-4368-9328-e3756adac1e4"
data-name="FND GRAPH">
<rect
x="8.22422"
y="309.05634"
width="28.55155"
height="39.15691"
rx="2.83465"
ry="2.83465"
fill="#1f1f1f"
id="rect6483" />
<g
id="g6489">
<path
d="m13.92012,87.35089c-4.87734-2.91881-8.14264-8.25353-8.14264-14.35091,0-9.23,7.48239-16.71239,16.71239-16.71239s16.71239,7.48239,16.71239,16.71239c0,6.06564-3.2314,11.37655-8.06662,14.30514"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="path6485" />
<circle
cx="22.5"
cy="72.99995"
r="20.69419"
fill="none"
isolation="isolate"
opacity=".69"
id="circle6487" />
</g>
<g
id="g6495">
<path
d="m13.90998,141.41229c-4.87734-2.91881-8.14264-8.25353-8.14264-14.35091,0-9.23,7.48239-16.71239,16.71239-16.71239s16.71239,7.48239,16.71239,16.71239c0,6.06564-3.2314,11.37655-8.06662,14.30514"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="path6491" />
<circle
cx="22.48986"
cy="127.06135"
r="20.69419"
fill="none"
isolation="isolate"
opacity=".69"
id="circle6493" />
</g>
<line
x1="22.48986"
y1="110.78674"
x2="22.48986"
y2="119.73803"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="line6497" />
<line
x1="22.48986"
y1="56.2876"
x2="22.48986"
y2="65.2389"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="line6499" />
<path
d="m15.30245,201.92112c-4.18524-2.51474-6.75324-7.05367-6.75324-11.93631,0-7.63919,6.28611-13.9253,13.9253-13.9253s13.9253,6.28611,13.9253,13.9253c0,4.9171-2.60439,9.48308-6.83674,11.98609l-7.44259-12.12156"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="path6501" />
<path
d="m29.56306,249.96669c4.23236-2.50301,6.83674-7.06899,6.83674-11.98609,0-7.63919-6.28611-13.9253-13.9253-13.9253s-13.9253,6.28611-13.9253,13.9253c0,4.88264,2.568,9.42157,6.75324,11.93631l7.32949-12.51059"
fill="none"
stroke="#1f1f1f"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width=".8"
id="path6503" />
<g
id="g6513">
<circle
cx="23.00165"
cy="355.83101"
r="1.18571"
fill="#1f1f1f"
id="circle6505" />
<path
d="m14.35927,359.75298c-.34551,0-.66126-.1952-.8158-.50419l-2.96428-5.92856c-.22526-.45057-.04266-.99844.40794-1.2237.45008-.22535.99831-.04271,1.22366.4079l2.14848,4.29696,2.14848-4.29696c.22526-.45057.77314-.63325,1.22366-.4079.45061.22526.63321.77314.40794,1.2237l-2.96428,5.92856c-.15454.30899-.47029.50419-.8158.50419Z"
fill="#1f1f1f"
id="path6507" />
<path
d="m30.64073,359.75298c-.34551,0-.66126-.1952-.8158-.50419l-2.96428-5.92856c-.22526-.45057-.04266-.99844.40794-1.2237.45016-.22535.9984-.04271,1.22366.4079l2.14848,4.29696,2.14848-4.29696c.22526-.45057.77305-.63325,1.22366-.4079.45061.22526.63321.77314.40794,1.2237l-2.96428,5.92856c-.15454.30899-.47029.50419-.8158.50419Z"
fill="#1f1f1f"
id="path6509" />
<path
d="m22.94242,359.75298c-2.13744,0-3.87637-1.73893-3.87637-3.87637s1.73893-3.87637,3.87637-3.87637c.84653,0,1.65102.26819,2.32653.77554.40278.30253.48401.87428.18153,1.27705-.30248.40273-.87432.48401-1.2771.18148-.357-.26815-.78267-.4099-1.23096-.4099-1.13156,0-2.05219.92059-2.05219,2.05219s.92064,2.05219,2.05219,2.05219c.44829,0,.87396-.14176,1.23096-.4099.40269-.30271.97444-.22125,1.2771.18148.30248.40278.22125.97453-.18153,1.27705-.67551.50735-1.48.77554-2.32653.77554Z"
fill="#1f1f1f"
id="path6511" />
</g>
</g>
<g
id="uuid-06d277f6-1463-4a4e-9530-518f7d72c0ea"
data-name="FND TXT">
<g
id="g6528">
<path
d="m5.38184,102.25439v-.0166c0-1.64404,1.26855-3.02148,3.06348-3.02148s3.04688,1.36084,3.04688,3.00488v.0166c0,1.64453-1.26953,3.02148-3.06348,3.02148-1.79492,0-3.04688-1.36035-3.04688-3.00488Zm5.0332,0v-.0166c0-1.13525-.82617-2.07812-1.98633-2.07812s-1.96973.92627-1.96973,2.06152v.0166c0,1.13525.82617,2.06982,1.98633,2.06982s1.96973-.91797,1.96973-2.05322Z"
fill="#1f1f1f"
id="path6516" />
<path
d="m12.92188,99.83398c0-.29199.22559-.51758.51758-.51758h3.40527c.25879,0,.46777.20898.46777.46777s-.20898.46729-.46777.46729h-2.89648v1.59424h2.52148c.25879,0,.4668.2085.4668.46729s-.20801.46729-.4668.46729h-2.52148v1.91162c0,.28369-.22461.50879-.50879.50879-.29199,0-.51758-.2251-.51758-.50879v-4.85791Z"
fill="#1f1f1f"
id="path6518" />
<path
d="m18.49609,99.83398c0-.29199.22559-.51758.51758-.51758h3.40527c.25879,0,.46777.20898.46777.46777s-.20898.46729-.46777.46729h-2.89648v1.59424h2.52148c.25879,0,.4668.2085.4668.46729s-.20801.46729-.4668.46729h-2.52148v1.91162c0,.28369-.22461.50879-.50879.50879-.29199,0-.51758-.2251-.51758-.50879v-4.85791Z"
fill="#1f1f1f"
id="path6520" />
<path
d="m23.88086,104.5083c-.11621-.0835-.2002-.22559-.2002-.39258,0-.26709.2168-.47559.48438-.47559.1416,0,.2334.0415.30078.0918.4834.38379,1.00098.60107,1.63574.60107.63379,0,1.03516-.30078,1.03516-.73486v-.0166c0-.41699-.23438-.64258-1.31934-.89307-1.24316-.30029-1.94434-.66748-1.94434-1.74414v-.01709c0-1.00146.83496-1.69434,1.99512-1.69434.73438,0,1.32617.19238,1.85254.54297.11719.06641.22559.2085.22559.40869,0,.26709-.21777.47559-.48438.47559-.10059,0-.18359-.0249-.26758-.07471-.4502-.29248-.88379-.44238-1.34375-.44238-.60059,0-.95117.30859-.95117.69238v.01709c0,.45068.26758.65088,1.39355.91797,1.23535.30029,1.87012.74268,1.87012,1.71094v.0166c0,1.09375-.85938,1.74463-2.08691,1.74463-.79297,0-1.54395-.25049-2.19531-.73438Z"
fill="#1f1f1f"
id="path6522" />
<path
d="m29.58691,104.6416v-4.80762c0-.29199.22559-.51758.51758-.51758h3.39746c.25,0,.45898.20898.45898.45947,0,.2583-.20898.45898-.45898.45898h-2.88867v1.51904h2.5127c.25098,0,.45898.2085.45898.46729,0,.25049-.20801.45068-.45898.45068h-2.5127v1.56934h2.92969c.25098,0,.45996.2085.45996.45898,0,.25879-.20898.45898-.45996.45898h-3.43848c-.29199,0-.51758-.22559-.51758-.51758Z"
fill="#1f1f1f"
id="path6524" />
<path
d="m36.86719,100.26807h-1.41895c-.2666,0-.47559-.2168-.47559-.47559s.20898-.47607.47559-.47607h3.88184c.25879,0,.4668.21729.4668.47607s-.20801.47559-.4668.47559h-1.42773v4.42383c0,.28369-.2334.50879-.51758.50879-.2832,0-.51758-.2251-.51758-.50879v-4.42383Z"
fill="#1f1f1f"
id="path6526" />
</g>
<g
id="g6538">
<path
d="m11.68457,48.20996v-.0166c0-1.63574,1.25195-3.02148,3.01367-3.02148.87598,0,1.45996.20898,1.99414.59277.10059.0752.20898.2168.20898.41748,0,.27539-.22559.50879-.50879.50879-.13379,0-.23438-.05811-.31738-.1167-.37598-.27539-.78418-.45898-1.41895-.45898-1.07715,0-1.89453.94287-1.89453,2.06152v.0166c0,1.20215.79297,2.08691,1.98633,2.08691.55078,0,1.05176-.17529,1.41016-.44238v-1.09375h-1.15137c-.25,0-.45898-.19189-.45898-.44238,0-.25.20898-.45068.45898-.45068h1.62793c.29199,0,.5166.22559.5166.51758v1.56104c0,.29199-.11621.50049-.3584.65088-.50098.33398-1.20215.63428-2.07812.63428-1.82812,0-3.03027-1.30225-3.03027-3.00488Z"
fill="#1f1f1f"
id="path6530" />
<path
d="m18.25586,50.44678l2.1709-4.84082c.11621-.25879.3252-.41748.61719-.41748h.0498c.29199,0,.49316.15869.60938.41748l2.16992,4.84082c.04199.0752.05859.15039.05859.21729,0,.27539-.20801.49219-.48438.49219-.24121,0-.4082-.1416-.5-.35889l-.47559-1.09326h-2.83789l-.49316,1.12695c-.08301.2085-.25879.3252-.47559.3252-.2666,0-.47559-.2085-.47559-.47559,0-.0752.02539-.15039.06641-.23389Zm3.82324-1.65234l-1.02637-2.3623-1.02734,2.3623h2.05371Z"
fill="#1f1f1f"
id="path6532" />
<path
d="m25.16406,45.73975c0-.28418.22559-.50928.51758-.50928.28418,0,.50879.2251.50879.50928v4.90771c0,.28369-.22461.50879-.50879.50879-.29199,0-.51758-.2251-.51758-.50879v-4.90771Z"
fill="#1f1f1f"
id="path6534" />
<path
d="m27.94141,45.75635c0-.28369.22559-.51758.51758-.51758h.1084c.25098,0,.39258.125.53418.30029l2.92188,3.78125v-3.58887c0-.27588.22461-.50098.5-.50098.28418,0,.50977.2251.50977.50098v4.90771c0,.28369-.2168.50879-.50098.50879h-.04199c-.24219,0-.3916-.125-.53418-.30859l-3.00488-3.88965v3.70605c0,.27539-.22461.50049-.5.50049-.28418,0-.50977-.2251-.50977-.50049v-4.89941Z"
fill="#1f1f1f"
id="path6536" />
</g>
<g
id="g6548">
<path
d="m6.44336,20.49121c0-.5376.42578-.96289.96387-.96289h3.04004c1.11377,0,1.97705.3125,2.55273.88818.48779.48779.75098,1.17627.75098,2.00195v.0249c0,1.37646-.68848,2.22754-1.75195,2.66504l1.33887,1.62695c.1875.2373.3125.4375.3125.73828,0,.5376-.4502.88818-.91309.88818-.43799,0-.72559-.21289-.95117-.50049l-1.87646-2.37744h-1.53906v1.91455c0,.53809-.42529.96338-.96338.96338s-.96387-.42529-.96387-.96338v-6.90723Zm3.87891,3.29102c.93848,0,1.47656-.50049,1.47656-1.23877v-.0249c0-.82617-.57568-1.25098-1.51416-1.25098h-1.91406v2.51465h1.95166Z"
fill="#1f1f1f"
id="path6540" />
<path
d="m15.44482,27.36084c-.21289-.15039-.36279-.42529-.36279-.72607,0-.5.40039-.88818.90088-.88818.25,0,.42529.0874.55029.17529.66309.48779,1.38867.78809,2.23975.78809.78809,0,1.26367-.3125,1.26367-.82568v-.0249c0-.48828-.30029-.73828-1.76416-1.11377-1.76416-.45068-2.90283-.93848-2.90283-2.67725v-.02539c0-1.58887,1.27637-2.64014,3.06543-2.64014,1.06348,0,1.98975.27539,2.77783.77588.21289.125.42529.3877.42529.76318,0,.50049-.40039.88818-.90088.88818-.1875,0-.33789-.0498-.48779-.1377-.63818-.375-1.23877-.58789-1.83936-.58789-.73828,0-1.12598.33789-1.12598.76367v.02441c0,.57617.375.76367,1.88916,1.15137,1.77686.46289,2.77783,1.10107,2.77783,2.62793v.02441c0,1.73926-1.32617,2.71533-3.21582,2.71533-1.15088,0-2.31445-.3501-3.29053-1.05078Z"
fill="#1f1f1f"
id="path6542" />
<path
d="m23.21387,23.93262v-.02539c0-2.48975,1.87695-4.5293,4.56689-4.5293,1.31396,0,2.20215.35059,2.92822.88867.2002.1499.375.4248.375.7627,0,.52588-.42529.93848-.95068.93848-.2627,0-.43799-.09961-.57568-.1875-.53809-.40039-1.10107-.62549-1.78906-.62549-1.47656,0-2.54004,1.22607-2.54004,2.72754v.0249c0,1.50146,1.03857,2.75293,2.54004,2.75293.81299,0,1.35107-.25049,1.90186-.68848.1499-.125.3501-.2124.5752-.2124.48828,0,.90088.40039.90088.88818,0,.30029-.1499.53809-.3252.68848-.78809.68799-1.71387,1.10059-3.11523,1.10059-2.57764,0-4.49219-1.98926-4.49219-4.50391Z"
fill="#1f1f1f"
id="path6544" />
<path
d="m32.90918,20.4165c0-.53809.42578-.96338.96387-.96338s.96338.42529.96338.96338v6.11865h3.56592c.48779,0,.87598.3877.87598.87549s-.38818.87598-.87598.87598h-4.5293c-.53809,0-.96387-.42529-.96387-.96338v-6.90674Z"
fill="#1f1f1f"
id="path6546" />
</g>
<g
id="g6556">
<path
d="m15.01318,316.55127v-.01367c0-1.34814,1.06396-2.45264,2.52734-2.45264s2.51318,1.09082,2.51318,2.43945v.01318c0,1.34814-1.06348,2.45264-2.52686,2.45264s-2.51367-1.09082-2.51367-2.43896Zm3.94971,0v-.01367c0-.81299-.5957-1.49023-1.43604-1.49023s-1.42285.66357-1.42285,1.47705v.01318c0,.81299.59619,1.49072,1.43652,1.49072.83984,0,1.42236-.66406,1.42236-1.47705Z"
fill="#f0f0f0"
id="path6550" />
<path
d="m21.13232,316.87646v-2.229c0-.29102.23047-.52148.52148-.52148.2915,0,.52197.23047.52197.52148v2.20215c0,.77197.38574,1.17188,1.02295,1.17188.63672,0,1.02295-.38623,1.02295-1.13818v-2.23584c0-.29102.23047-.52148.52148-.52148.2915,0,.52197.23047.52197.52148v2.19531c0,1.43604-.80615,2.14062-2.08008,2.14062s-2.05273-.71143-2.05273-2.10693Z"
fill="#f0f0f0"
id="path6552" />
<path
d="m27.61719,315.12842h-1.00244c-.26416,0-.48096-.2168-.48096-.48096s.2168-.48096.48096-.48096h3.04834c.26465,0,.48145.2168.48145.48096s-.2168.48096-.48145.48096h-1.00244v3.29932c0,.2915-.23047.52197-.52197.52197-.29102,0-.52148-.23047-.52148-.52197v-3.29932Z"
fill="#f0f0f0"
id="path6554" />
</g>
<g
id="g6562">
<path
d="m19.30615,266.60156c0-.23047.18311-.41309.41992-.41309.23047,0,.41357.18262.41357.41309v3.9834c0,.23047-.18311.41357-.41357.41357-.23682,0-.41992-.18311-.41992-.41357v-3.9834Z"
fill="#1f1f1f"
id="path6558" />
<path
d="m21.61572,266.61523c0-.23047.18311-.41992.41992-.41992h.08838c.20312,0,.31836.10156.43359.24365l2.37109,3.06885v-2.91309c0-.22363.18262-.40625.40625-.40625.23047,0,.41309.18262.41309.40625v3.9834c0,.23047-.17578.41357-.40625.41357h-.03418c-.19629,0-.31836-.10156-.43359-.25049l-2.43848-3.15723v3.00781c0,.22363-.18311.40674-.40674.40674-.22998,0-.41309-.18311-.41309-.40674v-3.97656Z"
fill="#1f1f1f"
id="path6560" />
</g>
<g
id="g6570">
<path
d="m16.48438,215.25439c0-.23047.18262-.42041.41992-.42041h.08789c.18311,0,.30518.09521.38623.22363l1.43652,2.24951,1.44287-2.25635c.08789-.14209.20996-.2168.37939-.2168h.08838c.23682,0,.41992.18994.41992.42041v3.97021c0,.22998-.18311.41309-.41992.41309-.22363,0-.41357-.18945-.41357-.41309v-2.8457l-1.15869,1.74121c-.08789.13574-.19629.2168-.35205.2168-.14893,0-.25732-.08105-.3457-.2168l-1.15137-1.72754v2.83887c0,.22998-.18311.40625-.41357.40625s-.40625-.17627-.40625-.40625v-3.97705Z"
fill="#1f1f1f"
id="path6564" />
<path
d="m22.6377,215.24072c0-.23047.18262-.41357.41992-.41357.23047,0,.41309.18311.41309.41357v3.98389c0,.22998-.18262.41309-.41309.41309-.2373,0-.41992-.18311-.41992-.41309v-3.98389Z"
fill="#1f1f1f"
id="path6566" />
<path
d="m24.94727,215.25439c0-.23047.18262-.42041.41992-.42041h.08789c.20361,0,.31836.10156.43359.24414l2.37158,3.06934v-2.91357c0-.22363.18262-.40674.40625-.40674.23047,0,.41357.18311.41357.40674v3.98389c0,.23047-.17627.41309-.40674.41309h-.03369c-.19678,0-.31836-.10156-.43359-.25098l-2.43896-3.15674v3.0083c0,.22314-.18311.40625-.40674.40625-.23047,0-.41309-.18311-.41309-.40625v-3.97705Z"
fill="#1f1f1f"
id="path6568" />
</g>
<g
id="g6578">
<path
d="m15.22412,167.27881c0-.23047.18262-.42041.41992-.42041h.08789c.18311,0,.30518.09521.38623.22363l1.43652,2.24951,1.44287-2.25635c.08838-.14209.20996-.2168.37939-.2168h.08789c.2373,0,.42041.18994.42041.42041v3.97021c0,.22998-.18311.41309-.42041.41309-.22314,0-.41309-.18945-.41309-.41309v-2.8457l-1.1582,1.74121c-.08838.13574-.19678.2168-.35254.2168-.14893,0-.25732-.08105-.3457-.2168l-1.15137-1.72754v2.83887c0,.22998-.18311.40625-.41357.40625-.22998,0-.40625-.17627-.40625-.40625v-3.97705Z"
fill="#1f1f1f"
id="path6572" />
<path
d="m20.97021,171.08594l1.76123-3.9292c.09473-.20996.26416-.33887.50146-.33887h.04053c.2373,0,.3999.12891.49463.33887l1.76172,3.9292c.03369.06152.04736.12207.04736.17627,0,.22363-.16943.3999-.39307.3999-.19629,0-.33203-.11523-.40674-.2915l-.38574-.88721h-2.30371l-.39941.91455c-.06787.16943-.21045.26416-.38623.26416-.2168,0-.38623-.16943-.38623-.38623,0-.06104.02002-.12207.0542-.18994Zm3.10303-1.34131l-.8335-1.91748-.8335,1.91748h1.66699Z"
fill="#1f1f1f"
id="path6574" />
<path
d="m26.60107,170.96436l1.40918-1.74805-1.32764-1.646c-.06787-.08838-.12891-.19678-.12891-.31201,0-.22998.17627-.40674.41309-.40674.17627,0,.27783.06836.37939.20361l1.19922,1.57861,1.18555-1.55176c.1084-.14893.22363-.23047.40674-.23047.18262,0,.37939.14941.37939.37988,0,.12207-.04736.2168-.12891.31836l-1.32764,1.65283,1.39551,1.74121c.06787.08838.12891.18994.12891.31201,0,.22998-.17627.40625-.41357.40625-.17627,0-.27783-.06787-.37939-.20312l-1.27344-1.66016-1.25342,1.63281c-.11523.14941-.22363.23047-.40674.23047-.18945,0-.37939-.14941-.37939-.38623,0-.11523.04736-.20996.12207-.31152Z"
fill="#1f1f1f"
id="path6576" />
</g>
</g>
<g
id="uuid-7325cf2b-8eed-4c52-8f90-00d78380668c"
data-name="components"
inkscape:groupmode="layer"
style="display:none">
<circle
id="uuid-6b7de1fc-81ed-48d8-b84a-a17b442d19d7"
data-name="In#PJ301MPort"
cx="22.5"
cy="286.00003"
r="5"
fill="#00ff00" />
<circle
id="uuid-3762b4fd-9a93-41fd-a5a2-7ab915fc8aa6"
data-name="Out#PJ301MPort"
cx="22.5"
cy="334"
r="5"
fill="#0000ff" />
<circle
id="uuid-e8d36fd9-e3da-406d-bbdd-3517776d0bd4"
data-name="In#PJ301MPort"
cx="22.5"
cy="286"
r="5"
fill="#00ff00" />
<circle
id="uuid-f4fb15da-ec19-4d2b-93e7-1806b325749d"
data-name="Gain#RoundBlackKnob"
cx="22.5"
cy="72.999947"
r="5"
fill="#ff0000" />
<circle
id="uuid-b94e1723-f3e2-45fb-9947-7db05befdb87"
data-name="Offset#RoundBlackKnob"
cx="22.489861"
cy="127.06135"
r="5"
fill="#ff0000" />
<circle
id="uuid-cd4dfb41-5aef-4ac0-9daf-2fb02d037e7c"
data-name="Max#RoundSmallBlackKnob"
cx="22.47665"
cy="189.99173"
r="5"
fill="#ff0000" />
<circle
id="uuid-447af012-8785-4df0-a7fb-37d82470eba6"
data-name="Min#RoundSmallBlackKnob"
cx="22.476191"
cy="237.983"
r="5"
fill="#ff0000" />
</g>
</svg>

+ 153
- 0
src/Rescale.cpp View File

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


struct Rescale : Module {
enum ParamId {
GAIN_PARAM,
OFFSET_PARAM,
MAX_PARAM,
MIN_PARAM,
PARAMS_LEN
};
enum InputId {
IN_INPUT,
INPUTS_LEN
};
enum OutputId {
OUT_OUTPUT,
OUTPUTS_LEN
};
enum LightId {
LIGHTS_LEN
};

float multiplier = 1.f;
bool reflectMin = false;
bool reflectMax = false;

Rescale() {
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);

struct GainQuantity : ParamQuantity {
float getDisplayValue() override {
Rescale* module = reinterpret_cast<Rescale*>(this->module);
if (module->multiplier == 1.f) {
unit = "%";
displayMultiplier = 100.f;
}
else {
unit = "x";
displayMultiplier = module->multiplier;
}
return ParamQuantity::getDisplayValue();
}
};
configParam<GainQuantity>(GAIN_PARAM, -1.f, 1.f, 0.f, "Gain", "%", 0, 100);
configParam(OFFSET_PARAM, -10.f, 10.f, 0.f, "Offset", " V");
configParam(MAX_PARAM, -10.f, 10.f, 10.f, "Maximum", " V");
configParam(MIN_PARAM, -10.f, 10.f, -10.f, "Minimum", " V");
configInput(IN_INPUT, "Signal");
configOutput(OUT_OUTPUT, "Signal");
configBypass(IN_INPUT, OUT_OUTPUT);
}

void process(const ProcessArgs& args) override {
using simd::float_4;

int channels = std::max(1, inputs[IN_INPUT].getChannels());

float gain = params[GAIN_PARAM].getValue() * multiplier;
float offset = params[OFFSET_PARAM].getValue();
float min = params[MIN_PARAM].getValue();
float max = params[MAX_PARAM].getValue();

for (int c = 0; c < channels; c += 4) {
float_4 x = inputs[IN_INPUT].getPolyVoltageSimd<float_4>(c);
x = x * gain + offset;

if (reflectMin && reflectMax) {
// TODO find a pen to work this out
}
else if (reflectMin) {
x = simd::fabs(x - min) + min;
x = simd::fmin(x, max);
}
else if (reflectMax) {
x = max - simd::fabs(max - x);
x = simd::fmax(x, min);
}
else {
x = simd::clamp(x, min, max);
}

outputs[OUT_OUTPUT].setVoltageSimd(x, c);
}

outputs[OUT_OUTPUT].setChannels(channels);
}

json_t* dataToJson() override {
json_t* rootJ = json_object();
json_object_set_new(rootJ, "multiplier", json_real(multiplier));
json_object_set_new(rootJ, "reflectMin", json_boolean(reflectMin));
json_object_set_new(rootJ, "reflectMax", json_boolean(reflectMax));
return rootJ;
}

void dataFromJson(json_t* rootJ) override {
json_t* multiplierJ = json_object_get(rootJ, "multiplier");
if (multiplierJ)
multiplier = json_number_value(multiplierJ);

json_t* reflectMinJ = json_object_get(rootJ, "reflectMin");
if (reflectMinJ)
reflectMin = json_number_value(reflectMinJ);

json_t* reflectMaxJ = json_object_get(rootJ, "reflectMax");
if (reflectMaxJ)
reflectMax = json_number_value(reflectMaxJ);
}
};


struct RescaleWidget : ModuleWidget {
RescaleWidget(Rescale* module) {
setModule(module);
setPanel(createPanel(asset::plugin(pluginInstance, "res/Rescale.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, Rescale::GAIN_PARAM));
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(7.617, 43.031)), module, Rescale::OFFSET_PARAM));
addParam(createParamCentered<RoundSmallBlackKnob>(mm2px(Vec(7.612, 64.344)), module, Rescale::MAX_PARAM));
addParam(createParamCentered<RoundSmallBlackKnob>(mm2px(Vec(7.612, 80.597)), module, Rescale::MIN_PARAM));

addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.62, 96.859)), module, Rescale::IN_INPUT));

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

void appendContextMenu(Menu* menu) override {
Rescale* module = getModule<Rescale>();

menu->addChild(new MenuSeparator);

menu->addChild(createIndexSubmenuItem("Gain multiplier", {"1x", "10x", "100x", "1000x"},
[=]() {
return (int) std::log10(module->multiplier);
},
[=](int mode) {
module->multiplier = std::pow(10.f, (float) mode);
}
));

menu->addChild(createBoolPtrMenuItem("Reflect at minimum", "", &module->reflectMin));
menu->addChild(createBoolPtrMenuItem("Reflect at maximum", "", &module->reflectMax));
}
};


Model* modelRescale = createModel<Rescale, RescaleWidget>("Rescale");

+ 1
- 0
src/plugin.cpp View File

@@ -41,4 +41,5 @@ void init(Plugin* p) {
p->addModel(modelGates);
p->addModel(modelProcess);
p->addModel(modelMult);
p->addModel(modelRescale);
}

+ 1
- 0
src/plugin.hpp View File

@@ -41,6 +41,7 @@ extern Model* modelCompare;
extern Model* modelGates;
extern Model* modelProcess;
extern Model* modelMult;
extern Model* modelRescale;


struct DigitalDisplay : Widget {


Loading…
Cancel
Save