aduros/flambe — pull request #287 by mikedotalmond (2014-08-17 18:50:18+00:00)
Title: Sound playback improvements - added optional offset and duration parameters

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:

* There are changes to the onComplete behaviour of one-shot Playback objects: once complete, the Playback is disposed + released for GC. The previous behaviour required users to dispose of Playback manually once a sound completed in order for it to be culled.
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.

* Some Dynamic properties in the html audio platform classes have also been changed to use the typed js.html and js.html.audio defs
Note: I had to update the signatures for `AudioNode::connect` and `AudioNode::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;`