Page 1 of 1

Bitcrusher

Posted: Thu Oct 29, 2009 10:02 pm
by accumulator
Can anyone provide a snippet of working code for a Bitcrusher effect?


Thank you!

Posted: Fri Oct 30, 2009 10:09 am
by frank
Here's a simple example, simply ANDing off the lower bits:

Code: Select all

crush equ 0xfc0000 ;define the bit mask - 6 bits here
clr
rdax adcl,0.5
rdax adcr,0.5
skp neg,invit; working with 2's comp numbers, if negative skip down
and crush
skp gez,outter
invit:
sof -1.0,0 ; for negative samples, invert them,
and crush ; mask the data
sof -1.0,0 ; invert it back
outter:
wrax dacl,1.0
wrax dacr,1.0
You could get fancier (use a POT input to determine mask, etc.)

Posted: Fri Oct 30, 2009 4:18 pm
by frank
A simple aliaser:

Code: Select all

flopper equ reg0
lastval equ reg1
ratio equ 0.95 ; Set between 0 and 0.975 in 0.025 steps to change alias ratio, 0 is no alias
clr
rdax flopper,1.0 ;read counter
sof 1.0,-0.025 ; subtract 1
skp gez, outter ; if > 0 jump to output
rdax adcl,0.5 ; else get input
rdax adcr,0.5
wrax lastval,0 ; write to out reg
sof 0,ratio ; reload counter
outter:
wrax flopper,0 ; save counter
clr
rdax lastval,1.0
wrax dacl,1.0
wrax dacr,0