//No need to mix something that isn't playing
if( audioChannel == null ) return;
//Adjust sound speed
if( (effects & MIX_SPEED) != 0 && line.isControlSupported(FloatControl.Type.SAMPLE_RATE) ) {
FloatControl gainControl = (FloatControl)line.getControl(FloatControl.Type.SAMPLE_RATE);
float sampleRate = soundFormat.getFrameRate() * speed;
sampleRate = Math.max(gainControl.getMinimum(), Math.min(sampleRate, gainControl.getMaximum()));
gainControl.setValue(sampleRate);
}
//Adjust sound balance
if( (effects & MIX_PANNING) != 0 && line.isControlSupported(FloatControl.Type.PAN) ) {
FloatControl gainControl = (FloatControl)line.getControl(FloatControl.Type.PAN);
panning = Math.max(gainControl.getMinimum(), Math.min(panning, gainControl.getMaximum()));
gainControl.setValue(panning);
}
//Set sound volume
if( (effects & MIX_VOLUME) != 0 && line.isControlSupported(FloatControl.Type.MASTER_GAIN) ) {
FloatControl gainControl = (FloatControl)line.getControl(FloatControl.Type.MASTER_GAIN);
float gain = (float)(Math.log(volume)/Math.log(10.0f)*20.0f);
gain = Math.max(gainControl.getMinimum(), Math.min(gain, gainControl.getMaximum()));
gainControl.setValue(gain);
}
}