Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 | 3 |
| 4 <head> | 4 <head> |
| 5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audio-testing.js"></script> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <script> | 12 <script> |
| 12 description('Test if StereoPannerNode producing glitches by crossing zero.') ; | |
| 13 window.jsTestIsAsync = true; | |
| 14 | |
| 15 var sampleRate = 44100; | 13 var sampleRate = 44100; |
| 16 var renderDuration = 0.5; | 14 var renderDuration = 0.5; |
| 17 | 15 |
| 18 // The threshold for glitch detection. This was experimentally determined. | 16 // The threshold for glitch detection. This was experimentally determined. |
| 19 var GLITCH_THRESHOLD = 0.0005; | 17 var GLITCH_THRESHOLD = 0.0005; |
| 20 | 18 |
| 21 // The maximum threshold for the error between the actual and the expected | 19 // The maximum threshold for the error between the actual and the expected |
| 22 // sample values. Experimentally determined. | 20 // sample values. Experimentally determined. |
| 23 var MAX_ERROR_ALLOWED = 0.0000001; | 21 var MAX_ERROR_ALLOWED = 0.0000001; |
| 24 | 22 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 35 function extractPanningTransition(input) { | 33 function extractPanningTransition(input) { |
| 36 var chanL = input.getChannelData(0); | 34 var chanL = input.getChannelData(0); |
| 37 var chanR = input.getChannelData(1); | 35 var chanR = input.getChannelData(1); |
| 38 var start, end; | 36 var start, end; |
| 39 var index = 1; | 37 var index = 1; |
| 40 | 38 |
| 41 // Find transition by comparing two consecutive samples. If two consecutiv e | 39 // Find transition by comparing two consecutive samples. If two consecutiv e |
| 42 // samples are identical, the transition has not started. | 40 // samples are identical, the transition has not started. |
| 43 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) { | 41 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) { |
| 44 if (++index >= input.length) { | 42 if (++index >= input.length) { |
| 45 testFailed('No transition found in the channel data.'); | 43 // TODO(rtoy): Replace this |
|
hongchan
2017/02/21 17:11:36
If this is replaced as you wanted, please remove t
Raymond Toy
2017/02/21 17:41:54
Done.
| |
| 44 Should(false, Transition in the channel data') | |
| 45 .summarize('found', 'not found'); | |
| 46 return null; | 46 return null; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 start = index - 1; | 49 start = index - 1; |
| 50 | 50 |
| 51 // Find the end of transition. If two consecutive samples are not equal, | 51 // Find the end of transition. If two consecutive samples are not equal, |
| 52 // the transition is still ongoing. | 52 // the transition is still ongoing. |
| 53 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) { | 53 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) { |
| 54 if (++index >= input.length) { | 54 if (++index >= input.length) { |
| 55 testFailed('A transition found but the buffer ended prematurely.'); | 55 Should(false, 'Transition found') |
| 56 .summarize('', 'but the buffer ended prematurely'); | |
| 56 return null; | 57 return null; |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 end = index; | 60 end = index; |
| 60 | 61 |
| 61 testPassed('Transition found between sample #' + start + ' and #' + end + '.'); | 62 Should('Transition found between sample #' + start + ' and #' + end, |
| 63 true) | |
| 64 .summarize('correctly', 'incorrectly'); | |
| 62 | 65 |
| 63 return { | 66 return { |
| 64 left: chanL.subarray(start, end), | 67 left: chanL.subarray(start, end), |
| 65 right: chanR.subarray(start, end), | 68 right: chanR.subarray(start, end), |
| 66 length: end - start | 69 length: end - start |
| 67 }; | 70 }; |
| 68 } | 71 } |
| 69 | 72 |
| 70 // JS implementation of stereo equal power panning. | 73 // JS implementation of stereo equal power panning. |
| 71 function panStereoEqualPower(pan, inputL, inputR) { | 74 function panStereoEqualPower(pan, inputL, inputR) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 167 |
| 165 | 168 |
| 166 // Task: move pan from positive (0.1) to negative (-0.1) value to check if | 169 // Task: move pan from positive (0.1) to negative (-0.1) value to check if |
| 167 // there is a glitch during the transition. | 170 // there is a glitch during the transition. |
| 168 audit.defineTask('positive-to-negative', function (done) { | 171 audit.defineTask('positive-to-negative', function (done) { |
| 169 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done); | 172 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done); |
| 170 }); | 173 }); |
| 171 | 174 |
| 172 audit.defineTask('finish-test', function (done) { | 175 audit.defineTask('finish-test', function (done) { |
| 173 done(); | 176 done(); |
| 174 finishJSTest(); | |
| 175 }); | 177 }); |
| 176 | 178 |
| 177 audit.runTasks( | 179 audit.runTasks( |
| 178 'negative-to-positive', | 180 'negative-to-positive', |
| 179 'positive-to-negative', | 181 'positive-to-negative', |
| 180 'finish-test' | 182 'finish-test' |
| 181 ); | 183 ); |
| 182 | |
| 183 successfullyParsed = true; | |
| 184 </script> | 184 </script> |
| 185 </body> | 185 </body> |
| 186 | 186 |
| 187 </html> | 187 </html> |
| OLD | NEW |