Page 1 of 1

Idea for generating a lower octave.

Posted: Wed Jun 02, 2010 4:45 am
by sad1024
Take input. Determine envelope voltage. Add half the envelope voltage to the input so its always positive. Take the square root of it. Invert at each zero crossing to get the lower octave. Filter out any transients. Now just turning it into code.

Code.

Posted: Wed Jun 02, 2010 9:53 am
by sad1024
equ input reg0
equ ef reg1 ;Set up registry

ldax adcl ;read input into acc
wrax input, 1 ;write input for later use
absa ;take absolute value
rdfx ef, .001
wrlx ef, 1 ; low pass filter
ldax ef
mulx 0.5 ; take half envelope
rdax input, 1 ; add input
log 0.5, 0
exp 1,0 ; take the square root

From here on I don't know how to write the code.

Posted: Thu Jun 03, 2010 12:49 pm
by sad1024
Does anybody know what should come next?

Posted: Thu Jun 03, 2010 1:30 pm
by frank
Well, I think there is an error in the logic, looking at the theory:
Take input. Determine envelope voltage. Add half the envelope voltage to the input so its always positive.
I believe that is incorrect. Imagine a constant amplitude sin wave that goes +1 to -1, taking the absolute value and finding the envelope give an envelope voltage of 1, adding 1/2 of that to the input results in a signal that goes from -0.5 to +1.5, not always positive. This is what your code appears to do (I haven't run it)

See this thread on doing an octave down using zero crossing detection
http://www.spinsemi.com/forum/viewtopic.php?t=185

Posted: Thu Jun 03, 2010 4:38 pm
by sad1024
Your right, but it looks like the average amplitude of the envelope will be less than the peak amplitude, so it will need to be multiplied by greater than unity, (1.4142??). It will take me a while to get comfortable enough with the code to detect the zero intercepts. Thanks.