retrospective-setValueCurveAtTime.html (2481B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Test SetValueCurve with start time in the past</title> 5 <script src=/resources/testharness.js></script> 6 <script src=/resources/testharnessreport.js></script> 7 <script src="/webaudio/resources/audit-util.js"></script> 8 <script src="/webaudio/resources/audit.js"></script> 9 <script src="retrospective-test.js"></script> 10 </head> 11 </body> 12 <script> 13 let audit = Audit.createTaskRunner(); 14 15 audit.define( 16 { 17 label: 'test', 18 description: 'Test SetValueCurve with start time in the past' 19 }, 20 (task, should) => { 21 let {context, source, test, reference} = setupRetrospectiveGraph(); 22 23 // Suspend the context at this frame so we can synchronously set up 24 // automations. 25 const suspendFrame = 128; 26 27 context.suspend(suspendFrame / context.sampleRate) 28 .then(() => { 29 // Call setValueAtTime with a time in the past 30 test.gain.setValueCurveAtTime( 31 new Float32Array([1.0, 0.1]), 0.5 * context.currentTime, 32 1.0); 33 reference.gain.setValueCurveAtTime( 34 new Float32Array([1.0, 0.1]), context.currentTime, 1.0); 35 }) 36 .then(() => context.resume()); 37 38 source.start(); 39 40 context.startRendering() 41 .then(resultBuffer => { 42 let testValue = resultBuffer.getChannelData(0); 43 let referenceValue = resultBuffer.getChannelData(1); 44 45 // Until the suspendFrame, both should be exactly equal to 1. 46 should( 47 testValue.slice(0, suspendFrame), 48 `Test[0:${suspendFrame - 1}]`) 49 .beConstantValueOf(1); 50 should( 51 referenceValue.slice(0, suspendFrame), 52 `Reference[0:${suspendFrame - 1}]`) 53 .beConstantValueOf(1); 54 55 // After the suspendFrame, both should be equal (and not 56 // constant) 57 should( 58 testValue.slice(suspendFrame), `Test[${suspendFrame}:]`) 59 .beEqualToArray(referenceValue.slice(suspendFrame)); 60 }) 61 .then(() => task.done()); 62 }); 63 64 audit.run(); 65 </script> 66 </body> 67 </html>