You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
818 B
52 lines
818 B
package mightypork.gamecore.audio;
|
|
|
|
|
|
import mightypork.utils.math.Calc;
|
|
import mightypork.utils.objects.Mutable;
|
|
|
|
|
|
/**
|
|
* Volume combined of multiple volumes, combining them (multiplication).
|
|
*
|
|
* @author MightyPork
|
|
*/
|
|
public class JointVolume extends Volume {
|
|
|
|
private final Mutable<Double>[] volumes;
|
|
|
|
|
|
/**
|
|
* Create joint volume with master gain of 1
|
|
*
|
|
* @param volumes individual volumes to join
|
|
*/
|
|
@SafeVarargs
|
|
public JointVolume(Volume... volumes) {
|
|
super(1D);
|
|
this.volumes = volumes;
|
|
}
|
|
|
|
|
|
/**
|
|
* Get combined gain (multiplied)
|
|
*/
|
|
@Override
|
|
public Double get()
|
|
{
|
|
double d = super.get();
|
|
for (final Mutable<Double> v : volumes)
|
|
d *= v.get();
|
|
|
|
return Calc.clampd(d, 0, 1);
|
|
}
|
|
|
|
|
|
/**
|
|
* Set master gain
|
|
*/
|
|
@Override
|
|
public void set(Double o)
|
|
{
|
|
super.set(o);
|
|
}
|
|
}
|
|
|