Trying to make really long exponential decay

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Digital Larry
Posts: 279
Joined: Mon Nov 12, 2012 12:12 pm
Contact:

Trying to make really long exponential decay

Post by Digital Larry » Sat Jun 18, 2016 5:12 pm

Here's what I've tried:

(detect trigger and initialize pulse level to -1.0)
sof 0, -1.0
wrax pulse, 0

(decay)
rdax pulse, 0.9999
wrax pulse, 0

This is a vast over simplification but I hope you get what I am describing. The issue that I am having is that I'd like a decay to last a few seconds. The resolution of the multiplier used in an rdax, an S1.14 format number, is 2^(-14) or 0.0000610352-something.

So the largest number less than 1.0 would be 1.0 - 0.0000610352, or 0.999938965.

If I use that value, then after 0.1 second, or 3277 samples, the pulse will have decayed to (about) 0.999938965^3277 or 0.8187.

This would seem to be OK, however in practice I don't seem to be able to get a decay that is much longer than 150 msec. I can make the rdax statement:

rdax pulse, 0.9999999

but it doesn't make any difference after a certain point so I seem to be hitting the maximum value that is less than 1.0 and it doesn't seem as large as I thought it was going to be. Any idea where I am going wrong?

Follow up:
I'm guessing (haven't tried it yet) that I can use a register initialized with a 24-bit value and then mulx this with the current value of the pulse after an rdax pulse, 1.0. That way I can get as much resolution as is possible with the FV-1.

I have seen a few examples among all the FV-1 code where there appeared to be some precision-extending approach used to get around various coefficient quantization limits of different instructions. It would be nice to get these strategies gathered together and more fully explained.

MacroMachines
Posts: 71
Joined: Fri Dec 12, 2014 9:45 pm
Location: Detroit,MI
Contact:

Post by MacroMachines » Thu Jul 07, 2016 11:35 pm

could you maybe use 2 registers to double the precision and do the calculation twice/add .5 of each?
http://MacroMachines.net
Digital Control for your Analog Soul.

MacroMachines
Posts: 71
Joined: Fri Dec 12, 2014 9:45 pm
Location: Detroit,MI
Contact:

Post by MacroMachines » Sun Nov 27, 2016 2:56 am

I was able to make a very long counter using:

Code: Select all

equ 	counter 		reg0 

				
or	%00000000_00000000_00001000	; add the increment to count upwards towards zero 
rdax 	counter, 		1.0 	
wrax 	counter, 		1.0 
skp 	gez, 		reset 		
skp 	run, 		output

reset: 			; reset counter to -1
sof 	0, 		-1.0 
wrax 	counter, 		1.0 

output: 
ldax counter
wrax dacl, 1
wrax dacr, 0
http://MacroMachines.net
Digital Control for your Analog Soul.

donstavely
Posts: 52
Joined: Thu Jan 07, 2010 1:29 pm
Location: Windsor, Colorado

Long exponential decay

Post by donstavely » Mon Feb 20, 2017 2:30 pm

I don't know if you are still interested in this, but I recently hit on an easy way to do very long decays. Instead of your:
rdax pulse, 0.999
wrax pulse, 0
Use a delay memory in place of the register, so the delay time is multiplied by the delay length:
rda pulse_dly+1000, 0.998 ; use long delay for filter reg
wra pulse_dly, 0
The value ticks down by 0.2% every 1000 cycles, so its time constant is about 500,000 cycles, or over 15 seconds at 32KHz.
Don't make the coefficient too close to 1.000, due to the limited precision of the delay memory. Make the delay longer if you need a longer decay.
Clever, eh?
Don Stavely

Digital Larry
Posts: 279
Joined: Mon Nov 12, 2012 12:12 pm
Contact:

Post by Digital Larry » Thu Feb 23, 2017 12:48 pm

That is pretty clever! However it is going to be stepped rather than smooth, which is probably what I was more interested in (can't remember what I was doing when I first posted here).

Thx Don.

DL

donstavely
Posts: 52
Joined: Thu Jan 07, 2010 1:29 pm
Location: Windsor, Colorado

Post by donstavely » Mon Mar 06, 2017 12:40 pm

Thanks, D.L.

Assuming that the decay value is used as some sort of control voltage, a 0.2% step in amplitude would not be noticeable. On the other hand, it very well could be noticeable as a step change in pitch.

I 'll bet a coefficient closer to 1.000 could be used, but I haven't done the math about the delay memory precision. We wouldn't want the decay to get "stuck" on one value because the multiply by the coefficient got rounded to the same value in the delay memory.

Don
Don Stavely

Post Reply