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.
53 lines
777 B
53 lines
777 B
11 years ago
|
package mightypork.gamecore.resources.audio;
|
||
11 years ago
|
|
||
11 years ago
|
|
||
11 years ago
|
import mightypork.gamecore.util.math.Calc;
|
||
11 years ago
|
|
||
|
|
||
|
/**
|
||
11 years ago
|
* Volume combined of multiple volumes, combining them (multiplication).
|
||
11 years ago
|
*
|
||
|
* @author MightyPork
|
||
|
*/
|
||
11 years ago
|
public class JointVolume extends Volume {
|
||
11 years ago
|
|
||
11 years ago
|
private final Volume[] volumes;
|
||
11 years ago
|
|
||
|
|
||
11 years ago
|
/**
|
||
11 years ago
|
* Create joint volume with master gain of 1
|
||
11 years ago
|
*
|
||
11 years ago
|
* @param volumes individual volumes to join
|
||
11 years ago
|
*/
|
||
11 years ago
|
@SafeVarargs
|
||
11 years ago
|
public JointVolume(Volume... volumes)
|
||
|
{
|
||
11 years ago
|
super(1D);
|
||
11 years ago
|
this.volumes = volumes;
|
||
|
}
|
||
11 years ago
|
|
||
|
|
||
11 years ago
|
/**
|
||
|
* Get combined gain (multiplied)
|
||
|
*/
|
||
|
@Override
|
||
11 years ago
|
public Double get()
|
||
11 years ago
|
{
|
||
11 years ago
|
double d = super.get();
|
||
11 years ago
|
for (final Volume v : volumes)
|
||
11 years ago
|
d *= v.get();
|
||
11 years ago
|
|
||
11 years ago
|
return Calc.clamp(d, 0, 1);
|
||
11 years ago
|
}
|
||
11 years ago
|
|
||
|
|
||
11 years ago
|
/**
|
||
|
* Set master gain
|
||
|
*/
|
||
|
@Override
|
||
11 years ago
|
public void set(Double o)
|
||
11 years ago
|
{
|
||
|
super.set(o);
|
||
|
}
|
||
|
}
|