chuck
chuck copied to clipboard
STK shouldn't have global sample rate
In ChucKDesigner, I have two virtual machines of ChucK running the same code but at different sample rates.
The code:
Step s => ADSR adsr => dac;
1. => s.next;
(100::ms, 10::ms, .8, 100::ms) => adsr.set;
while(true) {
adsr.keyOn(1);
150::ms => now;
adsr.keyOff(1);
500::ms => now;
}
I start the first VM at 90 Hz and then start the second at 44100. The output of the first VM changes when the second VM is launched because the second changes a global sample rate associated with STK:
https://github.com/ccrma/chuck/blob/d4c656d4843aa2dbc60ca9585cadb8b6b904ccbb/src/core/ugen_stk.cpp#L15094
I would prefer for the sample rate to not be global. It should work more like UGens accessing a private non-global srate
value https://github.com/ccrma/chuck/blob/d4c656d4843aa2dbc60ca9585cadb8b6b904ccbb/src/core/ugen_osc.cpp#L369