Browse Source

Finish Noise. Finish Random except TRIG input.

tags/v1.3.0
Andrew Belt 4 years ago
parent
commit
9630825950
8 changed files with 2273 additions and 28 deletions
  1. +3
    -1
      CHANGELOG.md
  2. +16
    -0
      plugin.json
  3. +327
    -0
      res/Noise.svg
  4. +1483
    -0
      res/Random.svg
  5. +231
    -0
      src/Noise.cpp
  6. +182
    -0
      src/Random.cpp
  7. +4
    -2
      src/plugin.cpp
  8. +27
    -25
      src/plugin.hpp

+ 3
- 1
CHANGELOG.md View File

@@ -1,5 +1,7 @@
### ??? (in development)
### 1.3.0 (in development)
- Add Random and Noise modules.
- Make VCA-1 display polyphonic CV.
- Add VU meters to level sliders in Mixer.

### 1.2.1 (2019-08-10)
- Fix VCO hard sync bug, resulting in aliasing.


+ 16
- 0
plugin.json View File

@@ -228,6 +228,22 @@
"Quantizer",
"Polyphonic"
]
},
{
"slug": "Random",
"name": "Random",
"description": "Random CV generator",
"tags": [
"Random"
]
},
{
"slug": "Noise",
"name": "Noise",
"description": "Multicolored noise generator",
"tags": [
"Noise"
]
}
]
}

+ 327
- 0
res/Noise.svg View File

@@ -0,0 +1,327 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<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="15.24mm"
height="128.5mm"
viewBox="0 0 15.24 128.5"
version="1.1"
id="svg4352"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="Noise.svg">
<defs
id="defs4346" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="107.17223"
inkscape:cy="234.02924"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-bbox="true"
inkscape:snap-nodes="false"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-others="false"
inkscape:snap-page="true"
inkscape:window-width="1600"
inkscape:window-height="882"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="0"
inkscape:bbox-nodes="false"
inkscape:pagecheckerboard="true" />
<metadata
id="metadata4349">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-168.5)">
<path
inkscape:connector-curvature="0"
style="fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="M 0.093697,168.59371 H 15.147395 V 296.90698 H 0.093697 Z m 0,0"
id="path102534" />
<path
inkscape:connector-curvature="0"
style="fill:#ababab;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="M 15.241092,168.5 H 0 V 296.99931 H 15.241092 Z M 15.053699,296.81328 H 0.187393 V 168.68741 h 14.866306 z m 0,0"
id="path102536" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 2.399487,177.76748 c 0,0.17639 0.143333,0.32522 0.319723,0.32522 0.17639,0 0.319688,-0.14883 0.319688,-0.32522 v -1.5875 l 1.306407,1.71428 c 0.08819,0.11024 0.18189,0.18741 0.336232,0.18741 h 0.02188 c 0.181893,0 0.325229,-0.14331 0.325229,-0.32521 v -2.35921 c 0,-0.17638 -0.143336,-0.3197 -0.319726,-0.3197 -0.176387,0 -0.325225,0.14332 -0.325225,0.3197 v 1.52687 l -1.25677,-1.64813 c -0.08819,-0.11576 -0.181891,-0.19293 -0.336233,-0.19293 h -0.06615 c -0.18189,0 -0.325225,0.14332 -0.325225,0.32522 z m 0,0"
id="path112935" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 7.212118,178.11475 c 0.915035,0 1.576493,-0.68902 1.576493,-1.53238 v -0.005 c 0,-0.84336 -0.655955,-1.52687 -1.570955,-1.52687 -0.915035,0 -1.576494,0.68902 -1.576494,1.53238 v 0.011 c 0,0.84336 0.655955,1.52135 1.570956,1.52135 z m 0.0056,-0.60083 c -0.523664,0 -0.898488,-0.42443 -0.898488,-0.93155 v -0.005 c 0,-0.50712 0.363783,-0.92605 0.89295,-0.92605 0.523663,0 0.892987,0.42444 0.892987,0.93156 v 0.011 c 0,0.50712 -0.36382,0.92053 -0.887449,0.92053 z m 0,0"
id="path112943" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.416274,177.76197 c 0,0.1819 0.143333,0.33073 0.325226,0.33073 0.181891,0 0.325226,-0.14883 0.325226,-0.33073 v -2.3592 c 0,-0.1819 -0.143335,-0.32522 -0.325226,-0.32522 -0.181893,0 -0.325226,0.14332 -0.325226,0.32522 z m 0,0"
id="path112939" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 11.897817,178.10923 c 0.639411,0 1.085887,-0.33073 1.085887,-0.92053 v -0.011 c 0,-0.51263 -0.336232,-0.7276 -0.937048,-0.88745 -0.512622,-0.1323 -0.639411,-0.19293 -0.639411,-0.38585 v -0.011 c 0,-0.14332 0.126789,-0.25908 0.380331,-0.25908 0.203941,0 0.407916,0.0717 0.622864,0.19844 0.04964,0.0331 0.09924,0.0496 0.165383,0.0496 0.165346,0 0.303175,-0.13229 0.303175,-0.30317 0,-0.12678 -0.07168,-0.21497 -0.143333,-0.25907 -0.270086,-0.16536 -0.578768,-0.25907 -0.942586,-0.25907 -0.606319,0 -1.036285,0.35278 -1.036285,0.89297 v 0.006 c 0,0.5898 0.385868,0.75517 0.981181,0.90951 0.496075,0.12678 0.600815,0.20946 0.600815,0.37482 v 0.011 c 0,0.17088 -0.165346,0.27561 -0.429929,0.27561 -0.286634,0 -0.534707,-0.0992 -0.755192,-0.26458 -0.0441,-0.0331 -0.104704,-0.0606 -0.187397,-0.0606 -0.170883,0 -0.308678,0.13229 -0.308678,0.30317 0,0.0992 0.0551,0.19292 0.126788,0.24253 0.330729,0.23702 0.722064,0.35829 1.113435,0.35829 z m 0,0"
id="path112947" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,182.39476 c 0,-0.54984 -0.450602,-1.00046 -1.000443,-1.00046 H 3.779943 c -0.549841,0 -1.000443,0.45062 -1.000443,1.00046 v 12.17359 c 0,0.54846 0.450602,0.99908 1.000443,0.99908 h 7.681206 c 0.549841,0 1.000443,-0.45062 1.000443,-0.99908 z m 0,0"
id="path105162" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 5.232434,184.61063 c 0.03316,0.0937 0.0992,0.14882 0.181893,0.14882 h 0.03859 c 0.08819,0 0.148802,-0.0551 0.18189,-0.14882 l 0.314185,-0.91502 0.319723,0.91502 c 0.03316,0.0937 0.0937,0.14882 0.181893,0.14882 h 0.03316 c 0.08819,0 0.154339,-0.0551 0.187431,-0.14882 l 0.446476,-1.25677 c 0.0056,-0.0221 0.01659,-0.0496 0.01659,-0.0717 0,-0.0937 -0.08269,-0.17088 -0.176388,-0.17088 -0.0882,0 -0.148838,0.0606 -0.170886,0.12678 l -0.319688,0.98668 -0.319723,-0.97566 c -0.02752,-0.0882 -0.08819,-0.14331 -0.176387,-0.14331 h -0.02752 c -0.0937,0 -0.154342,0.0606 -0.181893,0.14331 l -0.319714,0.97566 -0.319688,-0.98668 c -0.02188,-0.0717 -0.08819,-0.12678 -0.170887,-0.12678 -0.09923,0 -0.18189,0.0772 -0.18189,0.17639 0,0.0165 0.0056,0.0441 0.01659,0.0661 z m 0,0"
id="path112951" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 7.458464,184.56653 c 0,0.0992 0.07715,0.17639 0.176387,0.17639 0.0992,0 0.176389,-0.0772 0.176389,-0.17639 v -0.47956 h 0.650418 v 0.47956 c 0,0.0992 0.07719,0.17639 0.176387,0.17639 0.09924,0 0.17639,-0.0772 0.17639,-0.17639 v -1.27882 c 0,-0.0992 -0.07715,-0.17639 -0.17639,-0.17639 -0.0992,0 -0.176387,0.0772 -0.176387,0.17639 v 0.47405 H 7.81124 v -0.47405 c 0,-0.0992 -0.07719,-0.17639 -0.176389,-0.17639 -0.09924,0 -0.176387,0.0772 -0.176387,0.17639 z m 0,0"
id="path112959" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.628716,184.56653 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 0.0992,0 0.176387,-0.0772 0.176387,-0.17639 v -1.11345 h 0.336233 c 0.0937,0 0.165383,-0.0717 0.165383,-0.16537 0,-0.0882 -0.07168,-0.15985 -0.165383,-0.15985 h -1.03078 c -0.0882,0 -0.159845,0.0717 -0.159845,0.15985 0,0.0937 0.07165,0.16537 0.159845,0.16537 h 0.34177 z m 0,0"
id="path112955" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,272.39444 c 0,-0.54984 -0.450602,-0.99908 -1.000443,-0.99908 H 3.779943 c -0.549841,0 -1.000443,0.44924 -1.000443,0.99908 v 12.17359 c 0,0.54983 0.450602,0.99908 1.000443,0.99908 h 7.681206 c 0.549841,0 1.000443,-0.44925 1.000443,-0.99908 z m 0,0"
id="path105238" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 4.531005,274.55555 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 h 0.584271 c 0.363821,0 0.600851,-0.14883 0.600851,-0.44098 v -0.005 c 0,-0.21497 -0.110242,-0.3197 -0.297673,-0.39136 0.115745,-0.0661 0.209479,-0.16537 0.209479,-0.34727 v -0.005 c 0,-0.11024 -0.03316,-0.19844 -0.110244,-0.2701 -0.08819,-0.0937 -0.23703,-0.14331 -0.418923,-0.14331 H 4.707395 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17638 z m 0.341736,-0.77722 v -0.34175 H 5.22552 c 0.148837,0 0.231529,0.0606 0.231529,0.16536 v 0.006 c 0,0.11575 -0.09924,0.17087 -0.25908,0.17087 z m 0,0.64492 v -0.35277 H 5.28066 c 0.181893,0 0.264583,0.0661 0.264583,0.17087 v 0.005 c 0,0.12127 -0.0937,0.17639 -0.253577,0.17639 z m 0,0"
id="path112963" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 6.275599,274.55555 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 h 0.832307 c 0.08819,0 0.15988,-0.0717 0.15988,-0.15986 0,-0.0882 -0.07169,-0.15985 -0.15988,-0.15985 h -0.65592 v -1.12448 c 0,-0.0992 -0.07719,-0.17639 -0.176387,-0.17639 -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0,0"
id="path112971" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 8.444619,274.7595 c 0.259043,0 0.429929,-0.0772 0.573262,-0.20395 0.03316,-0.0275 0.06061,-0.0717 0.06061,-0.12127 0,-0.0937 -0.07715,-0.16536 -0.165346,-0.16536 -0.0441,0 -0.07719,0.0165 -0.104741,0.0386 -0.10474,0.0827 -0.198437,0.12678 -0.352777,0.12678 -0.270086,0 -0.463021,-0.23151 -0.463021,-0.50712 0,-0.27561 0.192935,-0.50161 0.463021,-0.50161 0.126789,0 0.231527,0.0386 0.330729,0.11576 0.02752,0.0165 0.05514,0.0331 0.104738,0.0331 0.0992,0 0.17639,-0.0772 0.17639,-0.17088 0,-0.0662 -0.03316,-0.11576 -0.07165,-0.14332 -0.132292,-0.0992 -0.292171,-0.15985 -0.534704,-0.15985 -0.496078,0 -0.837849,0.37483 -0.837849,0.82682 v 0.006 c 0,0.46302 0.352777,0.82682 0.821339,0.82682 z m 0,0"
id="path112967" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.459206,274.56657 c 0,0.0992 0.07715,0.17639 0.176389,0.17639 0.0992,0 0.17639,-0.0772 0.17639,-0.17639 v -0.31971 l 0.203941,-0.18741 0.457518,0.60083 c 0.03859,0.0496 0.07715,0.0827 0.148836,0.0827 0.104703,0 0.176389,-0.0717 0.176389,-0.17088 0,-0.0496 -0.01659,-0.0882 -0.0441,-0.12127 l -0.496112,-0.61736 0.452014,-0.42443 c 0.03856,-0.0386 0.06615,-0.0772 0.06615,-0.13229 0,-0.0882 -0.06615,-0.16537 -0.16538,-0.16537 -0.06064,0 -0.104741,0.0275 -0.148839,0.0717 L 9.811987,273.828 v -0.54019 c 0,-0.0992 -0.07719,-0.17639 -0.17639,-0.17639 -0.09924,0 -0.176389,0.0772 -0.176389,0.17639 z m 0,0"
id="path112975" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,257.39449 c 0,-0.54984 -0.450602,-1.00045 -1.000443,-1.00045 H 3.779943 c -0.549841,0 -1.000443,0.45061 -1.000443,1.00045 v 12.17359 c 0,0.54984 0.450602,0.99908 1.000443,0.99908 h 7.681206 c 0.549841,0 1.000443,-0.44924 1.000443,-0.99908 z m 0,0"
id="path105254" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,242.39454 c 0,-0.54983 -0.450602,-0.99907 -1.000443,-0.99907 H 3.779943 c -0.549841,0 -1.000443,0.44924 -1.000443,0.99907 v 12.17359 c 0,0.54984 0.450602,0.99908 1.000443,0.99908 h 7.681206 c 0.549841,0 1.000443,-0.44924 1.000443,-0.99908 z m 0,0"
id="path105256" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,227.3946 c 0,-0.54984 -0.450602,-1.00046 -1.000443,-1.00046 H 3.779943 c -0.549841,0 -1.000443,0.45062 -1.000443,1.00046 v 12.17221 c 0,0.55122 0.450602,1.00046 1.000443,1.00046 h 7.681206 c 0.549841,0 1.000443,-0.44924 1.000443,-1.00046 z m 0,0"
id="path105258" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,212.39465 c 0,-0.54984 -0.450602,-1.00046 -1.000443,-1.00046 H 3.779943 c -0.549841,0 -1.000443,0.45062 -1.000443,1.00046 v 12.17359 c 0,0.54984 0.450602,0.99908 1.000443,0.99908 h 7.681206 c 0.549841,0 1.000443,-0.44924 1.000443,-0.99908 z m 0,0"
id="path105260" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 5.233458,214.56609 c 0,0.0992 0.07715,0.17638 0.17639,0.17638 0.0992,0 0.176387,-0.0772 0.176387,-0.17638 v -0.34727 h 0.281093 l 0.347276,0.43546 c 0.03859,0.0496 0.0937,0.0882 0.170884,0.0882 0.0882,0 0.170887,-0.0606 0.170887,-0.15985 0,-0.0551 -0.02752,-0.0937 -0.06064,-0.13781 L 6.2532,214.14717 c 0.192934,-0.0772 0.319688,-0.23703 0.319688,-0.48507 v -0.005 c 0,-0.15434 -0.0496,-0.27561 -0.137795,-0.36931 -0.104741,-0.10474 -0.264584,-0.15986 -0.468525,-0.15986 H 5.409851 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0.352777,-0.66146 v -0.45751 h 0.352779 c 0.17085,0 0.27559,0.0772 0.27559,0.226 v 0.005 c 0,0.1378 -0.0992,0.226 -0.270086,0.226 z m 0,0"
id="path112979" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 7.155569,214.73145 h 0.898453 c 0.08819,0 0.15988,-0.0661 0.15988,-0.15434 0,-0.0882 -0.07169,-0.15986 -0.15988,-0.15986 H 7.331956 v -0.33624 h 0.611822 c 0.08269,0 0.154342,-0.0717 0.154342,-0.15433 0,-0.0882 -0.07165,-0.15986 -0.154342,-0.15986 H 7.331956 v -0.32521 h 0.711059 c 0.08819,0 0.159843,-0.0717 0.159843,-0.15435 0,-0.0882 -0.07165,-0.15985 -0.159843,-0.15985 H 7.155569 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 v 1.25126 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 z m 0,0"
id="path112987" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 8.595783,214.55506 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 H 9.22415 c 0.501615,0 0.848889,-0.35278 0.848889,-0.80477 0,-0.452 -0.347274,-0.79927 -0.848889,-0.79927 H 8.772173 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0.352777,-0.14332 v -0.96462 h 0.27559 c 0.286634,0 0.479568,0.19843 0.479568,0.47956 v 0.005 c 0,0.28663 -0.192934,0.47956 -0.479568,0.47956 z m 0,0"
id="path112983" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 12.461592,197.3947 c 0,-0.54983 -0.450602,-1.00045 -1.000443,-1.00045 H 3.779943 c -0.549841,0 -1.000443,0.45062 -1.000443,1.00045 v 12.17222 c 0,0.54983 0.450602,1.00045 1.000443,1.00045 h 7.681206 c 0.549841,0 1.000443,-0.45062 1.000443,-1.00045 z m 0,0"
id="path105272" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 4.822788,199.56579 c 0,0.0992 0.07715,0.17639 0.176389,0.17639 0.0992,0 0.17639,-0.0772 0.17639,-0.17639 v -0.31419 h 0.270087 c 0.35828,0 0.644914,-0.19293 0.644914,-0.56775 v -0.006 c 0,-0.32522 -0.231495,-0.55122 -0.611823,-0.55122 H 4.999177 c -0.09924,0 -0.176389,0.0772 -0.176389,0.17639 z m 0.352779,-0.62838 v -0.49058 h 0.27559 c 0.17639,0 0.286631,0.0827 0.286631,0.24253 v 0.005 c 0,0.1378 -0.104703,0.24253 -0.281093,0.24253 z m 0,0"
id="path112995" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 6.437558,199.56579 c 0,0.0992 0.07719,0.17639 0.17639,0.17639 0.09924,0 0.17639,-0.0772 0.17639,-0.17639 v -1.27882 c 0,-0.0992 -0.07715,-0.17639 -0.17639,-0.17639 -0.0992,0 -0.17639,0.0772 -0.17639,0.17639 z m 0,0"
id="path112991" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 7.268562,199.5713 c 0,0.0937 0.07715,0.17088 0.176389,0.17088 0.0937,0 0.170887,-0.0772 0.170887,-0.17088 v -0.85989 l 0.705554,0.92604 c 0.0496,0.0606 0.0992,0.10473 0.187396,0.10473 h 0.01093 c 0.0992,0 0.17639,-0.0772 0.17639,-0.17639 v -1.27882 c 0,-0.0992 -0.07719,-0.17639 -0.17639,-0.17639 -0.09373,0 -0.176387,0.0772 -0.176387,0.17639 v 0.82683 l -0.678005,-0.89297 c -0.0496,-0.0606 -0.09923,-0.10473 -0.181891,-0.10473 h -0.03859 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17638 z m 0,0"
id="path112999" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.167389,199.56579 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 0.0992,0 0.176387,-0.0772 0.176387,-0.17639 v -0.3197 l 0.203941,-0.18742 0.457517,0.60083 c 0.03856,0.0496 0.07715,0.0827 0.148802,0.0827 0.10474,0 0.176389,-0.0717 0.176389,-0.17088 0,-0.0496 -0.01659,-0.0882 -0.0441,-0.12127 l -0.496075,-0.61736 0.45198,-0.42443 c 0.03859,-0.0386 0.06615,-0.0772 0.06615,-0.1323 0,-0.0882 -0.06615,-0.16536 -0.165349,-0.16536 -0.06064,0 -0.104738,0.0276 -0.148836,0.0717 l -0.6504168,0.64492 v -0.54019 c 0,-0.0992 -0.07719,-0.17639 -0.176387,-0.17639 -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0,0"
id="path113003" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 4.655359,244.55599 c 0,0.0992 0.07715,0.17638 0.17639,0.17638 H 5.41602 c 0.363821,0 0.600851,-0.14882 0.600851,-0.44097 v -0.005 c 0,-0.21497 -0.110242,-0.3197 -0.297672,-0.39136 0.115744,-0.0661 0.209478,-0.16537 0.209478,-0.34726 v -0.006 c 0,-0.11026 -0.03316,-0.19844 -0.110244,-0.2701 -0.08819,-0.0937 -0.237029,-0.14332 -0.418923,-0.14332 H 4.831749 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17638 z m 0.341736,-0.77722 v -0.34175 h 0.35278 c 0.148836,0 0.231529,0.0606 0.231529,0.16537 v 0.006 c 0,0.11575 -0.09924,0.17087 -0.25908,0.17087 z m 0,0.64493 v -0.35278 h 0.407919 c 0.181893,0 0.264583,0.0661 0.264583,0.17087 v 0.006 c 0,0.12127 -0.0937,0.17639 -0.253577,0.17639 z m 0,0"
id="path113007" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 6.324494,244.55599 c 0,0.0992 0.07715,0.17638 0.17639,0.17638 h 0.832342 c 0.0882,0 0.159845,-0.0716 0.159845,-0.15985 0,-0.0882 -0.07165,-0.15985 -0.159845,-0.15985 H 6.677271 v -1.12448 c 0,-0.0992 -0.07719,-0.17639 -0.176387,-0.17639 -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0,0"
id="path113015" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 8.351237,244.75994 c 0.435469,0 0.705556,-0.24254 0.705556,-0.72761 v -0.74414 c 0,-0.0992 -0.07715,-0.17639 -0.17639,-0.17639 -0.0992,0 -0.176387,0.0772 -0.176387,0.17639 v 0.76068 c 0,0.25356 -0.132292,0.38585 -0.347276,0.38585 -0.214948,0 -0.347239,-0.1378 -0.347239,-0.39688 v -0.74965 c 0,-0.0992 -0.07719,-0.17639 -0.176387,-0.17639 -0.09373,0 -0.17639,0.0772 -0.17639,0.17639 v 0.75517 c 0,0.47404 0.264583,0.71658 0.694513,0.71658 z m 0,0"
id="path113011" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.60942,244.73237 h 0.898488 c 0.0882,0 0.159846,-0.0661 0.159846,-0.15433 0,-0.0882 -0.07165,-0.15986 -0.159846,-0.15986 H 9.785807 v -0.33624 h 0.61186 c 0.08266,0 0.154339,-0.0717 0.154339,-0.15434 0,-0.0882 -0.07168,-0.15985 -0.154339,-0.15985 h -0.61186 v -0.32522 h 0.71106 c 0.08819,0 0.159843,-0.0716 0.159843,-0.15434 0,-0.0882 -0.07165,-0.15985 -0.159843,-0.15985 H 9.60942 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 v 1.25126 c 0,0.0992 0.07715,0.17638 0.17639,0.17638 z m 0,0"
id="path113019" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 5.448829,229.75876 h 0.02188 c 0.09923,0 0.16538,-0.0551 0.198437,-0.14331 l 0.529167,-1.25677 c 0.0056,-0.022 0.01659,-0.0496 0.01659,-0.0772 0,-0.0937 -0.07719,-0.17088 -0.176387,-0.17088 -0.08269,0 -0.143335,0.0551 -0.170886,0.11576 l -0.402379,1.0473 -0.402378,-1.03628 c -0.02752,-0.0717 -0.0882,-0.12678 -0.17639,-0.12678 -0.09924,0 -0.176389,0.0772 -0.176389,0.17639 0,0.0275 0.0056,0.0551 0.01659,0.0827 l 0.523663,1.24575 c 0.03316,0.0882 0.09924,0.14331 0.198438,0.14331 z m 0,0"
id="path113027" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 6.540746,229.56584 c 0,0.0992 0.07719,0.17639 0.176389,0.17639 0.09924,0 0.17639,-0.0772 0.17639,-0.17639 v -1.27882 c 0,-0.0992 -0.07715,-0.17639 -0.17639,-0.17639 -0.0992,0 -0.176389,0.0772 -0.176389,0.17639 z m 0,0"
id="path113023" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 8.135691,229.75876 c 0.49611,0 0.859896,-0.37482 0.859896,-0.83233 0,-0.45751 -0.358283,-0.82682 -0.854393,-0.82682 -0.496077,0 -0.854358,0.37483 -0.854358,0.82682 v 0.006 c 0,0.45751 0.358281,0.82682 0.848855,0.82682 z m 0.0056,-0.32521 c -0.281094,0 -0.485069,-0.23151 -0.485069,-0.50712 0,-0.27561 0.198438,-0.50161 0.479565,-0.50161 0.286631,0 0.490572,0.226 0.490572,0.50161 v 0.006 c 0,0.27561 -0.198437,0.50161 -0.485068,0.50161 z m 0,0"
id="path113031" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.382971,229.55482 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 h 0.832342 c 0.0882,0 0.159846,-0.0717 0.159846,-0.15986 0,-0.0882 -0.07165,-0.15985 -0.159846,-0.15985 H 9.735748 v -1.12448 c 0,-0.0992 -0.07719,-0.17639 -0.176387,-0.17639 -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0,0"
id="path113035" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 5.266618,259.75882 c 0.242536,0 0.429932,-0.0827 0.562224,-0.15985 0.08269,-0.0496 0.126788,-0.12127 0.126788,-0.22601 v -0.39136 c 0,-0.0992 -0.08269,-0.17638 -0.181893,-0.17638 H 5.371359 c -0.08269,0 -0.15434,0.0717 -0.15434,0.15433 0,0.0882 0.07165,0.15434 0.15434,0.15434 h 0.242535 v 0.226 c -0.09373,0.0661 -0.203977,0.0992 -0.336269,0.0992 -0.281093,0 -0.485069,-0.21497 -0.485069,-0.51263 0,-0.27561 0.203976,-0.5016 0.463021,-0.5016 0.148836,0 0.253577,0.0386 0.347274,0.11024 0.02752,0.0165 0.06064,0.0386 0.110244,0.0386 0.0937,0 0.170886,-0.0827 0.170886,-0.17639 0,-0.0717 -0.0386,-0.11576 -0.07165,-0.14332 -0.143335,-0.0992 -0.303178,-0.15434 -0.545714,-0.15434 -0.485068,0 -0.843351,0.37483 -0.843351,0.82683 v 0.005 c 0,0.47404 0.341736,0.82682 0.843351,0.82682 z m 0,0"
id="path113039" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 6.30315,259.56589 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 0.0992,0 0.176389,-0.0772 0.176389,-0.17639 v -0.34727 h 0.281128 l 0.347239,0.43547 c 0.0386,0.0496 0.09373,0.0882 0.170887,0.0882 0.08819,0 0.170884,-0.0606 0.170884,-0.15986 0,-0.0551 -0.02752,-0.0937 -0.06064,-0.1378 l -0.242536,-0.29765 c 0.192934,-0.0772 0.319723,-0.23703 0.319723,-0.48507 v -0.005 c 0,-0.15434 -0.04964,-0.27561 -0.137832,-0.36932 -0.104704,-0.10473 -0.264584,-0.15985 -0.468525,-0.15985 H 6.47954 c -0.09924,0 -0.17639,0.0772 -0.17639,0.17639 z m 0.352779,-0.66146 v -0.45751 h 0.352777 c 0.170887,0 0.27559,0.0772 0.27559,0.226 v 0.006 c 0,0.13781 -0.0992,0.226 -0.270086,0.226 z m 0,0"
id="path113043" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 7.840945,259.58243 c 0,0.0882 0.07165,0.15985 0.165346,0.15985 0.07168,0 0.132292,-0.0386 0.15988,-0.10473 l 0.110241,-0.26459 h 0.71106 l 0.104741,0.24805 c 0.03316,0.0772 0.08819,0.12127 0.170849,0.12127 0.09373,0 0.165383,-0.0717 0.165383,-0.16536 0,-0.022 -0.0056,-0.0496 -0.01659,-0.0717 l -0.562221,-1.26228 c -0.0386,-0.0882 -0.104741,-0.14332 -0.203978,-0.14332 h -0.01659 c -0.09924,0 -0.170887,0.0551 -0.209482,0.14332 l -0.556717,1.26228 c -0.01093,0.022 -0.02188,0.0496 -0.02188,0.0772 z m 0.567759,-0.52366 0.220488,-0.52916 0.225988,0.52916 z m 0,0"
id="path113051" />
<path
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35277778"
d="m 9.970698,259.56589 c 0,0.0992 0.07715,0.17639 0.17639,0.17639 0.0992,0 0.17639,-0.0772 0.17639,-0.17639 v -0.46302 l 0.518123,-0.69453 c 0.02188,-0.0331 0.0441,-0.0772 0.0441,-0.12678 0,-0.0937 -0.06061,-0.17088 -0.17085,-0.17088 -0.07169,0 -0.126788,0.0386 -0.170886,0.10473 l -0.391372,0.56776 -0.391371,-0.56224 c -0.0441,-0.0661 -0.0937,-0.11025 -0.17639,-0.11025 -0.0992,0 -0.176387,0.0772 -0.176387,0.17088 0,0.0496 0.01659,0.0937 0.04409,0.12678 l 0.51816,0.70555 z m 0,0"
id="path113047" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 8.254436,288.975 c 0,0.22048 -0.179141,0.401 -0.401002,0.401 -0.220488,0 -0.401003,-0.18052 -0.401003,-0.401 0,-0.22187 0.180515,-0.40101 0.401003,-0.40101 0.221861,0 0.401002,0.17914 0.401002,0.40101"
id="path105592" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 4.932008,290.30067 c -0.117158,0 -0.224648,-0.0661 -0.277001,-0.17088 l -1.001818,-2.00367 c -0.07581,-0.15296 -0.01376,-0.33762 0.137795,-0.41478 0.151588,-0.0758 0.337608,-0.0138 0.413419,0.1378 l 0.727605,1.45383 0.726231,-1.45383 c 0.07578,-0.15159 0.261794,-0.2136 0.413385,-0.1378 0.152963,0.0772 0.213606,0.26182 0.137829,0.41478 L 5.2076,290.12979 c -0.05235,0.10473 -0.159845,0.17088 -0.275592,0.17088"
id="path105594" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 10.437249,290.30067 c -0.117124,0 -0.22324,-0.0661 -0.27559,-0.17088 l -1.003232,-2.00367 c -0.07578,-0.15296 -0.01376,-0.33762 0.137832,-0.41478 0.15293,-0.0758 0.337609,-0.0138 0.414761,0.1378 l 0.726229,1.45383 0.726228,-1.45383 c 0.07581,-0.15159 0.261832,-0.2136 0.413419,-0.1378 0.152964,0.0772 0.214982,0.26182 0.139171,0.41478 l -1.003194,2.00367 c -0.05239,0.10473 -0.158467,0.17088 -0.275624,0.17088"
id="path105596" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277778"
d="m 7.834135,290.30067 c -0.723477,0 -1.310497,-0.58843 -1.310497,-1.31052 0,-0.72347 0.58702,-1.31051 1.310497,-1.31051 0.285258,0 0.55813,0.0909 0.786871,0.26183 0.136419,0.10197 0.162597,0.29627 0.06064,0.43132 -0.101986,0.13643 -0.29492,0.16399 -0.431339,0.062 -0.121251,-0.0909 -0.264584,-0.13918 -0.416174,-0.13918 -0.38308,0 -0.694513,0.31144 -0.694513,0.69453 0,0.3831 0.311433,0.69316 0.694513,0.69316 0.15159,0 0.294923,-0.0469 0.416174,-0.13781 0.136419,-0.10197 0.329353,-0.0758 0.431339,0.0606 0.101955,0.13642 0.07578,0.33073 -0.06064,0.4327 -0.228741,0.17088 -0.501613,0.26183 -0.786871,0.26183"
id="path105598" />
</g>
<g
inkscape:groupmode="layer"
id="layer5"
inkscape:label="components"
style="display:none">
<circle
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle20236"
cx="7.6205459"
cy="21.726845"
r="3" />
<circle
r="3"
cy="36.726093"
cx="7.6205459"
id="circle115777"
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle115779"
cx="7.6205459"
cy="51.726727"
r="3" />
<circle
r="3"
cy="66.726677"
cx="7.6212339"
id="circle115781"
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle115783"
cx="7.6205459"
cy="81.726624"
r="3" />
<circle
r="3"
cy="96.72657"
cx="7.6205459"
id="circle115785"
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="display:inline;opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:0.50196078;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle115787"
cx="7.6205459"
cy="111.72652"
r="3" />
</g>
</svg>

+ 1483
- 0
res/Random.svg
File diff suppressed because it is too large
View File


+ 231
- 0
src/Noise.cpp View File

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


/** Based on "The Voss algorithm"
http://www.firstpr.com.au/dsp/pink-noise/
*/
template <int QUALITY = 8>
struct PinkNoiseGenerator {
int frame = -1;
float values[QUALITY] = {};

float process() {
int lastFrame = frame;
frame++;
if (frame >= (1 << QUALITY))
frame = 0;
int diff = lastFrame ^ frame;

float sum = 0.f;
for (int i = 0; i < QUALITY; i++) {
if (diff & (1 << i)) {
values[i] = random::uniform() - 0.5f;
}
sum += values[i];
}
return sum;
}
};


/**
a_0 is normalized to 1 and omitted from the `a` array, so its indices are shifted down by 1.
*/
template <int B_ORDER, int A_ORDER>
struct IIRFilter {
float b[B_ORDER] = {};
float a[A_ORDER - 1] = {};
float xState[B_ORDER] = {};
float yState[A_ORDER - 1] = {};

void setCoefficients(const float* b, const float* a) {
for (int i = 0; i < B_ORDER; i++) {
this->b[i] = b[i];
}
for (int i = 1; i < A_ORDER; i++) {
this->a[i - 1] = a[i - 1];
}
}

float process(float x) {
// Shift x state
for (int i = B_ORDER - 1; i >= 1; i--) {
xState[i] = xState[i - 1];
}
xState[0] = x;

float y = 0.f;
// Add x state
for (int i = 0; i < B_ORDER; i++) {
y += b[i] * xState[i];
}
// Subtract y state
for (int i = 1; i < A_ORDER; i++) {
y -= a[i - 1] * yState[i - 1];
}
// Shift y state
for (int i = A_ORDER - 1; i >= 2; i--) {
yState[i - 1] = yState[i - 2];
}
yState[0] = y;
return y;
}
};


struct InverseAWeightingFFTFilter {
static constexpr int BUFFER_LEN = 1024;

alignas(16) float inputBuffer[BUFFER_LEN] = {};
alignas(16) float outputBuffer[BUFFER_LEN] = {};
int frame = 0;
dsp::RealFFT fft;

InverseAWeightingFFTFilter() : fft(BUFFER_LEN) {}

float process(float deltaTime, float x) {
inputBuffer[frame] = x;
if (++frame >= BUFFER_LEN) {
frame = 0;
alignas(16) float freqBuffer[BUFFER_LEN * 2];
fft.rfft(inputBuffer, freqBuffer);

for (int i = 0; i < BUFFER_LEN; i++) {
float f = 1 / deltaTime / 2 / BUFFER_LEN * i;
float amp = 0.f;
if (80.f <= f && f <= 20000.f) {
float f2 = f * f;
// Inverse A-weighted curve
amp = ((424.36f + f2) * std::sqrt((11599.3f + f2) * (544496.f + f2)) * (148693636.f + f2)) / (148693636.f * f2 * f2);
}
freqBuffer[2 * i + 0] *= amp / BUFFER_LEN;
freqBuffer[2 * i + 1] *= amp / BUFFER_LEN;
}

fft.irfft(freqBuffer, outputBuffer);
}
return outputBuffer[frame];
}
};




struct Noise : Module {
enum ParamIds {
NUM_PARAMS
};
enum InputIds {
NUM_INPUTS
};
enum OutputIds {
WHITE_OUTPUT,
PINK_OUTPUT,
RED_OUTPUT,
VIOLET_OUTPUT,
BLUE_OUTPUT,
GRAY_OUTPUT,
BLACK_OUTPUT,
NUM_OUTPUTS
};
enum LightIds {
NUM_LIGHTS
};

dsp::ClockDivider blackDivider;
PinkNoiseGenerator<8> pinkNoiseGenerator;
IIRFilter<2, 2> redFilter;
float lastWhite = 0.f;
float lastPink = 0.f;
InverseAWeightingFFTFilter grayFilter;

// For calibrating levels
// float meanSqr = 0.f;

Noise() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);

// Hard-code coefficients for Butterworth lowpass with cutoff 20 Hz @ 44.1kHz.
const float b[] = {0.00425611, 0.00425611};
const float a[] = {-0.99148778};
redFilter.setCoefficients(b, a);
}

void process(const ProcessArgs& args) override {
// All noise is calibrated to 1 RMS.
// Then they should be scaled to match the RMS of a sine wave with 5V amplitude.
const float gain = 5.f / std::sqrt(2.f);

if (outputs[WHITE_OUTPUT].isConnected() || outputs[RED_OUTPUT].isConnected() || outputs[VIOLET_OUTPUT].isConnected() || outputs[GRAY_OUTPUT].isConnected()) {
// White noise: equal power density
float white = random::normal();
outputs[WHITE_OUTPUT].setVoltage(white * gain);

// Red/Brownian noise: -6dB/oct
if (outputs[RED_OUTPUT].isConnected()) {
float red = redFilter.process(white) / 0.0645f;
outputs[RED_OUTPUT].setVoltage(red * gain);
}

// Violet/purple noise: 6dB/oct
if (outputs[VIOLET_OUTPUT].isConnected()) {
float violet = (white - lastWhite) / 1.41f;
lastWhite = white;
outputs[VIOLET_OUTPUT].setVoltage(violet * gain);
}

// Gray noise: psychoacoustic equal loudness curve, specifically inverted A-weighted
if (outputs[GRAY_OUTPUT].isConnected()) {
float gray = grayFilter.process(args.sampleTime, white) / 1.67f;
outputs[GRAY_OUTPUT].setVoltage(gray * gain);
}
}

if (outputs[PINK_OUTPUT].isConnected() || outputs[BLUE_OUTPUT].isConnected()) {
// Pink noise: -3dB/oct
float pink = pinkNoiseGenerator.process() / 0.816f;
outputs[PINK_OUTPUT].setVoltage(pink * gain);

// Blue noise: 3dB/oct
if (outputs[BLUE_OUTPUT].isConnected()) {
float blue = (pink - lastPink) / 0.705f;
lastPink = pink;
outputs[BLUE_OUTPUT].setVoltage(blue * gain);
}
}

// Black noise: uniform noise
// Note: I made this definition up.
if (outputs[BLACK_OUTPUT].isConnected()) {
float u = random::uniform();
outputs[BLACK_OUTPUT].setVoltage(u * 10.f - 5.f);
}

// meanSqr += (std::pow(gray, 2.f) - meanSqr) * args.sampleTime / 10.f;
// DEBUG("%f", std::sqrt(meanSqr));
}
};


struct NoiseWidget : ModuleWidget {
NoiseWidget(Noise* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Noise.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)));

addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 21.727)), module, Noise::WHITE_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 36.726)), module, Noise::PINK_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 51.727)), module, Noise::RED_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 66.727)), module, Noise::VIOLET_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 81.727)), module, Noise::BLUE_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 96.727)), module, Noise::GRAY_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.621, 111.727)), module, Noise::BLACK_OUTPUT));
}
};


Model* modelNoise = createModel<Noise, NoiseWidget>("Noise");

+ 182
- 0
src/Random.cpp View File

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


struct Random : Module {
enum ParamIds {
RATE_PARAM,
SHAPE_PARAM,
OFFSET_PARAM,
RELATIVE_PARAM,
NUM_PARAMS
};
enum InputIds {
RATE_INPUT,
SHAPE_INPUT,
TRIGGER_INPUT,
EXTERNAL_INPUT,
NUM_INPUTS
};
enum OutputIds {
STEPPED_OUTPUT,
LINEAR_OUTPUT,
SMOOTH_OUTPUT,
EXPONENTIAL_OUTPUT,
NUM_OUTPUTS
};
enum LightIds {
RATE_LIGHT,
SHAPE_LIGHT,
NUM_LIGHTS
};

float lastValue = 0.f;
float value = 0.f;
float clockPhase = 0.f;

Random() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(RATE_PARAM, std::log2(0.001f), std::log2(1000.f), std::log2(2.f), "Rate", " Hz", 2);
configParam(SHAPE_PARAM, 0.f, 1.f, 0.f, "Shape", "%", 0, 100);
configParam(OFFSET_PARAM, 0.f, 1.f, 0.f, "Offset");
configParam(RELATIVE_PARAM, 0.f, 1.f, 0.f, "Quantize");
}

void process(const ProcessArgs& args) override {
// TODO TRIG input

// Clock
float rate = params[RATE_PARAM].getValue();
rate += inputs[RATE_PARAM].getVoltage();
float clockFreq = std::pow(2.f, rate);
float deltaPhase = std::fmin(clockFreq * args.sampleTime, 0.5f);
clockPhase += deltaPhase;
if (clockPhase >= 1.f) {
clockPhase -= 1.f;
lastValue = value;
if (inputs[EXTERNAL_INPUT].isConnected()) {
value = inputs[EXTERNAL_INPUT].getVoltage() / 10.f;
}
else {
// Choose a new random value
bool relative = params[RELATIVE_PARAM].getValue() > 0.f;
bool uni = params[OFFSET_PARAM].getValue() > 0.f;
if (relative) {
// Switch to uni if bi
if (!uni)
value += 0.5f;
float deltaValue = random::normal();
// Bias based on value
deltaValue -= (value - 0.5f) * 2.f;
// Scale delta and accumulate value
const float stdDev = 1 / 10.f;
deltaValue *= stdDev;
value += deltaValue;
value = clamp(value, 0.f, 1.f);
// Switch back to bi
if (!uni)
value -= 0.5f;
}
else {
value = random::uniform();
if (!uni)
value -= 0.5f;
}
}
lights[RATE_LIGHT].setBrightness(1.f);
}

// Shape
float shape = params[SHAPE_PARAM].getValue();
shape += inputs[SHAPE_INPUT].getVoltage() / 10.f;
shape = clamp(shape, 0.f, 1.f);

// Stepped
if (outputs[STEPPED_OUTPUT].isConnected()) {
float steps = std::floor(std::pow(shape + 1, 4));
float v = std::ceil(clockPhase * steps) / steps;
v = rescale(v, 0.f, 1.f, lastValue, value);
outputs[STEPPED_OUTPUT].setVoltage(v * 10.f);
}

// Linear
if (outputs[LINEAR_OUTPUT].isConnected()) {
float slope = 1 / (1 - shape);
float v;
if (slope < 1e6f) {
v = std::fmin(clockPhase * slope, 1.f);
}
else {
v = 1.f;
}
v = rescale(v, 0.f, 1.f, lastValue, value);
outputs[LINEAR_OUTPUT].setVoltage(v * 10.f);
}

// Exp
if (outputs[EXPONENTIAL_OUTPUT].isConnected()) {
float b = std::pow(1.f - shape, 4);
float v;
if (0.999f < b) {
v = clockPhase;
}
else if (1e-20f < b) {
v = (std::pow(b, clockPhase) - 1.f) / (b - 1.f);
}
else {
v = 1.f;
}
v = rescale(v, 0.f, 1.f, lastValue, value);
outputs[EXPONENTIAL_OUTPUT].setVoltage(v * 10.f);
}

// Smooth
if (outputs[SMOOTH_OUTPUT].isConnected()) {
float p = 1 / (1 - shape);
float v;
if (p < 1e6f) {
v = std::fmin(clockPhase * p, 1.f);
v = std::cos(M_PI * v);
}
else {
v = -1.f;
}
v = rescale(v, 1.f, -1.f, lastValue, value);
outputs[SMOOTH_OUTPUT].setVoltage(v * 10.f);
}

// Lights
lights[RATE_LIGHT].setSmoothBrightness(0.f, args.sampleTime);
lights[SHAPE_LIGHT].setBrightness(shape);
}
};


struct RandomWidget : ModuleWidget {
RandomWidget(Random* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Random.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(createLightParamCentered<LEDLightSlider<GreenLight>>(mm2px(Vec(7.215, 31.358)), module, Random::RATE_PARAM, Random::RATE_LIGHT));
addParam(createLightParamCentered<LEDLightSlider<GreenLight>>(mm2px(Vec(18.214, 31.358)), module, Random::SHAPE_PARAM, Random::SHAPE_LIGHT));
addParam(createParamCentered<CKSS>(mm2px(Vec(7.214, 78.498)), module, Random::OFFSET_PARAM));
addParam(createParamCentered<CKSS>(mm2px(Vec(18.214, 78.498)), module, Random::RELATIVE_PARAM));

addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.214, 51.227)), module, Random::RATE_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(18.214, 51.227)), module, Random::SHAPE_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.214, 64.763)), module, Random::TRIGGER_INPUT));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(18.214, 64.763)), module, Random::EXTERNAL_INPUT));

addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.214, 96.727)), module, Random::STEPPED_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.214, 96.727)), module, Random::LINEAR_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.214, 112.182)), module, Random::SMOOTH_OUTPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.214, 112.182)), module, Random::EXPONENTIAL_OUTPUT));
}
};


Model* modelRandom = createModel<Random, RandomWidget>("Random");

+ 4
- 2
src/plugin.cpp View File

@@ -1,9 +1,9 @@
#include "plugin.hpp"


Plugin *pluginInstance;
Plugin* pluginInstance;

void init(rack::Plugin *p) {
void init(rack::Plugin* p) {
pluginInstance = p;

p->addModel(modelVCO);
@@ -25,6 +25,8 @@ void init(rack::Plugin *p) {
p->addModel(modelSequentialSwitch2);
p->addModel(modelOctave);
p->addModel(modelQuantizer);
p->addModel(modelRandom);
p->addModel(modelNoise);
p->addModel(modelSplit);
p->addModel(modelMerge);
p->addModel(modelSum);


+ 27
- 25
src/plugin.hpp View File

@@ -4,29 +4,31 @@
using namespace rack;


extern Plugin *pluginInstance;
extern Plugin* pluginInstance;

extern Model *modelVCO;
extern Model *modelVCO2;
extern Model *modelVCF;
extern Model *modelVCA_1;
extern Model *modelVCA;
extern Model *modelLFO;
extern Model *modelLFO2;
extern Model *modelDelay;
extern Model *modelADSR;
extern Model *modelVCMixer;
extern Model *model_8vert;
extern Model *modelUnity;
extern Model *modelMutes;
extern Model *modelScope;
extern Model *modelSEQ3;
extern Model *modelSequentialSwitch1;
extern Model *modelSequentialSwitch2;
extern Model *modelOctave;
extern Model *modelQuantizer;
extern Model *modelSplit;
extern Model *modelMerge;
extern Model *modelSum;
extern Model *modelViz;
extern Model *modelMidSide;
extern Model* modelVCO;
extern Model* modelVCO2;
extern Model* modelVCF;
extern Model* modelVCA_1;
extern Model* modelVCA;
extern Model* modelLFO;
extern Model* modelLFO2;
extern Model* modelDelay;
extern Model* modelADSR;
extern Model* modelVCMixer;
extern Model* model_8vert;
extern Model* modelUnity;
extern Model* modelMutes;
extern Model* modelScope;
extern Model* modelSEQ3;
extern Model* modelSequentialSwitch1;
extern Model* modelSequentialSwitch2;
extern Model* modelOctave;
extern Model* modelQuantizer;
extern Model* modelRandom;
extern Model* modelNoise;
extern Model* modelSplit;
extern Model* modelMerge;
extern Model* modelSum;
extern Model* modelViz;
extern Model* modelMidSide;

Loading…
Cancel
Save