Help Needed: Writing Fade In/Out Function for Volume Control

Click For Summary
SUMMARY

This discussion focuses on creating a fade in and fade out function for volume control using mathematical modeling. The proposed volume function is defined as V(t) = (1 - ((1 + T/t_0)/(1 + t/t_0))^α) / (1 - (1 + T/t_0)^α) * V_0, where parameters A, B, t_0, and α are crucial for achieving the desired fade effect. The user is experimenting with α set to 1.01 and t_0 ranging from 0 to 475, stepping by 25, with an initial volume (V_0) of 50. The resulting volume values range from 16 to 45, indicating a successful implementation of the function.

PREREQUISITES
  • Understanding of mathematical functions and their applications in programming.
  • Familiarity with volume control concepts in audio programming.
  • Knowledge of power laws and their behavior in mathematical modeling.
  • Basic skills in programming to implement the volume function.
NEXT STEPS
  • Research "Power Law Functions in Audio Processing" to understand their effects on sound dynamics.
  • Explore "Mathematical Modeling in Audio Programming" for advanced techniques.
  • Learn about "Implementing Fade Effects in Audio Libraries" such as Web Audio API or FMOD.
  • Experiment with "Parameter Tuning for Audio Effects" to optimize fade in/out functions.
USEFUL FOR

Audio engineers, software developers working on audio applications, and anyone interested in implementing volume control features in multimedia projects.

VMail
Messages
11
Reaction score
0
This more of a maths question rather than a physics one, but I do remember doing something similar is my physics course.

Basically I trying to write a fade in and fade out function
for a volume control but I am stuck on the maths part. Thats where I
need you.

I've tryed a linear fade, but that does not sound good

so y = volume (0-100)
and x = time (0.5)

time is fixed to 0.5sec but can alter slightly if needed

volume will be one value from 0 to 100, but I don't know what the
volume will be until the function is needed
 
Physics news on Phys.org
Just putting this PM here because I can't read the formula in the PM

Ambitwistor said:
If a linear scaling doesn't sound good, you might try something that scales as a power of time other than 1. That is, something like [itex]t^{-\alpha}[/itex] for some [itex]\alpha>0[/itex] ([itex]\alpha\neq 1[/itex]). It will fade faster than linear for [itex]\alpha>1[/itex], and slower than linear for [itex]0<\alpha<1[/itex].

However, you can't just use a straight power law, because it goes to infinity at t=0, and never drops completely to zero. So, you want a power law that's shifted to the left a bit (to be positive at t=0), and also down a bit (to drop to zero at finite t).

So, you want a volume function that looks something like this,

[tex]V(t) = A(t+t_0)^{-\alpha} + B[/itex]<br /> <br /> for some constants A, B, and [itex]t_0[/itex].<br /> <br /> Adding the constraints that you want the volume to have some initial volume at time t=0 ([itex]V(0) = V_0[/itex]), and drop to zero volume after some finite time t=T ([itex]V(T) = 0[/itex]), that leads to a volume function that fades with time like this, <br /> <br /> [tex]V(t) = \frac{1-(\frac{1+T/t_0}{1+t/t_0})^\alpha}{1-(1+T/t_0)^\alpha} V_0[/tex]<br /> <br /> or,<br /> <br /> [tex]V(t) = \frac{1-k/(1+t/t_0)^\alpha}{1-k} V_0[/tex]<br /> <br /> where [itex]k = (1+T/t_0)^\alpha[/itex] -- assuming I haven't screwed up the algebra; you'll have to check it.<br /> <br /> You'll have to play around with the parameters [itex]\alpha[/itex] and [itex]t_0[/itex] to find something that sounds good. I already mentioned the effect that [itex]\alpha[/itex] has on the fade; larger [itex]t_0[/itex] values will also make for a slower fade (getting out on the tail end of the power-law decay curve).[/tex]
[tex][/tex]
 
ok, I'm using

to=0 to 475 (stepping by 25)
and alpha as 1.01
Vo is set at 50

The values that I am getting are 16-45(rounded up)
is this correct?
 

Similar threads

Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 33 ·
2
Replies
33
Views
4K
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 70 ·
3
Replies
70
Views
5K