Sound playback improvements - added optional offset and duration parameters #287
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds ability to play or loop regions of a sound, with optional offset and duration parameters.
play (volume :Float = 1.0, offset:Float=0, duration:Float=0) :Playback
loop (volume :Float = 1.0, offset:Float=0, duration:Float=0) :Playback
This will allow sound-sprite type behaviours - where many short sounds can be contained in, and played from, a single asset.
The update should be seamless across all platforms - and not break anything.. but I have changed how Playback objects are disposed:
In the case of the WebAudioPlayback, nodes were remaining in the audio graph after sounds completed. So playing lots of one-shot sounds created many
AudioBufferSourceNode -> GainNode
pairs that were not being removed/collected.Note: I had to update the signatures for
AudioNode::connect
andAudioNode::disconnect
which are out of date in the haxe std library. The output and input parameters for these functions are optional so should be more like this...@:overload( function( destination : AudioNode, ?output : Int, ?input : Int ) :Void {} )
function connect( destination : AudioParam, ?output : Int ) : Void;
function disconnect( ?output : Int ) : Void;