Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound playback improvements - added optional offset and duration parameters #287

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mikedotalmond
Copy link

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;

…und-sprite type applications

---

Changes the onComplete behavior of one-shot Playback objects - once complete, the Playback is disposed/released for GC.
@mikedotalmond
Copy link
Author

Ah, I see I didn't update Mixer. Will fix.

@mikedotalmond
Copy link
Author

Hmm, I see why those js.html.audio externs were left out... revert....

@mikedotalmond
Copy link
Author

Build appears to have failed on a firefox.js test - timed out after 10 mins. Not sure why.
https://travis-ci.org/aduros/flambe/jobs/32797267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant