Skip to content

Commit 6b04ddc

Browse files
committed
fixes/enhancements
1 parent b50717c commit 6b04ddc

10 files changed

+167
-78
lines changed

presets/Osc1/lines4.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

presets/Osc1/pulse_16_1.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

presets/Osc1/rnd1.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

presets/Osc1/rnd2.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

presets/Osc1/rnd3.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

presets/Osc1/trapez4.vcvm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": 0
99
},
1010
{
11-
"value": -0.36500033736228943,
11+
"value": 0.0,
1212
"id": 1
1313
},
1414
{

res/RndH2.svg

+44-10
Loading

src/AP.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct RB {
4646
};
4747
struct AP : Module {
4848
enum ParamId {
49-
FREQ_PARAM,DELAY_PARAM,DELAY_SAMP_PARAM,DELAY_CV_PARAM,PARAMS_LEN
49+
FREQ_PARAM,DELAY_PARAM,DELAY_SAMP_PARAM,DELAY_CV_PARAM,FREQ_CV_PARAM,PARAMS_LEN
5050
};
5151
enum InputId {
5252
CV_INPUT,FREQ_INPUT,DELAY_INPUT,INPUTS_LEN
@@ -64,6 +64,7 @@ struct AP : Module {
6464
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
6565
//configParam(FREQ_PARAM,-4.f,8.f,0.f,"Frequency"," Hz",2,dsp::FREQ_C4);
6666
configParam(FREQ_PARAM,0.001,0.49,0.125,"Frequency");
67+
configParam(FREQ_CV_PARAM,0,1,0,"Freq CV");
6768
configInput(CV_INPUT,"CV");
6869
configInput(FREQ_INPUT,"Freq");
6970
configInput(DELAY_INPUT,"Delay");
@@ -87,7 +88,7 @@ struct AP : Module {
8788
float_4 in=inputs[CV_INPUT].getVoltageSimd<float_4>(c);
8889
float_4 freq4 = freq;
8990
if(inputs[FREQ_INPUT].isConnected()) {
90-
freq4=clamp(inputs[FREQ_INPUT].getPolyVoltageSimd<float_4>(c)*0.05f,0.001f,0.49f);
91+
freq4=simd::clamp(freq4+inputs[FREQ_INPUT].getPolyVoltageSimd<float_4>(c)*0.05f*params[FREQ_CV_PARAM].getValue(),0.001f,0.49f);
9192
}
9293
float_4 t=simd::tan(M_PI*freq4);
9394
float_4 a1=(t-1.f)/(t+1.f);
@@ -107,6 +108,7 @@ struct APWidget : ModuleWidget {
107108
float x=1.9;
108109
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,10)),module,AP::FREQ_PARAM));
109110
addInput(createInput<SmallPort>(mm2px(Vec(x,18)),module,AP::FREQ_INPUT));
111+
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,26)),module,AP::FREQ_CV_PARAM));
110112
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,54)),module,AP::DELAY_PARAM));
111113
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,66)),module,AP::DELAY_SAMP_PARAM));
112114
addInput(createInput<SmallPort>(mm2px(Vec(x,74)),module,AP::DELAY_INPUT));

src/RndH.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct RndH : Module {
118118
seedParam/=10.f;
119119
}
120120
auto seedInput = (unsigned long long)(floor((double)seedParam*(double)ULONG_MAX));
121-
INFO("%.8f %lld",seedParam,seedInput);
121+
//INFO("%.8f %lld",seedParam,seedInput);
122122
rnd.reset(seedInput);
123123
next(bi>0.f);
124124
}

src/RndH2.cpp

+112-59
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,73 @@
11
#include "dcb.h"
22
#include "rnd.h"
33

4+
struct UniH {
5+
float val[16]={};
6+
void next(RND &rnd,bool bi,int chn) {
7+
val[chn]=float(rnd.nextDouble()*10-(bi?5:0));
8+
}
9+
float get(int chn) {
10+
return val[chn];
11+
}
12+
};
13+
14+
struct MinH {
15+
float val[16]={};
16+
void next(RND &rnd,bool bi,int chn,float strength) {
17+
if(strength==1.f) {
18+
val[chn]=float(rnd.nextDouble()*10-(bi?5:0));
19+
} else {
20+
double outm=rnd.nextMin((int)strength);
21+
if(bi) {
22+
val[chn]=rnd.nextCoin()?(float)outm*5.f:(float)-outm*5.f;
23+
} else {
24+
val[chn]=(float)outm*10.f;
25+
}
26+
}
27+
}
28+
float get(int chn) {
29+
return val[chn];
30+
}
31+
};
32+
33+
struct WBH {
34+
float val[16]={};
35+
void next(RND &rnd,bool bi,int chn,float strength) {
36+
if(strength==1.f) {
37+
val[chn]=float(rnd.nextDouble()*10-(bi?5:0));
38+
} else {
39+
double outw=rnd.nextWeibull(strength);
40+
if(bi) {
41+
val[chn]=rnd.nextCoin()?(float)outw*5.f:(float)-outw*5.f;
42+
} else {
43+
val[chn]=(float)outw*10.f;
44+
}
45+
}
46+
}
47+
float get(int chn) {
48+
return val[chn];
49+
}
50+
};
51+
52+
struct TriH {
53+
float val[16]={};
54+
void next(RND &rnd,bool bi,int chn,float strength) {
55+
if(strength==1.f) {
56+
val[chn]=float(rnd.nextDouble()*10-(bi?5:0));
57+
} else {
58+
double outt=rnd.nextTri((int)strength);
59+
val[chn]=(float)outt*10.f-(bi?5.f:0.f);
60+
}
61+
}
62+
float get(int chn) {
63+
return val[chn];
64+
}
65+
};
66+
67+
468
struct RndH2 : Module {
569
enum ParamIds {
6-
BI_PARAM,STRENGTH_PARAM,CHANNELS_PARAM,SEED_PARAM,RANGE_PARAM,RANGE_CV_PARAM,OFFSET_PARAM,OFFSET_CV_PARAM,NUM_PARAMS
70+
BI_PARAM,STRENGTH_PARAM,CHANNELS_PARAM,SEED_PARAM,RANGE_PARAM,RANGE_CV_PARAM,OFFSET_PARAM,OFFSET_CV_PARAM,SLEW_PARAM,NUM_PARAMS
771
};
872
enum InputIds {
973
CLOCK_INPUT,RST_INPUT,SEED_INPUT,STRENGTH_INPUT,RANGE_INPUT,OFFSET_INPUT,NUM_INPUTS
@@ -17,7 +81,14 @@ struct RndH2 : Module {
1781
RND rnd;
1882
dsp::SchmittTrigger clockTrigger[16];
1983
dsp::SchmittTrigger rstTrigger;
20-
84+
dsp::SlewLimiter slewLimiterUni[16];
85+
dsp::SlewLimiter slewLimiterWB[16];
86+
dsp::SlewLimiter slewLimiterTri[16];
87+
dsp::SlewLimiter slewLimiterMin[16];
88+
UniH uniH;
89+
WBH wbH;
90+
MinH minH;
91+
TriH triH;
2192
RndH2() {
2293
config(NUM_PARAMS,NUM_INPUTS,NUM_OUTPUTS,NUM_LIGHTS);
2394
configInput(SEED_INPUT,"SEED");
@@ -29,8 +100,9 @@ struct RndH2 : Module {
29100
configParam(OFFSET_CV_PARAM,0.f,1.f,0.f,"Offset CV");
30101
configParam(BI_PARAM,0.f,1.f,1.f,"BI-Polar");
31102
configParam(STRENGTH_PARAM,1.f,20.f,1.f,"Strength");
32-
configParam(CHANNELS_PARAM,1.f,16.f,8.f,"Polyphonic Channels");
103+
configParam(CHANNELS_PARAM,1.f,16.f,1.f,"Polyphonic Channels");
33104
configParam(SEED_PARAM,0,1,0,"Random Seed");
105+
configParam(SLEW_PARAM,0.0f,1.f,0.f,"Slew");
34106
configInput(SEED_INPUT,"Random Seed");
35107
configInput(CLOCK_INPUT,"Clock");
36108
configInput(RST_INPUT,"Reset");
@@ -57,67 +129,21 @@ struct RndH2 : Module {
57129
return f*range+offset;
58130
}
59131

60-
void nextMin(float strength,bool bi,int chn) {
61-
if(strength==1.f) {
62-
auto out=float(rnd.nextDouble()*10-(bi?5:0));
63-
outputs[MIN_OUTPUT].setVoltage(modify(out,chn),chn);
64-
} else {
65-
double outm=rnd.nextMin((int)strength);
66-
if(bi) {
67-
float out=rnd.nextCoin()?(float)outm*5.f:(float)-outm*5.f;
68-
outputs[MIN_OUTPUT].setVoltage(modify(out,chn),chn);
69-
} else {
70-
outputs[MIN_OUTPUT].setVoltage(modify((float)outm*10.f,chn),chn);
71-
}
72-
}
73-
}
74-
75-
void nextWB(float strength,bool bi,int chn) {
76-
if(strength==1.f) {
77-
auto out=float(rnd.nextDouble()*10-(bi?5:0));
78-
outputs[WB_OUTPUT].setVoltage(modify(out,chn),chn);
79-
} else {
80-
double outw=rnd.nextWeibull(strength);
81-
if(bi) {
82-
auto out=rnd.nextCoin()?(float)outw*5.f:(float)-outw*5.f;
83-
outputs[WB_OUTPUT].setVoltage(modify(out,chn),chn);
84-
} else {
85-
outputs[WB_OUTPUT].setVoltage(modify((float)outw*10.f,chn),chn);
86-
}
87-
}
88-
}
89-
90-
void nextTri(float strength,bool bi,int chn) {
91-
if(strength==1.f) {
92-
auto out=float(rnd.nextDouble()*10-(bi?5:0));
93-
outputs[TRI_OUTPUT].setVoltage(modify(out,chn),chn);
94-
} else {
95-
double outt=rnd.nextTri((int)strength);
96-
auto out=(float)outt*10.f-(bi?5.f:0.f);
97-
outputs[TRI_OUTPUT].setVoltage(modify(out,chn),chn);
98-
}
99-
}
100-
101-
void nextUni(bool bi,int chn) {
102-
auto out=float(rnd.nextDouble()*10-(bi?5:0));
103-
outputs[UNI_OUTPUT].setVoltage(modify(out,chn),chn);
104-
}
105-
106132
void next(int chn,bool bi=false) {
107133
float strength=params[STRENGTH_PARAM].getValue();
108134
strength=clamp(inputs[STRENGTH_INPUT].getNormalPolyVoltage(strength*.5f,chn)*2.f,1.f,20.f);
109135
if(outputs[MIN_OUTPUT].isConnected())
110-
nextMin(strength,bi,chn);
136+
minH.next(rnd,bi,chn,strength);
111137
if(outputs[WB_OUTPUT].isConnected())
112-
nextWB(strength,bi,chn);
138+
wbH.next(rnd,bi,chn,strength);
113139
if(outputs[TRI_OUTPUT].isConnected())
114-
nextTri(strength,bi,chn);
140+
triH.next(rnd,bi,chn,strength);
115141
if(outputs[UNI_OUTPUT].isConnected())
116-
nextUni(bi,chn);
142+
uniH.next(rnd,bi,chn);
117143
}
118144

119-
120145
void process(const ProcessArgs &args) override {
146+
float slew=(params[SLEW_PARAM].getValue()+0.001f)*1000;
121147
float bi=params[BI_PARAM].getValue();
122148
int channels=params[CHANNELS_PARAM].getValue();
123149
bool channelParam=false;
@@ -130,14 +156,20 @@ struct RndH2 : Module {
130156
channelParam=true;
131157
}
132158
}
159+
for(int c=0;c<channels;c++) {
160+
slewLimiterUni[c].setRiseFall(1/slew,1/slew);
161+
slewLimiterWB[c].setRiseFall(1/slew,1/slew);
162+
slewLimiterTri[c].setRiseFall(1/slew,1/slew);
163+
slewLimiterMin[c].setRiseFall(1/slew,1/slew);
164+
}
133165
if(rstTrigger.process(inputs[RST_INPUT].getVoltage())) {
134166
if(inputs[SEED_INPUT].isConnected()) {
135167
getParamQuantity(SEED_PARAM)->setValue(inputs[SEED_INPUT].getVoltage()*0.1);
136168
}
137169
float seedParam=params[SEED_PARAM].getValue();
138170
seedParam=floorf(seedParam*10000)/10000;
139171
auto seedInput=(unsigned long long)(floor((double)seedParam*(double)ULONG_MAX));
140-
INFO("%.8f %lld",seedParam,seedInput);
172+
//INFO("%.8f %lld",seedParam,seedInput);
141173
rnd.reset(seedInput);
142174
for(int c=0;c<channels;c++) {
143175
next(c,bi>0.f);
@@ -157,9 +189,28 @@ struct RndH2 : Module {
157189
}
158190
}
159191
}
192+
for(int c=0;c<channels;c++) {
193+
if(outputs[UNI_OUTPUT].isConnected())
194+
outputs[UNI_OUTPUT].setVoltage(slewLimiterUni[c].process(1.f,modify(uniH.get(c),c)),c);
195+
if(outputs[MIN_OUTPUT].isConnected())
196+
outputs[MIN_OUTPUT].setVoltage(slewLimiterMin[c].process(1.f,modify(minH.get(c),c)),c);
197+
if(outputs[WB_OUTPUT].isConnected())
198+
outputs[WB_OUTPUT].setVoltage(slewLimiterWB[c].process(1.f,modify(wbH.get(c),c)),c);
199+
if(outputs[TRI_OUTPUT].isConnected())
200+
outputs[TRI_OUTPUT].setVoltage(slewLimiterTri[c].process(1.f,modify(triH.get(c),c)),c);
201+
}
160202
} else {
161-
for(int k=0;k<channels;k++)
162-
next(k,true);
203+
for(int c=0;c<channels;c++) {
204+
next(c,true);
205+
if(outputs[UNI_OUTPUT].isConnected())
206+
outputs[UNI_OUTPUT].setVoltage(uniH.get(c),c);
207+
if(outputs[MIN_OUTPUT].isConnected())
208+
outputs[MIN_OUTPUT].setVoltage(minH.get(c),c);
209+
if(outputs[WB_OUTPUT].isConnected())
210+
outputs[WB_OUTPUT].setVoltage(wbH.get(c),c);
211+
if(outputs[TRI_OUTPUT].isConnected())
212+
outputs[TRI_OUTPUT].setVoltage(triH.get(c),c);
213+
}
163214
}
164215

165216

@@ -193,11 +244,11 @@ struct RndH2Widget : ModuleWidget {
193244
y+=12;
194245
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,y)),module,RndH2::STRENGTH_PARAM));
195246
addInput(createInput<SmallPort>(mm2px(Vec(x1,y)),module,RndH2::STRENGTH_INPUT));
196-
y+=12;
247+
y+=9;
197248
auto biPolarButton=createParam<SmallButtonWithLabel>(mm2px(Vec(6.8,y)),module,RndH2::BI_PARAM);
198249
biPolarButton->setLabel("BiP");
199250
addParam(biPolarButton);
200-
y=66;
251+
y=64;
201252
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,y)),module,RndH2::RANGE_PARAM));
202253
addParam(createParam<TrimbotWhite>(mm2px(Vec(x1,y)),module,RndH2::OFFSET_PARAM));
203254
y+=8;
@@ -206,6 +257,8 @@ struct RndH2Widget : ModuleWidget {
206257
y+=8;
207258
addParam(createParam<TrimbotWhite>(mm2px(Vec(x,y)),module,RndH2::RANGE_CV_PARAM));
208259
addParam(createParam<TrimbotWhite>(mm2px(Vec(x1,y)),module,RndH2::OFFSET_CV_PARAM));
260+
y=92;
261+
addParam(createParam<TrimbotWhite>(mm2px(Vec(6.9,y)),module,RndH2::SLEW_PARAM));
209262

210263
y=104;
211264
addOutput(createOutput<SmallPort>(mm2px(Vec(x,y)),module,RndH2::WB_OUTPUT));

0 commit comments

Comments
 (0)