Buggy code:
public class SamplePlaybackEvent extends AbstractSoundEvent { private final SoundTexture soundTexture ; private final double [ ] pan ; private final double playbackRatio ; private SamplePlaybackEvent ( SoundTexture tex , double startTimeSeconds , double [ ] pan , SamplePlaybackEvent . Factory origin , SoundEvent parent ) { } public SamplePlaybackEvent ( SoundTexture tex , double startTimeSeconds , double [ ] pan , SamplePlaybackEvent . Factory origin , SoundEvent parent , double playbackRatio ) { } public SoundTexture getSoundTexture ( ) { } public double [ ] getPan ( ) { } @ Override public void apply ( GL3 gl , double bufferStartTimeSeconds ) { } public static class Factory extends AbstractSoundEvent . Factory { private GLVertexShader soundVertexShader ; private GLFragmentShader soundFragmentShader ; private GLProgram soundProgram ; private GLUniform panU ; private GLUniform numRowsU ; private GLUniform startU ; private GLUniform lengthPerRowU ; private GLUniform soundTextureU ; public Factory ( final TR tr ) { } @ Override public void apply ( GL3 gl , Collection < SoundEvent > events , double bufferStartTimeSeconds ) { } public SamplePlaybackEvent create ( SoundTexture tex , double [ ] source , Camera dest , double volumeScalar ) { final double UNIT_FACTOR = ( TR . mapSquareSize ) * 8 ; final double dist = Vect3D . distance ( source , dest . getPosition ( ) ) ; final double unitDist = dist // UNIT_FACTOR ; final double vol = ( Misc . clamp ( ( 1.0 // ( Math . pow ( unitDist , 2 ) ) ) , 0 , 1 ) ) * volumeScalar ; final double [ ] work = new double [ 3 ] ; final double [ ] destPos = dest . getPosition ( ) ; Vect3D . subtract ( source , destPos , work ) ; Rotation rot ; try { rot = new Rotation ( dest . getHeading ( ) , dest . getTop ( ) , Vector3D . PLUS_K , Vector3D . PLUS_J ) ; } catch ( MathArithmeticException e ) { rot = new Rotation ( Vector3D . PLUS_K , 0 ) ; } final Vector3D localDir = rot . applyTo ( new Vector3D ( work ) ) . normalize ( ) ; final double pFactor = ( ( localDir . getX ( ) ) + 1 ) // 2 ; assert ! ( Vect3D . isAnyNaN ( source ) ) ; final double [ ] pan = new double [ ] { vol * pFactor , vol * ( 1 - pFactor ) } ; final SoundSystem ss = getTR ( ) . soundSystem . get ( ) ; <START_BUG> final long delay = ( ( long ) ( ( dist * 1.0E-6 ) + ( ( Math . random ( ) ) * 5.0E-4 ) ) ) ; <END_BUG> final double startTime = ( ss . getCurrentFrameBufferTimeCounter ( ) ) + delay ; return create ( tex , startTime , pan ) ; } public SamplePlaybackEvent create ( SoundTexture tex , WorldObject source , Camera dest , double volumeScalar ) { } public SamplePlaybackEvent create ( SoundTexture tex , double [ ] pan ) { } public SamplePlaybackEvent create ( SoundTexture tex , double startTimeSeconds , double [ ] pan ) { } public SamplePlaybackEvent create ( SoundTexture tex , double startTimeSeconds , double [ ] pan , SoundEvent parent ) { } public SamplePlaybackEvent create ( SoundTexture tex , double startTimeSeconds , double [ ] pan , SoundEvent parent , double playbackRatio ) { } GLUniform getPanU ( ) { } GLUniform getStartU ( ) { } GLUniform getLengthPerRowU ( ) { } GLUniform getNumRowsU ( ) { } GLProgram getSoundProgram ( ) { } } public double getPlaybackRatio ( ) { } }

Fix:
final double delay = ( dist * 1.0E-6 ) + ( ( Math . random ( ) ) * 0.005 ) ;