| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test WaveShaper Copies Curve Data</title> | 4 <title>Test WaveShaper Copies Curve Data</title> |
| 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 // Sample rate and number of frames are fairly arbitrary. We need to | 13 // Sample rate and number of frames are fairly arbitrary. We need to |
| 14 // render, however, at least 384 frames. 1024 is a nice small value. | 14 // render, however, at least 384 frames. 1024 is a nice small value. |
| 15 var sampleRate = 16000; | 15 var sampleRate = 16000; |
| 16 var renderFrames = 1024; | 16 var renderFrames = 1024; |
| 17 | 17 |
| 18 var audit = Audit.createTaskRunner(); | 18 var audit = Audit.createTaskRunner(); |
| 19 | 19 |
| 20 audit.defineTask("test copying", function (taskDone) { | 20 audit.define("test copying", (task, should) => { |
| 21 // Two-channel context; channel 0 contains the test data and channel 1 | 21 // Two-channel context; channel 0 contains the test data and channel 1 |
| 22 // contains the expected result. Channel 1 has the normal WaveShaper | 22 // contains the expected result. Channel 1 has the normal WaveShaper |
| 23 // output and channel 0 has the WaveShaper output with a modified curve. | 23 // output and channel 0 has the WaveShaper output with a modified curve. |
| 24 var context = new OfflineAudioContext(2, renderFrames, sampleRate); | 24 var context = new OfflineAudioContext(2, renderFrames, sampleRate); |
| 25 | 25 |
| 26 // Just use a default oscillator as the source. Doesn't really matter | 26 // Just use a default oscillator as the source. Doesn't really matter |
| 27 // what we use. | 27 // what we use. |
| 28 var src = context.createOscillator(); | 28 var src = context.createOscillator(); |
| 29 src.type = "sawtooth"; | 29 src.type = "sawtooth"; |
| 30 | 30 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 .then(context.resume.bind(context)); | 66 .then(context.resume.bind(context)); |
| 67 | 67 |
| 68 src.start(); | 68 src.start(); |
| 69 | 69 |
| 70 context.startRendering().then(function (renderedBuffer) { | 70 context.startRendering().then(function (renderedBuffer) { |
| 71 var actual = renderedBuffer.getChannelData(0); | 71 var actual = renderedBuffer.getChannelData(0); |
| 72 var expected = renderedBuffer.getChannelData(1); | 72 var expected = renderedBuffer.getChannelData(1); |
| 73 | 73 |
| 74 // Modifying the wave shaper curve should not modify the output so the | 74 // Modifying the wave shaper curve should not modify the output so the |
| 75 // outputs from the two wave shaper nodes should be exactly identical. | 75 // outputs from the two wave shaper nodes should be exactly identical. |
| 76 var success = Should("WaveShaper with modified curve", actual) | 76 should(actual, "WaveShaper with modified curve") |
| 77 .beEqualToArray(expected); | 77 .beEqualToArray(expected); |
| 78 | 78 |
| 79 Should("Summary: ", success).summarize( | 79 }).then(() => task.done()); |
| 80 "Output correctly did not change with modified WaveShaper curve.", | |
| 81 "Output incorrectly changed due to modified WaveShaper curve."); | |
| 82 }).then(taskDone); | |
| 83 }); | 80 }); |
| 84 | 81 |
| 85 audit.runTasks(); | 82 audit.run(); |
| 86 </script> | 83 </script> |
| 87 </body> | 84 </body> |
| 88 </html> | 85 </html> |
| OLD | NEW |