Awesome. Thanks Julius! Is there a reason why it won’t work without the abs:
bitcrusher(nbits,x) = x *(scaler) : round : /(scaler); Sorry to foul this forum with SC code, but the plots look the same: {SinOsc.ar(200)}.plot; {(SinOsc.ar(200)*a).round/a}.plot; {b = SinOsc.ar(200); (b.abs*a).round/a*(2*(b>0).asInteger-1)}.plot; Stay safe out there in Cali. Yikes. Sam On September 14, 2020 at 9:50:19 PM, Julius Smith (julius.sm...@gmail.com) wrote: Tested!: import("stdfaust.lib"); nbits = hslider("NBITS",8,0,16,1); scaler = float(2^nbits-1); round(x) = floor(x+0.5); bitcrusher(nbits,x) = x : abs : *(scaler) : round : /(scaler) * (2*(x>0)-1.0); process = os.oscrs(300) : bitcrusher(nbits); On Mon, Sep 14, 2020 at 6:40 PM Julius Smith <julius.sm...@gmail.com> wrote: > Hi Sam, > > What I wrote was for integers. For floats, you want something like this: > > scaler = float(2^nbits-1); > bitcrusher(nbits) = abs : *(scaler) : round : /(scaler) : *(>(0)*2-1); // > (put sign bit back in at the end) > > (not tested) > > > On Mon, Sep 14, 2020 at 5:29 PM Sam Pluta <spl...@gmail.com> wrote: > >> Didn’t mean to send this only to Julius. What am I doing wrong: >> >> import("stdfaust.lib”); >> nbits = 7; >> process = (os.osc(200)&(2^(nbits)-1))*0.1; >> >> Just kind of blips on and off for me. >> >> Sam >> >> >> On September 14, 2020 at 5:08:40 PM, Julius Smith (julius.sm...@gmail.com) >> wrote: >> >> No problem: >> >> process = &(2^(nbits)-1); >> >> On Mon, Sep 14, 2020 at 11:30 AM Súton <doctorsu...@gmail.com> wrote: >> >>> >>> >>> >>> _______________________________________________ >>> Faudiostream-users mailing list >>> Faudiostream-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users >>> >> >> >> -- >> "Anybody who knows all about nothing knows everything" -- Leonard Susskind >> _______________________________________________ >> Faudiostream-users mailing list >> Faudiostream-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/faudiostream-users >> >> _______________________________________________ >> Faudiostream-users mailing list >> Faudiostream-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/faudiostream-users >> > > > -- > "Anybody who knows all about nothing knows everything" -- Leonard Susskind > -- "Anybody who knows all about nothing knows everything" -- Leonard Susskind
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users