| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test linearRampToValue Updates the Param Value</title> | 4 <title>Test linearRampToValue Updates the Param Value</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 | 13 |
| 14 var renderQuantumSize = 128; | 14 var renderQuantumSize = 128; |
| 15 // Should be a power of two to get rid of rounding errors when converting
between time and | 15 // Should be a power of two to get rid of rounding errors when converting
between time and |
| 16 // frame. | 16 // frame. |
| 17 var sampleRate = 4096; | 17 var sampleRate = 4096; |
| 18 var renderDuration = 1; | 18 var renderDuration = 1; |
| 19 // End time of the linear ramp automation | 19 // End time of the linear ramp automation |
| 20 var rampEndTime = renderDuration / 2; | 20 var rampEndTime = renderDuration / 2; |
| 21 | 21 |
| 22 var audit = Audit.createTaskRunner(); | 22 var audit = Audit.createTaskRunner(); |
| 23 | 23 |
| 24 // Test that linearRampToValue properly sets the AudioParam .value attribu
te when the | 24 // Test that linearRampToValue properly sets the AudioParam .value attribu
te when the |
| 25 // linearRamp automation is running. | 25 // linearRamp automation is running. |
| 26 audit.defineTask("propagate", function (done) { | 26 audit.define("propagate", (task, should) => { |
| 27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa
mpleRate); | 27 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa
mpleRate); |
| 28 | 28 |
| 29 // Create a constant source. | 29 // Create a constant source. |
| 30 var source = context.createBufferSource(); | 30 var source = context.createBufferSource(); |
| 31 source.buffer = createConstantBuffer(context, 1, 1); | 31 source.buffer = createConstantBuffer(context, 1, 1); |
| 32 source.loop = true; | 32 source.loop = true; |
| 33 | 33 |
| 34 // The gain node to be automated for testing. | 34 // The gain node to be automated for testing. |
| 35 var gain = context.createGain(); | 35 var gain = context.createGain(); |
| 36 | 36 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 var expected = 1; | 54 var expected = 1; |
| 55 | 55 |
| 56 if (context.currentTime <= rampEndTime) { | 56 if (context.currentTime <= rampEndTime) { |
| 57 // The expected value of the gain is the last computed value from
the previous | 57 // The expected value of the gain is the last computed value from
the previous |
| 58 // rendering quantum because suspend() stops at the beginning of a
rendering quantum, | 58 // rendering quantum because suspend() stops at the beginning of a
rendering quantum, |
| 59 // so we haven't computed the new value yet. | 59 // so we haven't computed the new value yet. |
| 60 expected = (context.currentTime - 1 / sampleRate) / rampEndTime; | 60 expected = (context.currentTime - 1 / sampleRate) / rampEndTime; |
| 61 } | 61 } |
| 62 | 62 |
| 63 var frame = context.currentTime * sampleRate - 1; | 63 var frame = context.currentTime * sampleRate - 1; |
| 64 success = Should("gain.gain.value at frame " + frame, gain.gain.valu
e) | 64 success = should(gain.gain.value, |
| 65 .beEqualTo(expected) && success; | 65 "gain.gain.value at frame " + frame) |
| 66 .beEqualTo(expected); |
| 66 }).then(context.resume.bind(context)); | 67 }).then(context.resume.bind(context)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 // Rock and roll! | 70 // Rock and roll! |
| 70 source.start(); | 71 source.start(); |
| 71 context.startRendering().then(function (result) { | 72 context.startRendering().then(function (result) { |
| 72 Should("linearRampToValue", success) | 73 should(success, "linearRampToValue") |
| 73 .summarize("properly set the AudioParam value", | 74 .message("properly set the AudioParam value", |
| 74 "did not properly set the AudioParam value"); | 75 "did not properly set the AudioParam value"); |
| 75 }).then(done); | 76 }).then(() => task.done()); |
| 76 }); | 77 }); |
| 77 | 78 |
| 78 audit.defineTask("finish", function (done) { | 79 audit.run(); |
| 79 done(); | |
| 80 }); | |
| 81 | |
| 82 audit.runTasks(); | |
| 83 </script> | 80 </script> |
| 84 </body> | 81 </body> |
| 85 </html> | 82 </html> |
| OLD | NEW |