diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/webaudio/test/test_audioParamChaining.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/webaudio/test/test_audioParamChaining.html')
-rw-r--r-- | dom/media/webaudio/test/test_audioParamChaining.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_audioParamChaining.html b/dom/media/webaudio/test/test_audioParamChaining.html new file mode 100644 index 000000000..6093e4425 --- /dev/null +++ b/dom/media/webaudio/test/test_audioParamChaining.html @@ -0,0 +1,77 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test whether we can create an AudioContext interface</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +SimpleTest.waitForExplicitFinish() + +function frameToTime(frame, rate) +{ + return frame / rate; +} + +const RATE = 44100; + +var oc = new OfflineAudioContext(1, 44100, RATE); +// This allows us to have a source that is simply a DC offset. +var source = oc.createBufferSource(); +var buf = oc.createBuffer(1, 1, RATE); +buf.getChannelData(0)[0] = 1; +source.loop = true; +source.buffer = buf; + +source.start(0); + +var gain = oc.createGain(); + +source.connect(gain).connect(oc.destination); + +var gain2 = oc.createGain(); +var rv2 = gain2.gain.linearRampToValueAtTime(0.1, 0.5); +ok(rv2 instanceof AudioParam, "linearRampToValueAtTime returns an AudioParam."); +ok(rv2 == gain2.gain, "linearRampToValueAtTime returns the right AudioParam."); + +rv2 = gain2.gain.exponentialRampToValueAtTime(0.01, 1.0); +ok(rv2 instanceof AudioParam, + "exponentialRampToValueAtTime returns an AudioParam."); +ok(rv2 == gain2.gain, + "exponentialRampToValueAtTime returns the right AudioParam."); + +rv2 = gain2.gain.setTargetAtTime(1.0, 2.0, 0.1); +ok(rv2 instanceof AudioParam, "setTargetAtTime returns an AudioParam."); +ok(rv2 == gain2.gain, "setTargetAtTime returns the right AudioParam."); + +var array = new Float32Array(10); +rv2 = gain2.gain.setValueCurveAtTime(array, 10, 11); +ok(rv2 instanceof AudioParam, "setValueCurveAtTime returns an AudioParam."); +ok(rv2 == gain2.gain, "setValueCurveAtTime returns the right AudioParam."); + +// We chain three automation methods, making a gain step. +var rv = gain.gain.setValueAtTime(0, frameToTime(0, RATE)) + .setValueAtTime(0.5, frameToTime(22000, RATE)) + .setValueAtTime(1, frameToTime(44000, RATE)); + +ok(rv instanceof AudioParam, "setValueAtTime returns an AudioParam."); +ok(rv == gain.gain, "setValueAtTime returns the right AudioParam."); + +oc.startRendering().then(function(rendered) { + console.log(rendered.getChannelData(0)); + is(rendered.getChannelData(0)[0], 0, + "The value of the first step is correct."); + is(rendered.getChannelData(0)[22050], 0.5, + "The value of the second step is correct"); + is(rendered.getChannelData(0)[44099], 1, + "The value of the third step is correct."); + SimpleTest.finish(); +}); + +</script> +</pre> +</body> +</html> |