The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

danbernier (22) [Avatar] Offline
#1
(I'm not 100% sure of this, so apologies in advance if I'm wrong.)

In the 'for' loop, the idea is to set myWav.pos to the beginning of some "step" of the sample, and let it play.

The code starts with Math.random2(0, myWav.samples()-grain), which seems right, but then it adds grain to that answer - which seems like, sometimes, it would point position the sample at its end, causing it to not play.

I think you just need to take out the "+ grain".

Again, sorry if I'm off-base. Really liking the book so far.
VanessaVan (6) [Avatar] Offline
#2
Re: Listing 5.8, granularize: off-by-1 error?
What you say seems right to me. Maybe post about it in the coursera forum?
perry.cook (29) [Avatar] Offline
#3
Re: Listing 5.8, granularize: off-by-1 error?
Dan,

Right you are! There would be cases where we'd play
nothing, which just result in a silent frame (which could
be cool as well). But adding grain to the result of the
randomly generated pointer would ensure that we would
never play the frame starting at zero, which isn't very
cool.

I'll change it in the next version of the chapter.

Thanks for your excellent watchfulness and participation
in this forum.

PRC