A few questions from a FV-1 newbie

Algorithm development and general DSP issues

Moderator: frank

Post Reply
ZioGuido
Posts: 5
Joined: Mon Dec 17, 2012 4:24 am

A few questions from a FV-1 newbie

Post by ZioGuido »

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...

What would be the equivalent of this C code?

Code: Select all

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?

Thanks ;)
Guido.
slacker
Posts: 116
Joined: Tue Feb 01, 2011 1:13 pm

Post by slacker »

Hi

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.

Code: Select all

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:
Hopefully that makes sense.
ZioGuido
Posts: 5
Joined: Mon Dec 17, 2012 4:24 am

Post by ZioGuido »

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.

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

Post by frank »

See my example code in the second post of this thread http://www.spinsemi.com/forum/viewtopic.php?t=318 for using addr_ptr, you will basically replace the POT reads with your triangle.

As for interpolation you will need to do it manually, mask off the address part of the waveform and shift up the bits to use as a coefficient.
Frank Thomson
Experimental Noize
ZioGuido
Posts: 5
Joined: Mon Dec 17, 2012 4:24 am

Post by ZioGuido »

Thank you all for your help ;)
Last edited by ZioGuido on Fri Dec 21, 2012 2:44 pm, edited 1 time in total.
slacker
Posts: 116
Joined: Tue Feb 01, 2011 1:13 pm

Post by slacker »

No idea about that, way over my head.

Another way to modulate a delay is to use the servo method explained here
http://www.spinsemi.com/knowledge_base/ ... _technique this can only modulate over a range of 4096 samples though.
Post Reply