| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 7 <script src="../resources/audit.js"></script> |
| 8 <script src="../resources/audio-param.js"></script> | 8 <script src="../resources/audio-param.js"></script> |
| 9 <title>Updating of Value Attribute from Timeline</title> | 9 <title>Updating of Value Attribute from Timeline</title> |
| 10 </head> | 10 </head> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Test the value attribute from a linearRamp event | 26 // Test the value attribute from a linearRamp event |
| 27 runTest(should, function (g, v0, t0, v1, t1) { | 27 runTest(should, function (g, v0, t0, v1, t1) { |
| 28 g.gain.linearRampToValueAtTime(v1, t1); | 28 g.gain.linearRampToValueAtTime(v1, t1); |
| 29 return { | 29 return { |
| 30 expectedValue: function (testTime) { | 30 expectedValue: function (testTime) { |
| 31 return audioParamLinearRamp(testTime, v0, t0, v1, t1); | 31 return audioParamLinearRamp(testTime, v0, t0, v1, t1); |
| 32 }, | 32 }, |
| 33 message: "linearRamp(" + v1 + ", " + t1 + ")", | 33 message: "linearRamp(" + v1 + ", " + t1 + ")", |
| 34 errorThreshold: 1.1650e-6 | 34 errorThreshold: 1.1650e-6 |
| 35 }; | 35 }; |
| 36 }).then(done); | 36 }).then(() => task.done()); |
| 37 }); | 37 }); |
| 38 | 38 |
| 39 audit.define("exponential", (task, should) => { | 39 audit.define("exponential", (task, should) => { |
| 40 // Test the value attribute from an exponentialRamp event | 40 // Test the value attribute from an exponentialRamp event |
| 41 runTest(should, function (g, v0, t0, v1, t1) { | 41 runTest(should, function (g, v0, t0, v1, t1) { |
| 42 g.gain.exponentialRampToValueAtTime(v1, t1); | 42 g.gain.exponentialRampToValueAtTime(v1, t1); |
| 43 return { | 43 return { |
| 44 expectedValue: function (testTime) { | 44 expectedValue: function (testTime) { |
| 45 return audioParamExponentialRamp(testTime, v0, t0, v1, t1); | 45 return audioParamExponentialRamp(testTime, v0, t0, v1, t1); |
| 46 }, | 46 }, |
| 47 message: "exponentialRamp(" + v1 + ", " + t1 + ")", | 47 message: "exponentialRamp(" + v1 + ", " + t1 + ")", |
| 48 errorThreshold: 7.4601e-7 | 48 errorThreshold: 7.4601e-7 |
| 49 }; | 49 }; |
| 50 }).then(done); | 50 }).then(() => task.done()); |
| 51 }); | 51 }); |
| 52 | 52 |
| 53 audit.define("setTarget", (task, should) => { | 53 audit.define("setTarget", (task, should) => { |
| 54 // Test the value attribute from a setTargetAtTime event | 54 // Test the value attribute from a setTargetAtTime event |
| 55 runTest(should, function (g, v0, t0, v1, t1) { | 55 runTest(should, function (g, v0, t0, v1, t1) { |
| 56 var timeConstant = 0.1; | 56 var timeConstant = 0.1; |
| 57 var vFinal = 0; | 57 var vFinal = 0; |
| 58 g.gain.setTargetAtTime(vFinal, t0, timeConstant); | 58 g.gain.setTargetAtTime(vFinal, t0, timeConstant); |
| 59 return { | 59 return { |
| 60 expectedValue: function (testTime) { | 60 expectedValue: function (testTime) { |
| 61 return audioParamSetTarget(testTime, v0, t0, vFinal, timeConstant)
; | 61 return audioParamSetTarget(testTime, v0, t0, vFinal, timeConstant)
; |
| 62 }, | 62 }, |
| 63 message: "setTargetAtTime(" + vFinal + ", " + t0 + ", " + timeConsta
nt + ")", | 63 message: "setTargetAtTime(" + vFinal + ", " + t0 + ", " + timeConsta
nt + ")", |
| 64 errorThreshold: 2.2599e-6 | 64 errorThreshold: 2.2599e-6 |
| 65 }; | 65 }; |
| 66 }).then(done); | 66 }).then(() => task.done()); |
| 67 }); | 67 }); |
| 68 | 68 |
| 69 audit.define("setValueCurve", (task, should) => { | 69 audit.define("setValueCurve", (task, should) => { |
| 70 // Test the value attribute from a setValueCurve event | 70 // Test the value attribute from a setValueCurve event |
| 71 runTest(should, function (g, v0, t0, v1, t1) { | 71 runTest(should, function (g, v0, t0, v1, t1) { |
| 72 var curve = [1, 1.5, 4]; | 72 var curve = [1, 1.5, 4]; |
| 73 var duration = t1 - t0; | 73 var duration = t1 - t0; |
| 74 g.gain.setValueCurveAtTime(Float32Array.from(curve), t0, duration); | 74 g.gain.setValueCurveAtTime(Float32Array.from(curve), t0, duration); |
| 75 return { | 75 return { |
| 76 expectedValue: function (testTime) { | 76 expectedValue: function (testTime) { |
| 77 return audioParamSetValueCurve(testTime, curve, t0, duration); | 77 return audioParamSetValueCurve(testTime, curve, t0, duration); |
| 78 }, | 78 }, |
| 79 message: "setValueCurveAtTime([" + curve + "], " + t0 + ", " + durat
ion + ")", | 79 message: "setValueCurveAtTime([" + curve + "], " + t0 + ", " + durat
ion + ")", |
| 80 errorThreshold: 7.9577e-8 | 80 errorThreshold: 7.9577e-8 |
| 81 }; | 81 }; |
| 82 }).then(done); | 82 }).then(() => task.done()); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 audit.run(); | 85 audit.run(); |
| 86 | 86 |
| 87 // Test that the .value getter has the correct value when a timeline is ru
nning. | 87 // Test that the .value getter has the correct value when a timeline is ru
nning. |
| 88 // The |testFunction| is the underlying test to be run. | 88 // The |testFunction| is the underlying test to be run. |
| 89 function runTest(should, testFunction) { | 89 function runTest(should, testFunction) { |
| 90 // Create a simple graph consisting of a constant source and a gain node
where the | 90 // Create a simple graph consisting of a constant source and a gain node
where the |
| 91 // automations are run. A setValueAtTime event starts things off. | 91 // automations are run. A setValueAtTime event starts things off. |
| 92 var context = new OfflineAudioContext(1, renderFrames, sampleRate); | 92 var context = new OfflineAudioContext(1, renderFrames, sampleRate); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return context.startRendering().then(function (resultBuffer) { | 154 return context.startRendering().then(function (resultBuffer) { |
| 155 // Just print a final pass (or fail) message. | 155 // Just print a final pass (or fail) message. |
| 156 should(success, "Gain .value attribute for " + test.message) | 156 should(success, "Gain .value attribute for " + test.message) |
| 157 .message("correctly updated during automation", | 157 .message("correctly updated during automation", |
| 158 "not correctly updated during automation; max error = " + m
axError); | 158 "not correctly updated during automation; max error = " + m
axError); |
| 159 }); | 159 }); |
| 160 } | 160 } |
| 161 </script> | 161 </script> |
| 162 </body> | 162 </body> |
| 163 </html> | 163 </html> |
| OLD | NEW |