Start Sound at Given Position?

21 views
Skip to first unread message

Jon Grant

unread,
Nov 25, 2015, 7:58:24 PM11/25/15
to Flambe
Is there any way in Flambe to start a sound at a given position instead of always from the start?  

Jon Grant

unread,
Dec 1, 2015, 3:06:56 PM12/1/15
to Flambe
So, yes and no.

WebAudioPlayback is private so you can't override it, and the access modifier is only for properties so you can't access the class through WebAudioSound.  So I copied the code from WebAudioPlayback and made a new class with a position property in the constructor.  Then in the constructor change the call to WebAudioSound.start to:

if (_sourceNode.start != null) {
            _sourceNode.start(WebAudioSound.ctx.currentTime, position);
        } else {
            _sourceNode.noteOn(WebAudioSound.ctx.currentTime, position);
        }

So to start the sound:

new MyWebAudioPlayback(webSound, volume, loop, positionInSecondsFromStartOfFileToStart);

Haven't done a custom version for HTMLSound/HtmlPlayback yet, but assume it will be similar.
Reply all
Reply to author
Forward
0 new messages