Distortion code

Algorithm development and general DSP issues

Moderator: frank

Post Reply
donstavely
Posts: 53
Joined: Thu Jan 07, 2010 2:29 pm
Location: Windsor, Colorado

Distortion code

Post 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
Don Stavely
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Post 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.
pedrolake
Posts: 6
Joined: Tue Nov 09, 2010 6:29 pm

Distortion code

Post by pedrolake »

Hi donstavely, where i can find the cube distortion, i'm trying make one high gain overdrive like boss superdrive.
Pedro HS
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

I believe he is referring to this item: http://www.spinsemi.com/knowledge_base/ ... istortion:
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post by Alex MAK »

I'm not running any distortion code to which there are ready examples. Where to find the problem?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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?
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post by Alex MAK »

I'm not working distortion code. All codes (distortion) which I found on this forum and the site will not work.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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.
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post by Alex MAK »

frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post 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.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post 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?
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post 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) ?
Post Reply