summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/webaudio/delaynode-scheduling.html
blob: 3fdb85becaee91e4584d13236e9ead5fbf74f422 (plain)
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>

<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="resources/delay-testing.js"></script>
</head>

<body>

<div id="description"></div>
<div id="console"></div>

<script>
description("Tests that DelayNode delayTime parameter can be scheduled at a given time.");

function runTest() {
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
    
    window.jsTestIsAsync = true;
        
    // Create offline audio context.
    var context = new webkitOfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
    var toneBuffer = createToneBuffer(context, 20, 20 * toneLengthSeconds, sampleRate); // 20Hz tone
    
    var bufferSource = context.createBufferSource();
    bufferSource.buffer = toneBuffer;

    var delay = context.createDelayNode();
    
    // Schedule delay time at time zero.
    delay.delayTime.setValueAtTime(delayTimeSeconds, 0);

    bufferSource.connect(delay);
    delay.connect(context.destination);
    bufferSource.noteOn(0);
    
    context.oncomplete = checkDelayedResult(toneBuffer);
    context.startRendering();
}

runTest();

</script>

</body>
</html>