Page 1 of 1

Distortion code

Posted: Thu Jan 07, 2010 2:57 pm
by donstavely
Hey guys. I am new to the forum and just learning the chip. Very impressive! I procrastinated because it seemed too much like work, but it has been a blast.

I am working on a multi-band distortion project. Thanks for the cube distortion code, since I need to do it for each band. I came up with a square variant that is the same number of instructions, and is just a tad softer:
wrax temp, 0.5 ; save it, scale copy in ACC
absa ; strip one sign
mulx temp ; square value, with original sign
rdax temp, -1 ; add back original with opposite sign
sof -1.99, 0 ; scale to +/-1

Another variant uses the square function to get octave up. It uses the same cube idea to round the tops, and absa to get the signs right, like the above:
mulx in ; square it
wrax temp, 0.66667 ; save in^2, scale copy in ACC
mulx in ; cube it
absa ; strip sign
rdax temp, -1 ; subtract squared value
sof -1.99, 0 ; scale to +1,-something

Note that there is DC content left due to the even functions. This one will need a compressor or limiter in front of it to keep it close to the "sweet spot" where it isn't clipping too harshly.

I don't have a question, just throwing this out there to share learnings with other Spinners.

Don

Posted: Thu Jan 07, 2010 9:04 pm
by livingston
Cool, I'll check this out. My FV-1 interests mainly lie outside distortion type stuff, but I did use some code lifted from here to make a square wave generator controlled by input pitch - it sounds pretty much like a heavy analog fuzz. But using the code as is, the square wave keeps buzzing when you stop playing. I'll code up a fix for this and then post the code - somebody else might fight a digital fuzz useful for something.

Distortion code

Posted: Fri Dec 10, 2010 7:27 pm
by pedrolake
Hi donstavely, where i can find the cube distortion, i'm trying make one high gain overdrive like boss superdrive.

Posted: Sat Dec 11, 2010 3:04 pm
by frank
I believe he is referring to this item: http://www.spinsemi.com/knowledge_base/ ... istortion:

Posted: Tue Dec 14, 2010 7:46 am
by Alex MAK
I'm not running any distortion code to which there are ready examples. Where to find the problem?

Posted: Tue Dec 14, 2010 9:59 am
by frank
Alex MAK wrote:I'm not running any distortion code to which there are ready examples. Where to find the problem?
I do not understand the question, can you rephrase it?

Posted: Tue Dec 14, 2010 10:58 am
by Alex MAK
I'm not working distortion code. All codes (distortion) which I found on this forum and the site will not work.

Posted: Tue Dec 14, 2010 4:12 pm
by frank
Alex MAK wrote:I'm not working distortion code. All codes (distortion) which I found on this forum and the site will not work.
Much of the code posted here is only the "core" effect, you still need to add reading from ADC and writing to DAC to make the code work.

Posted: Tue Dec 14, 2010 4:26 pm
by Alex MAK

Posted: Tue Dec 14, 2010 4:40 pm
by frank
Alex MAK wrote:http://www.spinsemi.com/get_spn.php?spn ... um=SPN1001
This code does not work
I just ran the code and it worked for me but it does require a very strong input signal, you may need to add gain to the input. Or try this code based on a different method:

Code: Select all

equ  	tovrx  	reg0
equ 	sigin 	reg1
equ 	lf1 	reg2
equ 	lf2 	reg3
equ 	lf3 	reg4
equ 	lf4 	reg5
  	  	 
rdax 	adcl,1 	;read input signal
log 	-1,-3/16 	;coefficient is the LOG version of threshold ! ! !
exp 	1,0 	;provides t/X
wrax 	tovrx,1 	;save t/X, we'll need it later...
mulx 	tovrx 	;(t/X)^2
rdax 	tovrx,-2 	;inverts multiplicand, which will invert phase
mulx 	adcl 	;multiply by the input signal
rdax 	lf1,0.75 	;restore gain and filter
wrax 	lf1,1 	;output in ACC and lf1

log 	-1,-3/16 	;coefficient is the LOG version of threshold ! ! !
exp 	1,0 	;provides t/X
wrax 	tovrx,1 	;save t/X, we'll need it later...
mulx 	tovrx 	;(t/X)^2
rdax 	tovrx,-2 	;inverts multiplicand, which will invert phase
mulx 	lf1 	;multiply by the input signal
rdax 	lf2,0.75 	;restore gain and filter
wrax 	lf2,1 	;output in ACC and lf2

log 	-1,-3/16 	;coefficient is the LOG version of threshold ! ! !
exp 	1,0 	;provides t/X
wrax 	tovrx,1 	;save t/X, we'll need it later...
mulx 	tovrx 	;(t/X)^2
rdax 	tovrx,-2 	;inverts multiplicand, which will invert phase
mulx 	lf2 	;multiply by the input signal
rdax 	lf3,0.75 	;restore gain and filter
wrax 	lf3,1 	;output in ACC and lf3

log 	-1,-3/16 	;coefficient is the LOG version of threshold ! ! !
exp 	1,0 	;provides t/X
wrax 	tovrx,1 	;save t/X, we'll need it later...
mulx 	tovrx 	;(t/X)^2
rdax 	tovrx,-2 	;inverts multiplicand, which will invert phase
mulx 	lf3 	;multiply by the input signal
rdax 	lf4,0.75 	;restore gain and filter
wrax 	lf4,1 	;output in ACC and lf1

wrax dacl,0

Posted: Tue Dec 14, 2010 4:50 pm
by Alex MAK
This code makes a noise http://www.spinsemi.com/get_spn.php?spn ... um=SPN1001 . The quality of the noise varies regulators. The guitar does not change the noise.

Posted: Tue Dec 14, 2010 4:54 pm
by frank
Alex MAK wrote:This code makes a noise http://www.spinsemi.com/get_spn.php?spn ... um=SPN1001 . The quality of the noise varies regulators. The guitar does not change the noise.
That is strange, it is working correctly for me but I am running a strong signal into the board. What is your set up? Exactly want is plugged in where?

Posted: Wed Dec 15, 2010 12:40 am
by Alex MAK
Code (PostPosted: Tue Dec 14, 2010 3:40 pm Post subject:) works well. A good overdrive. Its possible to add gain control (POT0), TON (POT1) and volume (POT2) ?