Re: Problems with multiple functioncalls on the outputbuffer in a ScriptProcessorNode

Well, it seems that i made a calculation-error somewhere that i overlooked
all the time. I've got it working now:
http://petervandernoord.nl/jslooper/default.htm

- click 'from json'
- go the the play-section
- click the load sounds button, and then click on group 1. (it will loop
through all sounds in that group)

However, i must say that i find the audio somewhat sensitive (although the
machine i'm on now seems to do a better job). i didn't have huge loud
ticks, but it did generate some minor ones now and then. they're at
irregular times, and seem to be sometimes (but not always) affected by
ui-stuff.

basically, what i'm doing is writing each sample manually (with a
scriptprocessor) to the outputstream...

(by the way, if the audio doesnt loop correctly, it's because of something
else i encountered, i will start a new thread for that.)

2013/2/11 Joe Berkovitz <joe@noteflight.com>

> Hi Peter,
>
> Can you post a jsfiddle or link to complete working example with source
> code? Even if this pseudo code looks ok there are many possible details in
> the real code that could cause a problem.
>
> Also as a sanity check I suggest playing the source buffer from an
> AudioBufferSourceNode with loop = true to verify that the transients are
> not actually in the audio loop itself.
>
> Best
> .       .    .  . ...Joe
>
> *Joe Berkovitz*
> President
> Noteflight LLC
> +1 978 314 6271
> www.noteflight.com
> "Your music, everywhere."
>
> On Feb 11, 2013, at 3:00 PM, Peter van der Noord <peterdunord@gmail.com>
> wrote:
>
> I've been looking for over 4 hours at a problem that generates quite loud
> ticks in my sound. I have simplified it all the way down, and i am
> wondering if my approach can work at all.
>
> What i'm trying to do is seemlessly stitch multiple audiobuffers together,
> using a custom ScriptProcessorNode (with access to all buffers) to write
> the correct samplevalues (from the correct position and the correct buffer)
> to the output. I've trimmed it all down to just using 1 buffer, that should
> seamlessly restart at the beginning, once it reaches the end.
>
> This is in pseudocode my onaudioprocess-handler:
>
> handleAudioProcessingEvent(event: AudioProcessingEvent): void
> {
>         // there are two cases: either the current writeloop reaches the
> end of the source-buffer, or it doesnt
>
>         if(endNotReached)
>         {
>                 copySamples(bufferSize, 0, currentReadPosition);
>
>                  // params are:
>                  // the amount of samples to write (in this case the
> buffersize of the scriptprocessor)
>                  // the index to start writing in the outputbuffer
>                  // the index to start reading from the sourcebuffer (a
> loaded sample), which will be incremented in the writeloop in the
> copySamples function
>         }
>         else
>         {
>                 // the end of the source buffer will be reached in this
> writingloop,
>                 // so write the remainig samples, then reset the
> readposition, then write the remaining amount of samples
>                 // (so the amount of samples written equals the full
> buffersize of the scriptprocessor)
>
>                 copySamples(numberOfSamplesLeftForSourceSound, 0,
> currentReadPosition);
>                 currentReadPosition = 0;
>                 copySamples(bufferSize -
> numberOfSamplesLeftForSourceSound, numberOfSamplesLeftForSourceSound,
> currentReadPosition);
>         }
> }
>
> When the end is not reached, everything runs ok (although i have the
> feeling i hear some small irregularities now and then), but when the end is
> reached (2nd part of the if-statement), there's some big ticks in the
> audiostream.
>
> I am wondering if passing the outputbuffer to two functioncalls (both
> partially writing in it) has anything to do with it, or that i'm
> overlooking something else.
>
>
> Peter
>
>

Received on Tuesday, 12 February 2013 11:43:53 UTC