Distortion code
Moderator: frank
-
- Posts: 53
- Joined: Thu Jan 07, 2010 2:29 pm
- Location: Windsor, Colorado
Distortion code
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
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
-
- Posts: 131
- Joined: Sun Nov 15, 2009 3:37 pm
- Location: New Orleans, LA US
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
Hi donstavely, where i can find the cube distortion, i'm trying make one high gain overdrive like boss superdrive.
Pedro HS
I believe he is referring to this item: http://www.spinsemi.com/knowledge_base/ ... istortion:
Frank Thomson
Experimental Noize
Experimental Noize
I do not understand the question, can you rephrase it?Alex MAK wrote:I'm not running any distortion code to which there are ready examples. Where to find the problem?
Frank Thomson
Experimental Noize
Experimental Noize
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.Alex MAK wrote:I'm not working distortion code. All codes (distortion) which I found on this forum and the site will not work.
Frank Thomson
Experimental Noize
Experimental Noize
http://www.spinsemi.com/get_spn.php?spn ... um=SPN1001
This code does not work
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:Alex MAK wrote:http://www.spinsemi.com/get_spn.php?spn ... um=SPN1001
This code does not work
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
Experimental Noize
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?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.
Frank Thomson
Experimental Noize
Experimental Noize