Fade In Help
Moderator: frank
Fade In Help
Greetings All!
I'm pretty new to FV-1 programming and looking for a way to fade in a signal. I'm assuming it'd be something similar to creating a compressor with a slow release time.
I've been through the free DSP programs and have a decent understanding of the compressor/limiter examples but not sure how to create the slow release.
If somebody can point me in the right direction it would be greatly appreciated!
Ultimaetly I'd like to use a pot to be able to control how much the signal gets compressed and also to control how slow the fade in is.
Thanks for your help!
I'm pretty new to FV-1 programming and looking for a way to fade in a signal. I'm assuming it'd be something similar to creating a compressor with a slow release time.
I've been through the free DSP programs and have a decent understanding of the compressor/limiter examples but not sure how to create the slow release.
If somebody can point me in the right direction it would be greatly appreciated!
Ultimaetly I'd like to use a pot to be able to control how much the signal gets compressed and also to control how slow the fade in is.
Thanks for your help!
Re: Fade In Help
Well, a fade in is very different from a compressor so need a clearer understanding of what you really want. If there is an example somewhere please provide a link.
Frank Thomson
Experimental Noize
Experimental Noize
Re: Fade In Help
Frank,
I’m trying to create a Bloom type reverb where the trails gradually fade it. Probably the best example would be here: https://m.youtube.com/watch?v=KclJxqde8NQ
I’m trying to create a Bloom type reverb where the trails gradually fade it. Probably the best example would be here: https://m.youtube.com/watch?v=KclJxqde8NQ
Re: Fade In Help
That is a very complex program. The basics to fade in/out a signal is:
if (signal > minimum) then {
gain = gain + increase
} else {
gain = gain - decrease
}
output = signal * gain
Of course that is pseudo code not FV-1 code but it is to explain the basic idea. If the signal is above the minimum then we increase the gain (fade in) and limit it to 1.0 max else we decrease the gain (fade out) and limit it to 0.
Then multiply the calculated gain by the signal and output it.
I recommend you just work on the fade in/out and ignore reverb for now.
if (signal > minimum) then {
gain = gain + increase
} else {
gain = gain - decrease
}
output = signal * gain
Of course that is pseudo code not FV-1 code but it is to explain the basic idea. If the signal is above the minimum then we increase the gain (fade in) and limit it to 1.0 max else we decrease the gain (fade out) and limit it to 0.
Then multiply the calculated gain by the signal and output it.
I recommend you just work on the fade in/out and ignore reverb for now.
Frank Thomson
Experimental Noize
Experimental Noize
Re: Fade In Help
Tanks for your help Frank!
I’m not completely sure how to convert this to FV-1 code but the general concept makes sense. I’d rather try and figure out how to convert it on my own, then just ask for the answers. I noticed FV-1 code doesn’t have an IF/THEN/ELSE statement, can you point me in the right direction for that part of it?
Thanks!
I’m not completely sure how to convert this to FV-1 code but the general concept makes sense. I’d rather try and figure out how to convert it on my own, then just ask for the answers. I noticed FV-1 code doesn’t have an IF/THEN/ELSE statement, can you point me in the right direction for that part of it?
Thanks!
Re: Fade In Help
Things like IF/THEN/ELSE do not exist in assembly language but this is where a SKP instruction comes in. You can do (signal - minimum) and SKP if negative (meaning signal is less than minimum). Few notes:
1. Take the absolute value of the signal and average the value over some number of samples.
2. Smooth the gain result.
1. Take the absolute value of the signal and average the value over some number of samples.
2. Smooth the gain result.
Frank Thomson
Experimental Noize
Experimental Noize
Re: Fade In Help
Ok, here is what I've come up with... it's clearly not the way to do it as this code doesn't work.
Not sure what I've done wrong, when I load the program I get no signal coming out. Can you point me in the right direction?
equ sigin reg0
equ avg reg1
equ gain reg2
equ min 0.9
rdax adcl,0.5
wrax sigin,1 ;write mono input signal
mulx sigin ;multiply by temp register (ACC^2)
rdfx avg,0.001 ;effective square root
wrax avg,1
;Check to see if input signal is below threshold
sof 1,-min ;load averaged signal - min into ACC
skp neg,lowsignal ;if negative (signal below minimum threshold) skip gain and jump to output
clr
;Check to see if gain has reached maximum gain
rdax gain,1
sof 1,-min ;load gain - min into ACC
skp gez, maxgain ; if positive (gain above minimum threshold) skip gain and jump to output
;Create gain to reduce input volume
clr
rdax gain,1 ;load gain into ACC
sof 1,0.001 ;add a small amount of gain
wrax gain,0 ;write new level to gain
rdax avg,1
mulx gain
wrax dacl,0
;We've reached maximum gain, output full signal
maxgain:
clr
rdax avg,1
mulx gain
wrax dacl,0
;Input signal is below threshold, take input signal output to dacl and rest gain to zero
lowsignal:
clr
rdax avg,1
wrax dacl,0
rdax gain,1
mulx 0
wrax gain,0
Not sure what I've done wrong, when I load the program I get no signal coming out. Can you point me in the right direction?
equ sigin reg0
equ avg reg1
equ gain reg2
equ min 0.9
rdax adcl,0.5
wrax sigin,1 ;write mono input signal
mulx sigin ;multiply by temp register (ACC^2)
rdfx avg,0.001 ;effective square root
wrax avg,1
;Check to see if input signal is below threshold
sof 1,-min ;load averaged signal - min into ACC
skp neg,lowsignal ;if negative (signal below minimum threshold) skip gain and jump to output
clr
;Check to see if gain has reached maximum gain
rdax gain,1
sof 1,-min ;load gain - min into ACC
skp gez, maxgain ; if positive (gain above minimum threshold) skip gain and jump to output
;Create gain to reduce input volume
clr
rdax gain,1 ;load gain into ACC
sof 1,0.001 ;add a small amount of gain
wrax gain,0 ;write new level to gain
rdax avg,1
mulx gain
wrax dacl,0
;We've reached maximum gain, output full signal
maxgain:
clr
rdax avg,1
mulx gain
wrax dacl,0
;Input signal is below threshold, take input signal output to dacl and rest gain to zero
lowsignal:
clr
rdax avg,1
wrax dacl,0
rdax gain,1
mulx 0
wrax gain,0
Re: Fade In Help
As you have it now you are always executing "lowsignal". You may want to check how your skp statements are executing.
You are also multiplying your averaged signal instead of your input by the gain factor.
You are also multiplying your averaged signal instead of your input by the gain factor.
Re: Fade In Help
Thanks Aaron!
I did some research yesterday and noticed that my skp routines were off. I believe I've fixed that part of it... I basically added a "skp gez,end" line at the end of each block (and put the "end:" statement at the very end of the program) to skip the rest of code so it only executes the appropriate statements (I'd post the code but I'm at work and don't have access to it now).
I didn't think about multiplying the input signal by gain, I guess my limited knowledge had me thinking the avg would do it... I'll go back and look at this tonight when I get home, hoping this will get me up and running!
I've been trying to trouble shoot what's going on by simply sending the averaged signal to output (like this).
rdax adcl,0.5
wrax sigin,1 ;write mono input signal
mulx sigin ;multiply by temp register (ACC^2)
rdfx avg,0.001 ;effective square root
wrax avg,1
wrax dacl,0
However, I only get a distorted signal on the output, I'm assuming this is because I should only be using the averaged signal for the skp routines. Thoughts?
I did some research yesterday and noticed that my skp routines were off. I believe I've fixed that part of it... I basically added a "skp gez,end" line at the end of each block (and put the "end:" statement at the very end of the program) to skip the rest of code so it only executes the appropriate statements (I'd post the code but I'm at work and don't have access to it now).
I didn't think about multiplying the input signal by gain, I guess my limited knowledge had me thinking the avg would do it... I'll go back and look at this tonight when I get home, hoping this will get me up and running!
I've been trying to trouble shoot what's going on by simply sending the averaged signal to output (like this).
rdax adcl,0.5
wrax sigin,1 ;write mono input signal
mulx sigin ;multiply by temp register (ACC^2)
rdfx avg,0.001 ;effective square root
wrax avg,1
wrax dacl,0
However, I only get a distorted signal on the output, I'm assuming this is because I should only be using the averaged signal for the skp routines. Thoughts?
Re: Fade In Help
Try this as a starting point, you will need to adjust "level" depending on your source level
Code: Select all
;program: fade.spn
equ in_coeff 0.0003
equ level 0.05
equ attack 0.0005
equ release 0.0005
equ in_lp reg0
equ gain reg1
skp run, go
clr
wrax in_lp, 0
wrax gain, 0
go:
clr
ldax adcl ; Read left ADC
absa ; Absolute value of signal
rdfx in_lp, in_coeff ; Do a low pass to get signal envelope
wrax in_lp,1.0 ; Save result and keep in the acc
sof 1.0, -level ; averaged input - level
skp neg, under ; if negative means the average signal level is below the minimum level so jump to fade out
sof 0, 0.5 ; if here we are above the min level so increase gain, load 1.0 into acc
sof 1.0, 0.5
rdfx gain, attack ;
wrax gain, 0
skp zro, out
under:
clr ; if here we were under the min signal level
rdfx gain, release;
wrax gain, 0
out:
ldax adcl ; read the input
mulx gain ; multiply by calculated gain
wrax dacl,0 ; write to output
Frank Thomson
Experimental Noize
Experimental Noize
Re: Fade In Help
Thanks Frank!
I'll try this out when I get home tonight and adapt it to fit my use. This exercise has really helped me to better understand what is going on behind the scenes with the FV-1, although I still have a lot to learn...
I'm still a bit confused on how the code below keeps "gain" from going above 1.0 and also below 0.0. Any chance you could shed some light on this for me?
Maybe it's because I'm not fully grasping what is in the ACC prior to the "rdfx gain, attack" statement. If I'm following the code correctly, it appears we are leaving the averaged signal in the ACC after this line of code (although I have no clue what it's value is):
Then we load another value into the ACC Which I'm not sure what the new value becomes because I don't what was in the ACC prior to this statement. Then load 1.0 into ACC and then execute the "rdfx gain, attack" statement.
I'll try this out when I get home tonight and adapt it to fit my use. This exercise has really helped me to better understand what is going on behind the scenes with the FV-1, although I still have a lot to learn...
I'm still a bit confused on how the code below keeps "gain" from going above 1.0 and also below 0.0. Any chance you could shed some light on this for me?
Maybe it's because I'm not fully grasping what is in the ACC prior to the "rdfx gain, attack" statement. If I'm following the code correctly, it appears we are leaving the averaged signal in the ACC after this line of code (although I have no clue what it's value is):
Code: Select all
wrax in_lp,1.0 ; Save result and keep in the acc
Code: Select all
sof 1.0, -level ; averaged input - level
Re: Fade In Help
The increasing gain is done here:
sof 0, 0.5 ; if here we are above the min level so increase gain, load 1.0 into acc
sof 1.0, 0.5
rdfx gain, attack ;
The 2 "sof" statements set ACC to 1.0, could have used one like "sof 0, 0.999" to make ACC almost 1.0 which is good enough for most cases but decided to be exact in the example.
The "rdfx gain, attack" does the following:
(ACC - [gain])*attack + [gain] (gain is a register so the brackets [] indicate the value in the register is used in the instruction)
Basically the final result will be limited to the value in ACC which we set to 1.0, "attack" controls how fast it changes
Do a similar thing for the decreasing gain, set ACC to 0 with "clr" and now it will never go below 0
sof 0, 0.5 ; if here we are above the min level so increase gain, load 1.0 into acc
sof 1.0, 0.5
rdfx gain, attack ;
The 2 "sof" statements set ACC to 1.0, could have used one like "sof 0, 0.999" to make ACC almost 1.0 which is good enough for most cases but decided to be exact in the example.
The "rdfx gain, attack" does the following:
(ACC - [gain])*attack + [gain] (gain is a register so the brackets [] indicate the value in the register is used in the instruction)
Basically the final result will be limited to the value in ACC which we set to 1.0, "attack" controls how fast it changes
Do a similar thing for the decreasing gain, set ACC to 0 with "clr" and now it will never go below 0
Frank Thomson
Experimental Noize
Experimental Noize
Re: Fade In Help
Frank, you've been VERY helpful. Thanks!