| OLD | NEW |
| 1 <!doctype> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title> |
| 5 note-grain-on-timing.html |
| 6 </title> |
| 4 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 9 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 10 <script src="../resources/audit.js"></script> |
| 8 <script src="../resources/note-grain-on-testing.js"></script> | 11 <script src="../resources/note-grain-on-testing.js"></script> |
| 9 </head> | 12 </head> |
| 10 | |
| 11 <body> | 13 <body> |
| 12 <script> | 14 <script id="layout-test-code"> |
| 13 let audit = Audit.createTaskRunner(); | 15 let audit = Audit.createTaskRunner(); |
| 14 | 16 |
| 15 let squarePulseBuffer; | 17 let squarePulseBuffer; |
| 16 | 18 |
| 17 function checkResult(buffer, should) { | 19 function checkResult(buffer, should) { |
| 18 renderedData = buffer.getChannelData(0); | 20 renderedData = buffer.getChannelData(0); |
| 19 let nSamples = renderedData.length; | 21 let nSamples = renderedData.length; |
| 20 let startEndFrames = findStartAndEndSamples(renderedData); | 22 let startEndFrames = findStartAndEndSamples(renderedData); |
| 21 | 23 |
| 22 verifyStartAndEndFrames(startEndFrames, should); | 24 verifyStartAndEndFrames(startEndFrames, should); |
| 23 } | 25 } |
| 24 | 26 |
| 25 audit.define("Test timing of noteGrainOn", function (task, should) { | 27 audit.define('Test timing of noteGrainOn', function(task, should) { |
| 26 // Create offline audio context. | 28 // Create offline audio context. |
| 27 context = new OfflineAudioContext(2, sampleRate * renderTime, | 29 context = |
| 28 sampleRate); | 30 new OfflineAudioContext(2, sampleRate * renderTime, sampleRate); |
| 29 | 31 |
| 30 squarePulseBuffer = createSignalBuffer(context, function (k) { | 32 squarePulseBuffer = createSignalBuffer(context, function(k) { |
| 31 return 1 | 33 return 1 |
| 32 }); | 34 }); |
| 33 | 35 |
| 34 playAllGrains(context, squarePulseBuffer, numberOfTests); | 36 playAllGrains(context, squarePulseBuffer, numberOfTests); |
| 35 | 37 |
| 36 context.startRendering() | 38 context.startRendering().then(function(audioBuffer) { |
| 37 .then(function (audioBuffer) { | 39 checkResult(audioBuffer, should); |
| 38 checkResult(audioBuffer, should); | 40 task.done(); |
| 39 task.done(); | 41 }); |
| 40 }); | |
| 41 }); | 42 }); |
| 42 | 43 |
| 43 audit.run(); | 44 audit.run(); |
| 44 </script> | 45 </script> |
| 45 | |
| 46 </body> | 46 </body> |
| 47 </html> | 47 </html> |
| OLD | NEW |