WebProcessCache should keep track of processes being added
[WebKit-https.git] / LayoutTests / webaudio / mixing.html
1 <!DOCTYPE html>
2
3 <!--
4 Create two sources and play them simultaneously.  This tests unity-gain summing of AudioNode inputs.
5 The result should be some laughing playing at the same time as the drumming.
6 -->
7
8 <html>
9 <head>
10 <script type="text/javascript" src="resources/audio-testing.js"></script>
11 <script type="text/javascript" src="resources/buffer-loader.js"></script>
12
13 </head>
14 <body>
15
16 <script>
17
18 window.onload = init;
19
20 var sampleRate = 44100.0;
21 var lengthInSeconds = 2;
22
23 var context = 0;
24 var bufferLoader = 0;
25
26 function init() {
27     if (!window.testRunner)
28         return;
29         
30     // Create offline audio context.
31     context = new webkitOfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
32         
33     bufferLoader = new BufferLoader(
34         context,
35         [
36         "resources/hyper-reality/br-jam-loop.wav",
37         "resources/hyper-reality/laughter.wav",
38         ],
39         finishedLoading
40     );
41
42     bufferLoader.load();
43     testRunner.waitUntilDone();
44 }
45
46 function finishedLoading(bufferList) {
47     // Create two sources and play them at the same time.
48     var source1 = context.createBufferSource();
49     var source2 = context.createBufferSource();
50     source1.buffer = bufferList[0];
51     source2.buffer = bufferList[1];
52     
53     source1.connect(context.destination);
54     source2.connect(context.destination);
55     source1.start(0);
56     source2.start(0);
57     
58     context.oncomplete = finishAudioTest;
59     context.startRendering();    
60 }
61
62 </script>
63
64 </body>
65 </html>