1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<!doctype html>
<meta charset=utf-8>
<title>Test setTargetAtTime with start time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
var test = context.createGain();
test.gain.setTargetAtTime(0.1, 0.5*context.currentTime, 0.1);
test.gain.linearRampToValueAtTime(0.9, 2.0);
var reference = context.createGain();
reference.gain.setTargetAtTime(0.1, context.currentTime, 0.1);
reference.gain.linearRampToValueAtTime(0.9, 2.0);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>
|