Index: third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js |
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js |
index f19d57e245062dcecda99f33316fecd8819f1a5a..6c948f7346fca235b21fcd9606464cb814e6c3d9 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js |
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/note-grain-on-testing.js |
@@ -29,22 +29,21 @@ let renderedData; |
// Create a buffer containing the data that we want. The function f |
// returns the desired value at sample frame k. |
function createSignalBuffer(context, f) { |
+ // Make sure the buffer has enough data for all of the possible |
+ // grain offsets and durations. Need to include the extra frames |
+ // for HRTF. The additional 1 is for any round-off errors. |
+ let signalLength = Math.floor( |
+ 1 + extraFramesHRTF + |
+ sampleRate * (numberOfTests * grainOffsetStep + duration)); |
+ |
+ let buffer = context.createBuffer(2, signalLength, sampleRate); |
+ let data = buffer.getChannelData(0); |
+ |
+ for (let k = 0; k < signalLength; ++k) { |
+ data[k] = f(k); |
+ } |
- // Make sure the buffer has enough data for all of the possible |
- // grain offsets and durations. Need to include the extra frames |
- // for HRTF. The additional 1 is for any round-off errors. |
- let signalLength = Math.floor( |
- 1 + extraFramesHRTF + |
- sampleRate * (numberOfTests * grainOffsetStep + duration)); |
- |
- let buffer = context.createBuffer(2, signalLength, sampleRate); |
- let data = buffer.getChannelData(0); |
- |
- for (let k = 0; k < signalLength; ++k) { |
- data[k] = f(k); |
- } |
- |
- return buffer; |
+ return buffer; |
} |
// From the data array, find the start and end sample frame for each |
@@ -75,9 +74,9 @@ function findStartAndEndSamples(data) { |
lookForStart = true; |
} |
} |
- } |
+ } |
- return {start : startTime, end : endTime}; |
+ return {start: startTime, end: endTime}; |
} |
function playGrain(context, source, time, offset, duration) { |
@@ -101,9 +100,9 @@ function playAllGrains(context, source, numberOfNotes) { |
playGrain(context, source, timeOffset, grainOffset, duration); |
startTimes[k] = timeOffset; |
offsets[k] = grainOffset; |
- } |
+ } |
- return { startTimes : startTimes, grainOffsetTimes : offsets }; |
+ return {startTimes: startTimes, grainOffsetTimes: offsets}; |
} |
// Verify that the start and end frames for each grain match our |
@@ -150,7 +149,8 @@ function verifyStartAndEndFrames(startEndFrames, should) { |
.beEqualTo(numberOfTests); |
} else { |
should( |
- errorCountStart, 'Number of grains out of ' + numberOfTests + |
+ errorCountStart, |
+ 'Number of grains out of ' + numberOfTests + |
'that started at the wrong time') |
.beEqualTo(0); |
} |
@@ -160,7 +160,8 @@ function verifyStartAndEndFrames(startEndFrames, should) { |
.beEqualTo(numberOfTests); |
} else { |
should( |
- errorCountEnd, 'Number of grains out of ' + numberOfTests + |
+ errorCountEnd, |
+ 'Number of grains out of ' + numberOfTests + |
' that ended at the wrong time') |
.beEqualTo(0); |
} |