Re: how to detect the end of a playing sound ?

The case originally described is about playing mp3 "songs" one after
another.

For that case, it seems to me that the web audio api might be a bit of an
overkill and the <audio> object may be more appropriate, since you can
install callbacks on it for various states of playback. (Googling "html5
audio tag" would give you useful links).

If you need sample accurate continuation, then Chris Rogers answered it.

Regarding performance implications, the overhead of creating and firing
buffer source nodes is low enough that it doesn't impact triggering
hundreds of short sound grains per second. You dont need to do an explicit
noteOff because the nodes have "dynamic lifetime" (
https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#DynamicLifetime
). The
system load is better described by the number of *simultaneously* playing
source nodes.

Hope that helps.
-kumar

On 1 Nov, 2012, at 12:34 AM, Nick Thompson <ncthom91@gmail.com> wrote:

Hi all,

I agree with you both, I think that would be a useful feature, but it leads
me to a question. Are there performance implications for creating a buffer
source node, connecting it to context.destination, calling noteOn(0), and
then forgetting about it? As in, would I see improved performance if I
specifically found all samples that were playing, whose buffer has ended,
and turned them off via noteOff or disconnected them from the destination
node?

Aside from that, Jerome, to your question, potentially a better way of
handling your situation would be to load your mp3 buffers, and then create
a new empty AudioBuffer whose length is the sum of your mp3 buffers'
lengths, and just copy each buffer into the new array in sequence. Then you
could push the large buffer into a BufferSourceNode, and even take
advantage of the "loop" parameter. Maybe you'd find that useful?

-Nick

On Wed, Oct 31, 2012 at 7:54 AM, Gabriel Cardoso
<gabriel.cardoso@inria.fr>wrote:

> Hi !
>
> +1 for that.
>
> I also think such an event would be comfortable.
>
> Gabriel
>
> Le 31 oct. 2012 à 12:39, Jerome Etienne a écrit :
>
> > Hello,
> >
> > i would like to play multiple sounds (songs in mp3) one after the other.
> Is there a way to detect the end of a playing sound ? an event endOfSound
> or something like that ?
> >
> > Currently i storing the duration of the currently playing sound, do a
> settimeout which is triggered after this time, when it is triggered, i stop
> the current sound and start the new one... rather clumsy. is there a better
> way ?
> >
> > Jerome
>
>
>

Received on Thursday, 1 November 2012 04:06:18 UTC