| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 | 3 |
| 4 <head> | 4 <head> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 8 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| 11 <body> | 11 <body> |
| 12 <script> | 12 <script> |
| 13 | 13 |
| 14 // Sample rate should be power of 128 to observe the change of AudioParam at | 14 // Sample rate should be power of 128 to observe the change of AudioParam at |
| 15 // the beginning of rendering quantum. (playbackRate is k-rate) This is the | 15 // the beginning of rendering quantum. (playbackRate is k-rate) This is the |
| 16 // minimum sample rate in the valid sample rate range. | 16 // minimum sample rate in the valid sample rate range. |
| 17 var sampleRate = 4096; | 17 var sampleRate = 4096; |
| 18 | 18 |
| 19 // The render duration in seconds, and the length in samples. | 19 // The render duration in seconds, and the length in samples. |
| 20 var renderDuration = 1.0; | 20 var renderDuration = 1.0; |
| 21 var renderLength = renderDuration * sampleRate; | 21 var renderLength = renderDuration * sampleRate; |
| 22 | 22 |
| 23 var context = new OfflineAudioContext(1, renderLength, sampleRate); | 23 var context = new OfflineAudioContext(1, renderLength, sampleRate); |
| 24 var audit = Audit.createTaskRunner(); | 24 var audit = Audit.createTaskRunner(); |
| 25 | 25 |
| 26 | 26 |
| 27 // Task: Render the actual buffer and compare with the reference. | 27 // Task: Render the actual buffer and compare with the reference. |
| 28 audit.defineTask('synthesize-verify', function (done) { | 28 audit.define('synthesize-verify', (task, should) => { |
| 29 var ramp = context.createBufferSource(); | 29 var ramp = context.createBufferSource(); |
| 30 var rampBuffer = createLinearRampBuffer(context, renderLength); | 30 var rampBuffer = createLinearRampBuffer(context, renderLength); |
| 31 ramp.buffer = rampBuffer; | 31 ramp.buffer = rampBuffer; |
| 32 | 32 |
| 33 ramp.connect(context.destination); | 33 ramp.connect(context.destination); |
| 34 ramp.start(); | 34 ramp.start(); |
| 35 | 35 |
| 36 // Leave the playbackRate as 1 for the first half, then change it | 36 // Leave the playbackRate as 1 for the first half, then change it |
| 37 // to zero at the exact half. The zero playback rate should hold the | 37 // to zero at the exact half. The zero playback rate should hold the |
| 38 // sample value of the buffer index at the moment. (sample-and-hold) | 38 // sample value of the buffer index at the moment. (sample-and-hold) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 } else { | 56 } else { |
| 57 // From the half position, the actual value should not change. | 57 // From the half position, the actual value should not change. |
| 58 if (data[i] !== rampData[half]) { | 58 if (data[i] !== rampData[half]) { |
| 59 passed = false; | 59 passed = false; |
| 60 break; | 60 break; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 Should('The zero playbackRate', passed) | 65 should(passed, 'The zero playbackRate') |
| 66 .summarize( | 66 .message( |
| 67 'held the sample value correctly', | 67 'held the sample value correctly', |
| 68 'should hold the sample value. ' + 'Expected ' + rampData[half] + | 68 'should hold the sample value. ' + 'Expected ' + rampData[half] + |
| 69 ' but got ' + data[i] + ' at the index ' + i); | 69 ' but got ' + data[i] + ' at the index ' + i); |
| 70 }).then(done); | 70 }).then(() => task.done()); |
| 71 }); | 71 }); |
| 72 | 72 |
| 73 audit.defineTask('finish', function (done) { | 73 audit.run(); |
| 74 done(); | |
| 75 }); | |
| 76 | |
| 77 audit.runTasks( | |
| 78 'synthesize-verify', | |
| 79 'finish' | |
| 80 ); | |
| 81 | |
| 82 successfullyParsed = true; | |
| 83 </script> | 74 </script> |
| 84 </body> | 75 </body> |
| 85 | 76 |
| 86 </html> | 77 </html> |
| OLD | NEW |