audioparam-setTargetAtTime.html (2227B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> 5 Test AudioParam.setTargetAtTime 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/webaudio/resources/audit-util.js"></script> 10 <script src="/webaudio/resources/audit.js"></script> 11 <script src="/webaudio/resources/audioparam-testing.js"></script> 12 </head> 13 <body> 14 <script id="layout-test-code"> 15 let audit = Audit.createTaskRunner(); 16 17 // Play a long DC signal out through an AudioGainNode, and call 18 // setValueAtTime() and setTargetAtTime at regular intervals to set the 19 // starting value and the target value. Each time interval has a ramp with 20 // a different starting and target value so that there is a discontinuity 21 // at each time interval boundary. The discontinuity is for testing 22 // timing. Also, we alternate between an increasing and decreasing ramp 23 // for each interval. 24 25 // Number of tests to run. 26 let numberOfTests = 100; 27 28 // Max allowed difference between the rendered data and the expected 29 // result. 30 let maxAllowedError = 6.5683e-4 31 32 // The AudioGainNode starts with this value instead of the default value. 33 let initialValue = 100; 34 35 // Set the gain node value to the specified value at the specified time. 36 function setValue(value, time) { 37 gainNode.gain.setValueAtTime(value, time); 38 } 39 40 // Generate an exponential approach starting at |startTime| with a target 41 // value of |value|. 42 function automation(value, startTime, endTime){ 43 // endTime is not used for setTargetAtTime. 44 gainNode.gain.setTargetAtTime(value, startTime, timeConstant)} 45 46 audit.define( 47 { 48 label: 'test', 49 description: 'AudioParam setTargetAtTime() functionality.' 50 }, 51 function(task, should) { 52 createAudioGraphAndTest( 53 task, should, numberOfTests, initialValue, setValue, automation, 54 'setTargetAtTime()', maxAllowedError, 55 createExponentialApproachArray); 56 }); 57 58 audit.run(); 59 </script> 60 </body> 61 </html>