MCPcopy Create free account
hub / github.com/LabSound/LabSound / randomize

Method randomize

src/extended/SfxrNode.cpp:1075–1113  ·  view source on GitHub ↗

@TODO remove need for context lock see above

Source from the content-addressed store, hash-verified

1073
1074/// @TODO remove need for context lock see above
1075void SfxrNode::randomize()
1076{
1077 if (rnd(1))
1078 _startFrequency->setValue(cube(frnd(2) - 1) + 0.5f);
1079 else
1080 _startFrequency->setValue(sqr(frnd(1)));
1081 _minFrequency->setValue(0);
1082 _slide->setValue(powf(frnd(2) - 1, 5));
1083 if (_startFrequency->value() > 0.7 && _slide->value() > 0.2)
1084 _slide->setValue(-_slide->value());
1085 if (_startFrequency->value() < 0.2 && _slide->value() < -0.05)
1086 _slide->setValue(-_slide->value());
1087 _deltaSlide->setValue(powf(frnd(2) - 1, 3));
1088 _squareDuty->setValue(frnd(2) - 1);
1089 _dutySweep->setValue(powf(frnd(2) - 1, 3));
1090 _vibratoDepth->setValue(powf(frnd(2) - 1, 3));
1091 _vibratoSpeed->setValue(rndr(-1, 1));
1092 _attack->setValue(cube(rndr(0, 1)));
1093 _sustainTime->setValue(sqr(rndr(0, 1)));
1094 _decayTime->setValue(rndr(0, 1));
1095 _sustainPunch->setValue(powf(frnd(0.8f), 2));
1096 if (_attack->value() + _sustainTime->value() + _decayTime->value() < 0.2f)
1097 {
1098 _sustainTime->setValue(_sustainTime->value() + 0.2f + frnd(0.3f));
1099 _decayTime->setValue(_decayTime->value() + 0.2f + frnd(0.3f));
1100 }
1101 _lpFilterResonance->setValue(rndr(-1, 1));
1102 _lpFilterCutoff->setValue(1 - powf(frnd(1), 3));
1103 _lpFilterCutoffSweep->setValue(powf(frnd(2) - 1, 3));
1104 if (_lpFilterCutoff->value() < 0.1 && _lpFilterCutoffSweep->value() < -0.05f)
1105 _lpFilterCutoffSweep->setValue(-_lpFilterCutoffSweep->value());
1106 _hpFilterCutoff->setValue(powf(frnd(1), 5));
1107 _hpFilterCutoffSweep->setValue(powf(frnd(2) - 1, 5));
1108 _phaserOffset->setValue(powf(frnd(2) - 1, 3));
1109 _phaserSweep->setValue(powf(frnd(2) - 1, 3));
1110 _repeatSpeed->setValue(frnd(2) - 1);
1111 _changeSpeed->setValue(frnd(2) - 1);
1112 _changeAmount->setValue(frnd(2) - 1);
1113}
1114
1115//------------------------------------------------------------------------
1116

Callers 1

SfxrNodeMethod · 0.95

Calls 7

rndFunction · 0.85
cubeFunction · 0.85
frndFunction · 0.85
sqrFunction · 0.85
rndrFunction · 0.85
setValueMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected