Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review comments
* Rename `bufferDuration` to `bufferTimeElapsed`
* Initialize `bufferTime` to `offset`.
  • Loading branch information
Raymond Toy committed Jul 12, 2018
commit a57fe0818bafa460755eb6e216486504e9704d05
10 changes: 5 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4822,7 +4822,7 @@ let stop = Infinity; // Set by stop()

// Variables for tracking node's playback state
let bufferTime = 0, started = false, enteredLoop = false;
let bufferDuration = 0;
let bufferTimeElapsed = 0;
let dt = 1 / context.sampleRate;

// Handle invocation of start method call
Expand Down Expand Up @@ -4896,16 +4896,16 @@ function process(numberOfFrames) {

// Render each sample frame in the quantum
for (let index = 0; index < numberOfFrames; index++) {
// Check that currentTime and bufferDuration are within allowable range for playback
if (currentTime < start || currentTime >= stop || bufferDuration >= duration) {
// Check that currentTime and bufferTimeElapsed are within allowable range for playback
if (currentTime < start || currentTime >= stop || bufferTimeElapsed >= duration) {
output.push(0); // this sample frame is silent
currentTime += dt;
continue;
}

if (!started) {
// Take note that buffer has started playing and get initial playhead position.
bufferTime = offset + bufferDuration;
bufferTime = offset;
started = true;
}

Expand Down Expand Up @@ -4942,7 +4942,7 @@ function process(numberOfFrames) {
}

bufferTime += dt * computedPlaybackRate;
bufferDuration += dt * computedPlaybackRate;
bufferTimeElapsed += dt * computedPlaybackRate;
currentTime += dt;
} // End of render quantum loop

Expand Down