Re: Looping a specific number of times

Ehsan,

I believe the time specified in stop() must be sample-accurate, it is not something that can be rounded to the nearest processing block. That would be a regression that would break existing apps which already use loops. The spec states, "Schedules a sound to stop playback at an exact time".

The exact case you are describing already works in the webkit implementation as Chris W described, by enabling looping and setting the stop() time to occur at the start() time plus an exact multiple of the buffer length.  

…Joe

On Mar 21, 2013, at 12:28 AM, Ehsan Akhgari <ehsan.akhgari@gmail.com> wrote:

> OK, I'll look into this more closely and will report back if scheduling a stop() event is not enough.
> 
> --
> Ehsan
> <http://ehsanakhgari.org/>
> 
> 
> On Thu, Mar 21, 2013 at 12:25 AM, Chris Wilson <cwilso@google.com> wrote:
> rounding errors from the stop time?  No, that should be well below the precision.
> 
> 
> On Wed, Mar 20, 2013 at 9:22 PM, Ehsan Akhgari <ehsan.akhgari@gmail.com> wrote:
> It's not, but wouldn't that cause potential glitches resulting from rounding errors?
> 
> --
> Ehsan
> <http://ehsanakhgari.org/>
> 
> 
> On Wed, Mar 20, 2013 at 5:58 PM, Chris Wilson <cwilso@google.com> wrote:
> I meant scheduling a stop(startTime+duration*loops).  That shouldn't be driven from the main thread at all, should it?
> 
> On Mar 20, 2013 2:35 PM, "Ehsan Akhgari" <ehsan.akhgari@gmail.com> wrote:
> No, I'm not specifically talking about playback rate change.  The problem with relying on calling stop() is that stop() is driven off of the main thread, which makes it tricky to call it at the exact right time, which means that we will either cut the last iteration of the loop prematurely or we'll overplay from loopStart shortly before stop() manages to actually stop the playback.
> 
> --
> Ehsan
> <http://ehsanakhgari.org/>
> 
> 
> On Wed, Mar 20, 2013 at 5:26 PM, Chris Wilson <cwilso@google.com> wrote:
> I presume you mean in case playback rate is changed?  Otherwise you can just call stop() for now +duration*loops.
> 
> On Mar 20, 2013 2:22 PM, "Ehsan Akhgari" <ehsan.akhgari@gmail.com> wrote:
> There are use cases where you want to loop over an AudioBufferSourceNode a specific number of times.  I think that in the current spec, the only way to do that accurately would be to copy the same content enough number of times after in the buffer.  I think this could be a useful feature for us to support, and I think we can do that by adding a loopRounds (bikeshedding on the name to be done later ;) attribute to AudioBufferSourceNode, which basically stops the loop after loopRounds rounds if stop() is not called beforehand.
> 
> What do you all think about this?
> 
> Thanks!
> --
> Ehsan
> <http://ehsanakhgari.org/>
> 
> 
> 
> 

.            .       .    .  . ...Joe

Joe Berkovitz
President

Noteflight LLC
Boston, Mass.
phone: +1 978 314 6271
www.noteflight.com
"Your music, everywhere"

Received on Thursday, 21 March 2013 20:14:48 UTC