OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 audiobuffersource-detune-modulation.html |
| 6 </title> |
| 7 <script src="../../resources/testharness.js"></script> |
| 8 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../resources/audit-util.js"></script> |
| 10 <script src="../resources/audit.js"></script> |
| 11 <script src="../resources/audiobuffersource-testing.js"></script> |
| 12 <script src="../resources/buffer-loader.js"></script> |
| 13 </head> |
| 14 <body> |
| 15 <script id="layout-test-code"> |
| 16 let sampleRate = 44100; |
| 17 let duration = 0.25; |
3 | 18 |
4 <head> | 19 let context = |
5 <script src="../../resources/testharness.js"></script> | 20 new OfflineAudioContext(1, sampleRate * duration, sampleRate); |
6 <script src="../../resources/testharnessreport.js"></script> | 21 let referenceBuffer; |
7 <script src="../resources/audit-util.js"></script> | 22 let audioBufferResult; |
8 <script src="../resources/audit.js"></script> | |
9 <script src="../resources/audiobuffersource-testing.js"></script> | |
10 <script src="../resources/buffer-loader.js"></script> | |
11 </head> | |
12 | 23 |
13 <body> | 24 let audit = Audit.createTaskRunner(); |
14 <script> | |
15 var sampleRate = 44100; | |
16 var duration = 0.25; | |
17 | 25 |
18 var context = new OfflineAudioContext(1, sampleRate * duration, sampleRate); | 26 // Task: Load the reference file asynchronously. In order to create a new |
19 var referenceBuffer; | 27 // reference file, use the task 'generate-reference' below. |
20 var audioBufferResult; | 28 audit.define('load-reference', (task, should) => { |
| 29 let loader = new BufferLoader( |
| 30 context, ['audiobuffersource-detune-modulation-expected.wav'], |
| 31 function(bufferList) { |
| 32 referenceBuffer = bufferList[0]; |
| 33 task.done(); |
| 34 }); |
21 | 35 |
22 var audit = Audit.createTaskRunner(); | 36 loader.load(); |
23 | 37 }); |
24 // Task: Load the reference file asynchronously. In order to create a new | |
25 // reference file, use the task 'generate-reference' below. | |
26 audit.define('load-reference', (task, should) => { | |
27 var loader = new BufferLoader(context, [ | |
28 'audiobuffersource-detune-modulation-expected.wav' | |
29 ], function (bufferList) { | |
30 referenceBuffer = bufferList[0]; | |
31 task.done(); | |
32 }); | |
33 | |
34 loader.load(); | |
35 }); | |
36 | 38 |
37 | 39 |
38 // Task: Render the actual buffer and compare with the reference. | 40 // Task: Render the actual buffer and compare with the reference. |
39 audit.define('generate-verify', (task, should) => { | 41 audit.define('generate-verify', (task, should) => { |
40 | 42 |
41 // With this setting, the detune will be changing continuously and | 43 // With this setting, the detune will be changing continuously and |
42 // repeatedly within the range of [-1200, 1200] around 440Hz, based on the | 44 // repeatedly within the range of [-1200, 1200] around 440Hz, based on |
43 // input from the oscillator. | 45 // the input from the oscillator. |
44 createSawtoothWithModulation(context, 'detune', 440, 1200); | 46 createSawtoothWithModulation(context, 'detune', 440, 1200); |
45 | 47 |
46 context.startRendering().then(function (renderedBuffer) { | 48 context.startRendering() |
47 audioBufferResult = renderedBuffer; | 49 .then(function(renderedBuffer) { |
48 var actual = renderedBuffer.getChannelData(0); | 50 audioBufferResult = renderedBuffer; |
49 var expected = referenceBuffer.getChannelData(0); | 51 let actual = renderedBuffer.getChannelData(0); |
| 52 let expected = referenceBuffer.getChannelData(0); |
50 | 53 |
51 // Compare two buffers with arbitrary (yet reasonable) constraints. | 54 // Compare two buffers with arbitrary (yet reasonable) |
52 // There parameters are determined by try bot experiments. | 55 // constraints. There parameters are determined by try bot |
53 compareBuffersWithConstraints(should, actual, expected, { | 56 // experiments. |
54 prefix: "", | 57 compareBuffersWithConstraints(should, actual, expected, { |
55 thresholdSNR: 93.31, | 58 prefix: '', |
56 thresholdDiffULP: 1.01, | 59 thresholdSNR: 93.31, |
57 thresholdDiffCount: 0, | 60 thresholdDiffULP: 1.01, |
58 bitDepth: 16}); | 61 thresholdDiffCount: 0, |
| 62 bitDepth: 16 |
| 63 }); |
59 | 64 |
60 var filename = 'audiobuffersource-detune-modulation-actual.wav'; | 65 let filename = 'audiobuffersource-detune-modulation-actual.wav'; |
61 if (downloadAudioBuffer(renderedBuffer, filename)) | 66 if (downloadAudioBuffer(renderedBuffer, filename)) |
62 should(true, "Saved reference file").message(filename, ""); | 67 should(true, 'Saved reference file').message(filename, ''); |
63 }).then(() => task.done()); | 68 }) |
64 }); | 69 .then(() => task.done()); |
| 70 }); |
65 | 71 |
66 audit.run(); | 72 audit.run(); |
67 </script> | 73 </script> |
68 </body> | 74 </body> |
69 | |
70 </html> | 75 </html> |
OLD | NEW |