Amplitude and Frequency Formulas for RAMP LFO

Software questions and issues with the FV-1

Moderator: frank

Post Reply
HammerheadAudio
Posts: 11
Joined: Wed Apr 14, 2021 3:19 pm

Amplitude and Frequency Formulas for RAMP LFO

Post by HammerheadAudio »

Hi, I'm writing a granular / sample chopper program on the FV-1 where I'm using the built-in LFOs as a timing and enveloping element. Currently using sine since the documentation is clearer on how this works outside of the pitch shifting application described in AN-0001, but it seems like RAMP might potentially work better.

Can anyone give a clear description of the formula for ramp frequency when it is used as an oscillator, and ramp amplitude when it is read into the accumulator via CHO RDAL? This information is not explicitly stated in the documentation and would be very useful to have.

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

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by frank »

This is not so easy to answer, the ramps in FV-1 are generated based on delay length and pitch shift desired along with the sample rate.

You can probably determine the frequency from coefficient if you consider that for a 1 octave up shift the coefficient is 16384 and to shift up an octave we would need to add an lsb to the address each sample period but roll over once it has passed the length of the delay used (-256 to + 255 for the 512 long delay) so for a once octave shift the ramp will do one cycle every 512 sample periods or one cycle per octave over a period of the selected delay length for octave up. If using the octave down equation then you want to only advance 1/2 a sample per sample period which will create a reverse ramp at a much slower speed.

Amplitude will basically be the delay length selected.

FV-1 is not really designed for advanced address manipulation by the user, FXCore is better suited to that type of thing.
Frank Thomson
Experimental Noize
HammerheadAudio
Posts: 11
Joined: Wed Apr 14, 2021 3:19 pm

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by HammerheadAudio »

The 512, 1024, 2048, 4096 amplitude coefficients make sense, but how does that amplitude map from the integer value in samples to a 0-1 floating point value in the accumulator? Looking for a precise way to scale this such that I have an exact 0-1 ramp wave value in the accumulator.

Frequency makes sense, could probably work out the formula if I spent a minute, will likely figure out a pleasing range through trial and error anyway so it's less of a concern.

I know there's better hardware out there for granular, but for this project the hardware is set in stone so we work with what we got!

Appreciate the reply.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by frank »

HammerheadAudio wrote: Fri Dec 16, 2022 9:52 am The 512, 1024, 2048, 4096 amplitude coefficients make sense, but how does that amplitude map from the integer value in samples to a 0-1 floating point value in the accumulator? Looking for a precise way to scale this such that I have an exact 0-1 ramp wave value in the accumulator.
Been so many years since I designed this section I do not recall, I suggest set amp to 4096 and multiply the ramp by a carrier like 1KHz so you can see the ramp effect on the 1K signal and see how the peak amplitudes compare.

We didn't design the ramp with frequency and amplitude in mind as we were concerned with how much it adds to the sample counter each period to create a specific pitch shift and how to handle the wrap around of the delay block.
Frank Thomson
Experimental Noize
vasilius
Posts: 5
Joined: Tue Jan 10, 2023 9:42 am

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by vasilius »

CHO RDAL for RMP looks like triangle (float 0..0.5)
If we look on phaser sources and listen - we hear that lfo work smooth like periodic function, RMP have clicks every period.
vasilius
Posts: 5
Joined: Tue Jan 10, 2023 9:42 am

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by vasilius »

As I understand RAMP LFO in fv-1 :
Every sample we increment LFO_ACC to some step value

step = freq / 16384.0;
mask = RANGE - 1;

LFO_ACC = (LFO_ACC - step) & mask - this is just for simplicity
from sign of step depends type of ramp : decreasing or increasing
so we get difference rates for different amplitudes :
4096 : 32768/16384=2 -> 2 * 32768 (sample rate = buffer length = 32768) = 65536 / 4096 (range) = 16 ramps = 16Hz - this max rate
2048 : 32768/16384=2 -> 2 * 32768 (sample rate = buffer length = 32768) = 65536 / 2048(range) = 32ramps = 32Hz - this max rate
and so on

interpolating coefficients :
as I understand it correctly then
if step is whole digit then K = 0 and COMPC = 1
for example for WLDR 16384, 4096
K always will 0 and COMPC = 1
but for for WLDR 16300, 4096 for example
step = 0,994873046875
and for N sample we get K = N*step / 16384.0 - int(N*step / 16384) and COMPC = 1 -K

for example N = 4001 then 0,994873046875 * 4001 = 3 980,487060546875 - 3980 = 0,487060546875
COMPC = 1 - 0,487060546875 = 0,512939453125

COMPA all the same - just inverted -> COMPA = RANGE - RAMP

XFADE have values from 0..1.0 ?
it's trapezoid from parts = 1/8 of rate
xfade compc = 1 - XFADE

xfade for compa eqivalent to compc
xfade for compa + compc = xfade

RDAL value for range 4096 have 0..0.5 in float
for different ranges i don't know if it will change.

frank, do I right understand or not?
Thx
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by frank »

Well, I think you do but as I said it has been a long time and I was always looking at it from the pitch shifting perspective. So I never cared what the ramp speed was, I cared about how much it added to/subtracted from the sample counter to change the pitch.
Frank Thomson
Experimental Noize
vasilius
Posts: 5
Joined: Tue Jan 10, 2023 9:42 am

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by vasilius »

question about interpolation coefficients
How it calcs?

for example
take example

Code: Select all

wldr RMP0,16384,4096
cho rda,RMP0,REG|COMPC,delayd
cho rda,RMP0,0,delayd+1
wra temp,0
cho rda,RMP0,RPTR2|COMPC,delayd
cho rda,RMP0,RPTR2,delayd+1
cho sof,RMP0,NA|COMPC,0
cho rda,RMP0,NA,temp
mulx POT1
wrax REG0,0
here frequency is 16384 - so we have 4 ramps 0..4095 in rate period
and k=0.0 compc = 1 - k = 1.0 always for all counts bcs ramps consists from whole digits
then this code
cho rda,RMP0,REG|COMPC,delayd
cho rda,RMP0,0,delayd+1
have not sense - bcs we read from delayLine[0]*compc = delayLine[0]*1.0=delayLine[0]
and then add delayLine[1]*k = delayLine[0]*0.0=0
and receive just a delayLine[0] - no interpolation between values

It's ok? or do I wrong with calc interpolation coef k and compc?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by frank »

vasilius wrote: Sun Jan 15, 2023 8:17 am and k=0.0 compc = 1 - k = 1.0 always for all counts bcs ramps consists from whole digits
No they do not, ramps have a fractional portion and that is the bits used for interpolation. The integer bits are added to the sample counter.
vasilius wrote: Sun Jan 15, 2023 8:17 am then this code
cho rda,RMP0,REG|COMPC,delayd
cho rda,RMP0,0,delayd+1
have not sense - bcs we read from delayLine[0]*compc = delayLine[0]*1.0=delayLine[0]
That is only true if the fractional portion of the ramp is 0 which is rarely true.

Ramps generate a number that has both integer and fractional bits and what is important is how these two portions of a ramp interact with the address counter and are used for interpolation.

If you need to generate ramps, triangles, etc. at specific frequencies or amplitudes then FV-1 is the wrong chip to use, use FXCore as it has both saturating and non-saturating math to support this.

If you are doing pitch shifting then focus on the equations and not things like frequency as that is completely unimportant, how much the ramp adds/subtracts to the address counter and how that effects the resulting pitch shift is what is important.
Frank Thomson
Experimental Noize
vasilius
Posts: 5
Joined: Tue Jan 10, 2023 9:42 am

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by vasilius »

aha

then k is repeat RAMP in float 0..1
k = ramp/range;
and compc = 1.0 - k

XFADE also in area 0..1.0?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by frank »

vasilius wrote: Sun Jan 15, 2023 9:37 am XFADE also in area 0..1.0?
Yes
Frank Thomson
Experimental Noize
vasilius
Posts: 5
Joined: Tue Jan 10, 2023 9:42 am

Re: Amplitude and Frequency Formulas for RAMP LFO

Post by vasilius »

Hello

I found here
http://www.spinsemi.com/forum/viewtopic.php?f=4&t=713

code

Code: Select all

sof	0,0.999 
wrax	rmp0_range,1 
wrax	rmp1_range,0	
What value will be in rmp0_range? 32735? but it's not correct.

or also there

Code: Select all

wrax	fade,0	
or	%00111111_11111111_00000000   // 0x3fff00 => 16383
wrax	rmp0_range,1 
what value will be in range register?

Bcs Range is 2 bit value 00 (0)=512, 01 (1)=1024, 10 (2)=2048 and 11 (3)=4096
Post Reply