Index: LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html |
diff --git a/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html b/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html |
index 1ddb02073c7279d0bea8418fbea25ab9815de685..4110e8f5228b8ab569ea93d6d559c91194ea89c3 100644 |
--- a/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html |
+++ b/LayoutTests/webaudio/audiobuffersource-loop-comprehensive.html |
@@ -136,14 +136,37 @@ var tests = [ |
expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, |
// Start a loop with a duration longer than the buffer. The output should be the data from frame 1 |
-// to 6, and then looping from 3 to 5 until 30 frames have been played. |
-{ description: "loop from 3 -> 6 with offset 1 for 31 frames", |
+// to 6, and then looping from 3 to 5 until 20 frames have been played. |
+{ description: "loop from 3 -> 6 with offset 1 for 20 frames", |
loopStartFrame: 3, |
loopEndFrame: 6, |
playbackRate: 1, |
offsetFrame: 1, |
- durationFrames: 30, |
- expected: [1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3] }, |
+ renderFrames: 30, |
+ durationFrames: 20, |
+ expected: [1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, |
+ |
+// Start a loop with a duration less than the grain length. The output should be the data from |
hongchan
2015/02/20 22:49:45
By 'grain length', do you mean the playback durati
Raymond Toy
2015/02/20 23:06:18
No. It's the length of the looping region from loo
|
+// frame 1 to 3, and then stopping because duration = 3 |
+{ description: "loop from 3 -> 8 with offset 1 for 3 frames", |
+ loopStartFrame: 3, |
+ loopEndFrame: 8, |
+ playbackRate: 1, |
+ offsetFrame: 1, |
+ durationFrames: 3, |
+ renderFrames: 30, |
+ expected: [1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, |
+ |
+// Start a loop with a duration less than the grain length. The output should be the data from |
+// frame 1 to 3, and then stopping because duration = 3 |
+{ description: "loop from 3 -> 8 with offset 7 for 3 frames", |
+ loopStartFrame: 3, |
+ loopEndFrame: 8, |
+ playbackRate: 1, |
+ offsetFrame: 7, |
+ durationFrames: 3, |
+ renderFrames: 30, |
+ expected: [7, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, |
hongchan
2015/02/20 22:49:45
This is the last item in the array. The comma shou
|
]; |
@@ -170,7 +193,19 @@ function runLoopTest(context, testNumber, test) { |
// Render each test one after the other, spaced apart by testSpacingSeconds. |
var startTime = testNumber * testSpacingSeconds; |
- if (test.renderFrames) { |
+ // If durationFrames is given, run the test for the specified duration. |
+ if (test.durationFrames) { |
+ if (!test.renderFrames) { |
+ testFailed("renderFrames is required for test " + testNumber + ": " + test.description); |
+ } else { |
+ if (test.durationFrames > testSpacingFrames || test.durationFrames < 0) { |
+ testFailed("Test " + testNumber |
+ + ": durationFrames (" + test.durationFrames + ") outside the range [0, " |
+ + testSpacingFrames + "]"); |
+ } |
+ source.start(startTime, offset, test.durationFrames / context.sampleRate); |
+ } |
+ } else if (test.renderFrames) { |
var duration = test.renderFrames / context.sampleRate; |
if (test.renderFrames > testSpacingFrames || test.renderFrames < 0) { |
testFailed("Test " + testNumber |
@@ -179,24 +214,12 @@ function runLoopTest(context, testNumber, test) { |
} |
source.start(startTime, offset); |
source.stop(startTime + duration); |
- } else if (test.durationFrames) { |
- if (test.durationFrames > testSpacingFrames || test.durationFrames < 0) { |
- testFailed("Test " + testNumber |
- + ": durationFrames (" + test.durationFrames + ") outside the range [0, " |
- + testSpacingFrames + "]"); |
- } |
- source.start(startTime, offset, test.durationFrames / context.sampleRate); |
} else { |
- testFailed("Test " + testNumber + " must specify one of renderFrames or durationFrames"); |
+ testFailed("Test " + testNumber + " must specify renderFrames and possibly durationFrames"); |
} |
} |
function runTest() { |
- if (window.testRunner) { |
- testRunner.dumpAsText(); |
- testRunner.waitUntilDone(); |
- } |
- |
window.jsTestIsAsync = true; |
// Create offline audio context. |