Hello everybody,
I am new to the SPIN platform and I'm trying to program some stuff on it. Maybe some of you might help on a few commands I'm currently stuck on. I've read many interesting posts along with all available documentations, but I still have some doubts...
IN THE LOOP:
float Process (s) {
if (s > m) m += c1; // increment m by c1 until it reaches s
else m -= c2; // else decrement m by c2
return m;
}
Alternatively, how can I implement an envelope follower with given attack and decay times that can go from a positive value to another positive value upon a specific condition?
Something like this will replicate that c code. This assumes that the values for M and S will always be positive, at the end of the code the new value of M will be in the accumulator.
clr; clear accumulator, may not be needed depending on the preceding code
rdax S,-1 ;load minus S into accumulator
rdax M,1 ;add M
skp neg,INCREMENT ;if result is negative S > M, skip to increment
;else decrement M
clr; clear accumulator
rdax M,1 ;load M into accumulator
rdax c2,-1 ; add minus c2 (subtract c2)
wrax M,1 ;write to M, keep result in accumulator
skp gez, END ;result will always be positive so skip to end of this code
INCREMENT:
clr ; clear accumulator
rdax M,1 ; load M into accumulator
rdax c1,1 ;add c1
wrax M,1 ;write to M and keep in accumulator
END:
Wow! Thank you very much for this code. Didn't try it yet but at a quick look it seems right. What I was ignoring is the logic behind the use of the accumulator and a linear execution versus the logic of a C program with its blocks, functions, etc.
I will test it tomorrow and will let you know how it goes.
Meanwhile, I'd like to submit another question: I wish to modulate a delay with a triangle waveform. I've managed to create the waveform, but I still can't find the correct way to use it for reading from the delay memory. I think I have to use ADDR_PTR but I still can't figure out how, and I don't know how to make the linear interpolation without using CHO RDA (which only accepts the internal LFOs). Unfortunately, using the sine LFOs just doesn't work for what I wish to do.