A FlxSound that pans left and right based on the camera position in 3D.
Note: Due to OpenAL limitations, this only works with sounds that doesn't have stereo audio channels.
Constructor
Variables
panStrength:Float = 0.85
The strength of the stereo panning.
A value of 1.0 means pan fully left or right,
A value of 0.5 means pan left, while right is still audible, and viceversa.
A value of 0.0 means no panning, and negative values inverts the panning.
range:Float = 100
The sound range in world units.
Note: The attenuation power follows the Inverse Square Law for realistic effects.
dopplerStrength:Float = 0
Pitch up/down the sound based on its velocity towards/away from the camera.
It's the same effect when an ambulance is passing in front of you; its siren sounds pitched up when it's getting closer, and pitched down when it's going away
Keep in mind that this effect overwrites pitch, use dopplerPitchOffset to use a custom pitch.
propagationSpeed:Float = 343
The speed the sound travels at sea level in meters per second (m/s)
To disable it, set it to 0
queued:PropagationQueue = { currentTime : 0, targetTime : 0, queuedStartTime : 0 }
The queued sound parameters for propagation
onSoundReached:FlxTypedSignalImpl<() ‑> Void> = new FlxTypedSignalImpl()
If playing with realistic propagation, this event will fire when the sound "reaches" the camera
Methods
privateinlinegetDelayFromDistance(dist:Float):Float
Returns the delay in seconds the sound would take to reach the camera to be heard
This distance can change based on propagationSpeed and if the camera has been moved
since the last play() call
privateinlinegetDopplerShiftStrength(listenerSpeed:Float):Float
Returns the doppler shifting strength based on the doppler formula:
f' = f0 * ( (C+Vo) / (C-Vs) )
Wave speeds are converted to pitch, which is 1 for simplification
Parameters:
listenerSpeed | The speed of the listener towards the sound |
|---|
play(startTime:Float = 0, ?endTime:Float):Void
Plays the sound. Unlike FlxSound.play(), this function takes into account realistic sound propagation
and will queue the sound.
Note: Calling this will force the sound to play from the beginning, if you want to pause/resume the sound
use its play() function directly and after the timer has been finished, if you need to stop the sound or the queue,
call stop()