From the original SynthMaker forum (2004–2014), with its members’ names and dates.
CoreStyler ·
Can someone translate this code to synthmaker code?
function output = crusher( input, normfreq, bits );
step = 1/2^(bits);
phasor = 0;
last = 0;
for i = 1:length(input)
phasor = phasor + normfreq;
if (phasor >= 1.0)
phasor = phasor - 1.0;
last = step * floor( input(i)/step + 0.5 ); %quantize
end
output(i) = last; %sample and hold
end
end
MichaelBenjamin ·
CoreStyler wrote: Can someone translate this code to synthmaker code?
function output = crusher( input, normfreq, bits );
step = 1/2^(bits);
phasor = 0;
last = 0;
for i = 1:length(input)
phasor = phasor + normfreq;
if (phasor >= 1.0)
phasor = phasor - 1.0;
last = step * floor( input(i)/step + 0.5 ); %quantize
end
output(i) = last; %sample and hold
end
end
heres a try, should work:
streamin in;
streamin freq;//0.5 for half samplingrate 0.25 for 1/4 etc
streamout out;
float step=0.00390625;//precalculated for 8 bit - 1/2^8
float stepinv=256;//to avoid div
float ramp,lastramp,floor;
ramp=(ramp+freq)&(ramp<=1);//ramp to trigger s&h
floor=step*(rndint(in*stepinv+0.5));// not so sure here if that is meant with floor, maybe its only the one ctvsdpqs that gives out the remainder, but the rndint here should do the quantizing just right
out=out&(lastramp<ramp)+floor&(lastramp>=ramp);//s&h on each cycle
lastramp=ramp;
Wrote something here? To have a post removed or your name hidden, write to [email protected].