Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <script src="resources/audio-testing.js"></script> | 5 <script src="resources/audio-testing.js"></script> |
| 6 <script src="resources/compatibility.js"></script> | 6 <script src="resources/compatibility.js"></script> |
| 7 <script src="resources/audiobuffersource-testing.js"></script> | 7 <script src="resources/audiobuffersource-testing.js"></script> |
| 8 <script src="../resources/js-test.js"></script> | 8 <script src="../resources/js-test.js"></script> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, | 80 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, |
| 81 | 81 |
| 82 { description: "illegal loop: loopStartFrame < 0", | 82 { description: "illegal loop: loopStartFrame < 0", |
| 83 loopStartFrame: -8, loopEndFrame: 3, renderFrames: 16, playbackRate: 1, | 83 loopStartFrame: -8, loopEndFrame: 3, renderFrames: 16, playbackRate: 1, |
| 84 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, | 84 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, |
| 85 | 85 |
| 86 { description: "illegal loop: loopEndFrame > bufferLength", | 86 { description: "illegal loop: loopEndFrame > bufferLength", |
| 87 loopStartFrame: 0, loopEndFrame: 30000, renderFrames: 16, playbackRate: 1, | 87 loopStartFrame: 0, loopEndFrame: 30000, renderFrames: 16, playbackRate: 1, |
| 88 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, | 88 expected: [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7] }, |
| 89 | 89 |
| 90 // Start a loop with a duration longer than the buffer. The output should be th e data from frame 1 | |
| 91 // to 6, and then looping from 3 to 5 until 30 frames have been played. | |
| 92 { description: "loop from 3 -> 6 with offset 1 for 31 frames", | |
| 93 loopStartFrame: 3, loopEndFrame: 6, playbackRate: 1, | |
| 94 offsetFrame: 1, | |
| 95 durationFrames: 30, | |
| 96 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] }, | |
| 97 | |
|
hongchan
2015/02/03 23:09:05
I understand there are so many objects and propert
Raymond Toy
2015/02/04 00:18:06
Done.
| |
| 90 ]; | 98 ]; |
| 91 | 99 |
| 92 var sampleRate = 44100; | 100 var sampleRate = 44100; |
| 93 var buffer; | 101 var buffer; |
| 94 var bufferFrameLength = 8; | 102 var bufferFrameLength = 8; |
| 95 var testSpacingFrames = 32; | 103 var testSpacingFrames = 32; |
| 96 var testSpacingSeconds = testSpacingFrames / sampleRate; | 104 var testSpacingSeconds = testSpacingFrames / sampleRate; |
| 97 var totalRenderLengthFrames = tests.length * testSpacingFrames; | 105 var totalRenderLengthFrames = tests.length * testSpacingFrames; |
| 98 | 106 |
| 99 function runLoopTest(context, testNumber, test) { | 107 function runLoopTest(context, testNumber, test) { |
| 100 var source = context.createBufferSource(); | 108 var source = context.createBufferSource(); |
| 101 | 109 |
| 102 source.buffer = buffer; | 110 source.buffer = buffer; |
| 103 source.playbackRate.value = test.playbackRate; | 111 source.playbackRate.value = test.playbackRate; |
| 104 source.loop = true; | 112 source.loop = true; |
| 105 source.loopStart = test.loopStartFrame / context.sampleRate; | 113 source.loopStart = test.loopStartFrame / context.sampleRate; |
| 106 source.loopEnd = test.loopEndFrame / context.sampleRate; | 114 source.loopEnd = test.loopEndFrame / context.sampleRate; |
| 107 | 115 |
| 108 var offset = test.offsetFrame ? test.offsetFrame / context.sampleRate : 0; | 116 var offset = test.offsetFrame ? test.offsetFrame / context.sampleRate : 0; |
| 109 | 117 |
| 110 source.connect(context.destination); | 118 source.connect(context.destination); |
| 111 | 119 |
| 112 // Render each test one after the other, spaced apart by testSpacingSeconds. | 120 // Render each test one after the other, spaced apart by testSpacingSeconds. |
| 113 var startTime = testNumber * testSpacingSeconds; | 121 var startTime = testNumber * testSpacingSeconds; |
| 114 var duration = test.renderFrames / context.sampleRate; | 122 |
| 115 source.start(startTime, offset); | 123 if (test.renderFrames) { |
| 116 source.stop(startTime + duration); | 124 var duration = test.renderFrames / context.sampleRate; |
| 125 if (test.renderFrames > testSpacingFrames || test.renderFrames < 0) { | |
| 126 testFailed("Test " + testNumber | |
| 127 + ": renderFrames (" + test.renderFrames + ") outside the range [0, " | |
| 128 + testSpacingFrames + "]"); | |
| 129 } | |
| 130 source.start(startTime, offset); | |
| 131 source.stop(startTime + duration); | |
| 132 } else if (test.durationFrames) { | |
| 133 if (test.durationFrames > testSpacingFrames || test.durationFrames < 0) { | |
| 134 testFailed("Test " + testNumber | |
| 135 + ": durationFrames (" + test.durationFrames + ") outside the ra nge [0, " | |
| 136 + testSpacingFrames + "]"); | |
| 137 } | |
| 138 source.start(startTime, offset, test.durationFrames / context.sampleRate ); | |
| 139 } else { | |
| 140 testFailed("Test " + testNumber + " must specify one of renderFrames or durationFrames"); | |
| 141 } | |
| 117 } | 142 } |
| 118 | 143 |
| 119 function runTest() { | 144 function runTest() { |
| 120 if (window.testRunner) { | 145 if (window.testRunner) { |
| 121 testRunner.dumpAsText(); | 146 testRunner.dumpAsText(); |
| 122 testRunner.waitUntilDone(); | 147 testRunner.waitUntilDone(); |
| 123 } | 148 } |
| 124 | 149 |
| 125 window.jsTestIsAsync = true; | 150 window.jsTestIsAsync = true; |
| 126 | 151 |
| 127 // Create offline audio context. | 152 // Create offline audio context. |
| 128 var context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate ); | 153 var context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate ); |
| 129 buffer = createTestBuffer(context, bufferFrameLength); | 154 buffer = createTestBuffer(context, bufferFrameLength); |
| 130 | 155 |
| 131 for (var i = 0; i < tests.length; ++i) | 156 for (var i = 0; i < tests.length; ++i) |
| 132 runLoopTest(context, i, tests[i]); | 157 runLoopTest(context, i, tests[i]); |
| 133 | 158 |
| 134 context.oncomplete = checkAllTests; | 159 context.oncomplete = checkAllTests; |
| 135 context.startRendering(); | 160 context.startRendering(); |
| 136 } | 161 } |
| 137 | 162 |
| 138 runTest(); | 163 runTest(); |
| 139 successfullyParsed = true; | 164 successfullyParsed = true; |
| 140 | 165 |
| 141 </script> | 166 </script> |
| 142 | 167 |
| 143 </body> | 168 </body> |
| 144 </html> | 169 </html> |
| OLD | NEW |