summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/specification.html
blob: 3178c5e10221a54b6000055d620274057ca8f26f (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Web Audio API</title>
  <meta name="revision"
  content="$Id: Overview.html,v 1.4 2012/07/30 11:44:57 tmichel Exp $" />
  <link rel="stylesheet" href="style.css" type="text/css" />
  <!--
          <script src="section-links.js" type="application/ecmascript"></script> 
          <script src="dfn.js" type="application/ecmascript"></script> 
          -->
  <!--[if IE]>
          <style type='text/css'>
            .ignore {
              -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
              filter: alpha(opacity=50);
            }
          </style>
          <![endif]-->
  <link rel="stylesheet" href="//www.w3.org/StyleSheets/TR/W3C-ED"
  type="text/css" />
</head>

<body>

<div class="head">
<p><a href="http://www.w3.org/"><img width="72" height="48" alt="W3C"
src="http://www.w3.org/Icons/w3c_home" /></a> </p>

<h1 id="title" class="title">Web Audio API </h1>

<h2 id="w3c-date-document"><acronym
title="World Wide Web Consortium">W3C</acronym> Editor's Draft
</h2>
<dl>
  <dt>This version: </dt>
    <dd><a
    href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html">https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html</a>
    </dd>
  <dt>Latest published version: </dt>
    <dd><a
      href="http://www.w3.org/TR/webaudio/">http://www.w3.org/TR/webaudio/</a>
    </dd>
  <dt>Previous version: </dt>
     <dd><a
      href="http://www.w3.org/TR/2012/WD-webaudio-20120315/">http://www.w3.org/TR/2012/WD-webaudio-20120315/</a>
    </dd>
</dl>

<dl>
  <dt>Editor: </dt>
    <dd>Chris Rogers, Google &lt;crogers@google.com&gt;</dd>
</dl>

<p class="copyright"><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2012 <a href="http://www.w3.org/"><acronym
title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym
title="Massachusetts Institute of Technology">MIT</acronym></a>, <a
href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<hr />
</div>

<div id="abstract-section" class="section">
<h2 id="abstract">Abstract</h2>

<p>This specification describes a high-level JavaScript <acronym
title="Application Programming Interface">API</acronym> for processing and
synthesizing audio in web applications. The primary paradigm is of an audio
routing graph, where a number of <a
href="#AudioNode-section"><code>AudioNode</code></a> objects are connected
together to define the overall audio rendering. The actual processing will
primarily take place in the underlying implementation (typically optimized
Assembly / C / C++ code), but <a href="#JavaScriptProcessing-section">direct
JavaScript processing and synthesis</a> is also supported. </p>

<p>The <a href="#introduction">introductory</a> section covers the motivation
behind this specification.</p>

<p>This API is designed to be used in conjunction with other APIs and elements
on the web platform, notably: XMLHttpRequest
(using the <code>responseType</code> and <code>response</code> attributes). For
games and interactive applications, it is anticipated to be used with the
<code>canvas</code> 2D and WebGL 3D graphics APIs. </p>
</div>

<div id="sotd-section" class="section">
<h2 id="sotd">Status of this Document</h2>


<p><em>This section describes the status of this document at the time of its
publication. Other documents may supersede this document. A list of current W3C
publications and the latest revision of this technical report can be found in
the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/. </em></p>

<p>This is the Editor's Draft of the <cite>Web Audio API</cite>
specification. It has been produced by the <a
href="http://www.w3.org/2011/audio/"><b>W3C Audio Working Group</b></a> , which
is part of the W3C WebApps Activity.</p>

<p></p>

<p>Please send comments about this document to &lt;<a
href="mailto:public-audio@w3.org">public-audio@w3.org</a>&gt; (<a
href="http://lists.w3.org/Archives/Public/public-audio/">public archives</a> of
the W3C audio mailing list). Web content and browser developers are encouraged
to review this draft. </p>

<p>Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or obsoleted
by other documents at any time. It is inappropriate to cite this document as
other than work in progress.</p>

<p> This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/46884/status">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
</div>

<div id="toc">
<h2 id="L13522">Table of Contents</h2>

<div class="toc">
<ul>
  <li><a href="#introduction">1. Introduction</a>
    <ul>
      <li><a href="#Features">1.1. Features</a></li>
      <li><a href="#ModularRouting">1.2. Modular Routing</a></li>
      <li><a href="#APIOverview">1.3. API Overview</a></li>
    </ul>
  </li>
  <li><a href="#conformance">2. Conformance</a></li>
  <li><a href="#API-section">4. The Audio API</a>
    <ul>
      <li><a href="#AudioContext-section">4.1. The AudioContext Interface</a> 
        <ul>
          <li><a href="#attributes-AudioContext">4.1.1. Attributes</a></li>
          <li><a href="#methodsandparams-AudioContext">4.1.2. Methods and
            Parameters</a></li>
          <li><a href="#lifetime-AudioContext">4.1.3. Lifetime</a></li>
        </ul>
      </li>
      <li><a href="#OfflineAudioContext-section">4.1b. The OfflineAudioContext Interface</a> 
      </li>

      <li><a href="#AudioNode-section">4.2. The AudioNode Interface</a> 
        <ul>
          <li><a href="#attributes-AudioNode">4.2.1. Attributes</a></li>
          <li><a href="#methodsandparams-AudioNode">4.2.2. Methods and
            Parameters</a></li>
          <li><a href="#lifetime-AudioNode">4.2.3. Lifetime</a></li>
        </ul>
      </li>
      <li><a href="#AudioDestinationNode">4.4. The AudioDestinationNode
        Interface</a> 
        <ul>
          <li><a href="#attributes-AudioDestinationNode">4.4.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#AudioParam">4.5. The AudioParam Interface</a> 
        <ul>
          <li><a href="#attributes-AudioParam">4.5.1. Attributes</a></li>
          <li><a href="#methodsandparams-AudioParam">4.5.2. Methods and
            Parameters</a></li>
          <li><a href="#computedValue-AudioParam-section">4.5.3. Computation of Value</a></li>
          <li><a href="#example1-AudioParam-section">4.5.4. AudioParam Automation Example</a></li>
        </ul>
      </li>
      <li><a href="#GainNode">4.7. The GainNode Interface</a> 
        <ul>
          <li><a href="#attributes-GainNode">4.7.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#DelayNode">4.8. The DelayNode Interface</a> 
        <ul>
          <li><a href="#attributes-GainNode_2">4.8.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#AudioBuffer">4.9. The AudioBuffer Interface</a> 
        <ul>
          <li><a href="#attributes-AudioBuffer">4.9.1. Attributes</a></li>
          <li><a href="#methodsandparams-AudioBuffer">4.9.2. Methods and
            Parameters</a></li>
        </ul>
      </li>
      <li><a href="#AudioBufferSourceNode">4.10. The AudioBufferSourceNode
        Interface</a> 
        <ul>
          <li><a href="#attributes-AudioBufferSourceNode">4.10.1.
          Attributes</a></li>
          <li><a href="#methodsandparams-AudioBufferSourceNode">4.10.2. Methods and
            Parameters</a></li>
        </ul>
      </li>
      <li><a href="#MediaElementAudioSourceNode">4.11. The
        MediaElementAudioSourceNode Interface</a></li>
      <li><a href="#ScriptProcessorNode">4.12. The ScriptProcessorNode
        Interface</a> 
        <ul>
          <li><a href="#attributes-ScriptProcessorNode">4.12.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#AudioProcessingEvent">4.13. The AudioProcessingEvent
        Interface</a> 
        <ul>
          <li><a href="#attributes-AudioProcessingEvent">4.13.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#PannerNode">4.14. The PannerNode Interface</a> 
        <ul>
          <li><a href="#attributes-PannerNode_attributes">4.14.2.
            Attributes</a></li>
          <li><a href="#Methods_and_Parameters">4.14.3. Methods and
          Parameters</a></li>
        </ul>
      </li>
      <li><a href="#AudioListener">4.15. The AudioListener Interface</a> 
        <ul>
          <li><a href="#attributes-AudioListener">4.15.1. Attributes</a></li>
          <li><a href="#L15842">4.15.2. Methods and Parameters</a></li>
        </ul>
      </li>
      <li><a href="#ConvolverNode">4.16. The ConvolverNode Interface</a> 
        <ul>
          <li><a href="#attributes-ConvolverNode">4.16.1. Attributes</a></li>
        </ul>
      </li>
      <li><a href="#AnalyserNode">4.17. The AnalyserNode
        Interface</a> 
        <ul>
          <li><a href="#attributes-ConvolverNode_2">4.17.1. Attributes</a></li>
          <li><a href="#methods-and-parameters">4.17.2. Methods and
          Parameters</a></li>
        </ul>
      </li>
      <li><a href="#ChannelSplitterNode">4.18. The ChannelSplitterNode
        Interface</a> 
        <ul>
          <li><a href="#example-1">Example:</a></li>
        </ul>
      </li>
      <li><a href="#ChannelMergerNode">4.19. The ChannelMergerNode Interface</a> 
        <ul>
          <li><a href="#example-2">Example:</a></li>
        </ul>
      </li>
      <li><a href="#DynamicsCompressorNode">4.20. The DynamicsCompressorNode
        Interface</a> 
        <ul>
          <li><a href="#attributes-DynamicsCompressorNode">4.20.1.
          Attributes</a></li>
        </ul>
      </li>
      <li><a href="#BiquadFilterNode">4.21. The BiquadFilterNode Interface</a> 
        <ul>
          <li><a href="#BiquadFilterNode-description">4.21.1 Lowpass</a></li>
          <li><a href="#HIGHPASS">4.21.2 Highpass</a></li>
          <li><a href="#BANDPASS">4.21.3 Bandpass</a></li>
          <li><a href="#LOWSHELF">4.21.4 Lowshelf</a></li>
          <li><a href="#L16352">4.21.5 Highshelf</a></li>
          <li><a href="#PEAKING">4.21.6 Peaking</a></li>
          <li><a href="#NOTCH">4.21.7 Notch</a></li>
          <li><a href="#ALLPASS">4.21.8 Allpass</a></li>
          <li><a href="#Methods">4.21.9. Methods</a></li>
        </ul>
      </li>
      <li><a href="#WaveShaperNode">4.22. The WaveShaperNode Interface</a> 
        <ul>
          <li><a href="#attributes-WaveShaperNode">4.22.1.
            Attributes</a></li>
        </ul>
      </li>
      <li><a href="#OscillatorNode">4.23. The OscillatorNode Interface</a> 
        <ul>
          <li><a href="#attributes-OscillatorNode">4.23.1.
            Attributes</a></li>
            <li><a href="#methodsandparams-OscillatorNode-section">4.23.2. Methods and
            Parameters</a></li>
        </ul>
      </li>
      <li><a href="#PeriodicWave">4.24. The PeriodicWave Interface</a> 
      </li>
      <li><a href="#MediaStreamAudioSourceNode">4.25. The
        MediaStreamAudioSourceNode Interface</a></li>
      <li><a href="#MediaStreamAudioDestinationNode">4.26. The
        MediaStreamAudioDestinationNode Interface</a></li>
    </ul>
  </li>
  <li><a href="#MixerGainStructure">6. Mixer Gain Structure</a> 
    <ul>
      <li><a href="#background">Background</a></li>
      <li><a href="#SummingJunction">Summing Inputs</a></li>
      <li><a href="#gain-Control">Gain Control</a></li>
      <li><a href="#Example-mixer-with-send-busses">Example: Mixer with Send
        Busses</a></li>
    </ul>
  </li>
  <li><a href="#DynamicLifetime">7. Dynamic Lifetime</a> 
    <ul>
      <li><a href="#DynamicLifetime-background">Background</a></li>
      <li><a href="#Example-DynamicLifetime">Example</a></li>
    </ul>
  </li>
  <li><a href="#UpMix">9. Channel up-mixing and down-mixing</a> 
    <ul>
      <li><a href="#ChannelLayouts">9.1. Speaker Channel Layouts</a>
      <ul>
        <li><a href="#ChannelOrdering">9.1.1. Channel Ordering</a></li>
        <li><a href="#UpMix-sub">9.1.2. Up Mixing</a></li>
        <li><a href="#down-mix">9.1.3. Down Mixing</a></li>
      </ul>
      </li>

      <li><a href="#ChannelRules-section">9.2. Channel Rules Examples</a>

    </ul>
  </li>
  <li><a href="#Spatialization">11. Spatialization / Panning </a> 
    <ul>
      <li><a href="#Spatialization-background">Background</a></li>
      <li><a href="#Spatialization-panning-algorithm">Panning Algorithm</a></li>
      <li><a href="#Spatialization-distance-effects">Distance Effects</a></li>
      <li><a href="#Spatialization-sound-cones">Sound Cones</a></li>
      <li><a href="#Spatialization-doppler-shift">Doppler Shift</a></li>
    </ul>
  </li>
  <li><a href="#Convolution">12. Linear Effects using Convolution</a> 
    <ul>
      <li><a href="#Convolution-background">Background</a></li>
      <li><a href="#Convolution-motivation">Motivation for use as a
      Standard</a></li>
      <li><a href="#Convolution-implementation-guide">Implementation Guide</a></li>
      <li><a href="#Convolution-reverb-effect">Reverb Effect (with
        matrixing)</a></li>
      <li><a href="#recording-impulse-responses">Recording Impulse
      Responses</a></li>
      <li><a href="#tools">Tools</a></li>
      <li><a href="#recording-setup">Recording Setup</a></li>
      <li><a href="#warehouse">The Warehouse Space</a></li>
    </ul>
  </li>
  <li><a href="#JavaScriptProcessing">13. JavaScript Synthesis and
    Processing</a> 
    <ul>
      <li><a href="#custom-DSP-effects">Custom DSP Effects</a></li>
      <li><a href="#educational-applications">Educational Applications</a></li>
      <li><a href="#javaScript-performance">JavaScript Performance</a></li>
    </ul>
  </li>
  <li><a href="#Performance">15. Performance Considerations</a> 
    <ul>
      <li><a href="#Latency">15.1. Latency: What it is and Why it's
        Important</a></li>
      <li><a href="#audio-glitching">15.2. Audio Glitching</a></li>
      <li><a href="#hardware-scalability">15.3. Hardware Scalability</a> 
        <ul>
          <li><a href="#CPU-monitoring">15.3.1. CPU monitoring</a></li>
          <li><a href="#Voice-dropping">15.3.2. Voice Dropping</a></li>
          <li><a href="#Simplification-of-Effects-Processing">15.3.3.
            Simplification of Effects Processing</a></li>
          <li><a href="#Sample-rate">15.3.4. Sample Rate</a></li>
          <li><a href="#pre-flighting">15.3.5. Pre-flighting</a></li>
          <li><a href="#Authoring-for-different-user-agents">15.3.6. Authoring
            for different user agents</a></li>
          <li><a href="#Scalability-of-Direct-JavaScript-Synthesis">15.3.7.
            Scalability of Direct JavaScript Synthesis / Processing</a></li>
        </ul>
      </li>
      <li><a href="#JavaScriptPerformance">15.4. JavaScript Issues with
        real-time Processing and Synthesis: </a></li>
    </ul>
  </li>
  <li><a href="#ExampleApplications">16. Example Applications</a> 
    <ul>
      <li><a href="#basic-sound-playback">Basic Sound Playback</a></li>
      <li><a href="#threeD-environmentse-and-games">3D Environments and
        Games</a></li>
      <li><a href="#musical-applications">Musical Applications</a></li>
      <li><a href="#music-visualizers">Music Visualizers</a></li>
      <li><a href="#educational-applications_2">Educational
      Applications</a></li>
      <li><a href="#artistic-audio-exploration">Artistic Audio
      Exploration</a></li>
    </ul>
  </li>
  <li><a href="#SecurityConsiderations">17. Security Considerations</a></li>
  <li><a href="#PrivacyConsiderations">18. Privacy Considerations</a></li>
  <li><a href="#requirements">19. Requirements and Use Cases</a></li>
  <li><a href="#OldNames">20. Old Names</a></li>
  <li><a href="#L17310">A.References</a> 
    <ul>
      <li><a href="#Normative-references">A.1 Normative references</a></li>
      <li><a href="#Informative-references">A.2 Informative references</a></li>
    </ul>
  </li>
  <li><a href="#L17335">B.Acknowledgements</a></li>
  <li><a href="#ChangeLog">C. Web Audio API Change Log</a></li>
</ul>
</div>
</div>

<div id="sections">

<div id="div-introduction" class="section">
<h2 id="introduction">1. Introduction</h2>

<p class="norm">This section is informative.</p>

<p>Audio on the web has been fairly primitive up to this point and until very
recently has had to be delivered through plugins such as Flash and QuickTime.
The introduction of the <code>audio</code> element in HTML5 is very important,
allowing for basic streaming audio playback. But, it is not powerful enough to
handle more complex audio applications. For sophisticated web-based games or
interactive applications, another solution is required. It is a goal of this
specification to include the capabilities found in modern game audio engines as
well as some of the mixing, processing, and filtering tasks that are found in
modern desktop audio production applications. </p>

<p>The APIs have been designed with a wide variety of <a
href="#ExampleApplications-section">use cases</a> in mind. Ideally, it should
be able to support <i>any</i> use case which could reasonably be implemented
with an optimized C++ engine controlled via JavaScript and run in a browser.
That said, modern desktop audio software can have very advanced capabilities,
some of which would be difficult or impossible to build with this system.
Apple's Logic Audio is one such application which has support for external MIDI
controllers, arbitrary plugin audio effects and synthesizers, highly optimized
direct-to-disk audio file reading/writing, tightly integrated time-stretching,
and so on. Nevertheless, the proposed system will be quite capable of
supporting a large range of reasonably complex games and interactive
applications, including musical ones. And it can be a very good complement to
the more advanced graphics features offered by WebGL. The API has been designed
so that more advanced capabilities can be added at a later time. </p>

<div id="Features-section" class="section">
<h2 id="Features">1.1. Features</h2>
</div>

<p>The API supports these primary features: </p>
<ul>
  <li><a href="#ModularRouting-section">Modular routing</a> for simple or
    complex mixing/effect architectures, including <a
    href="#MixerGainStructure-section">multiple sends and submixes</a>.</li>
  <li><a href="#AudioParam">Sample-accurate scheduled sound
    playback</a> with low <a href="#Latency-section">latency</a> for musical
    applications requiring a very high degree of rhythmic precision such as
    drum machines and sequencers. This also includes the possibility of <a
    href="#DynamicLifetime-section">dynamic creation</a> of effects. </li>
  <li>Automation of audio parameters for envelopes, fade-ins / fade-outs,
    granular effects, filter sweeps, LFOs etc. </li>
  <li>Flexible handling of channels in an audio stream, allowing them to be split and merged.</li>

  <li>Processing of audio sources from an <code>audio</code> or
    <code>video</code> <a href="#MediaElementAudioSourceNode">media
    element</a>. </li>
  
    <li>Processing live audio input using a <a href="#MediaStreamAudioSourceNode">MediaStream</a>
    from getUserMedia().  
     </li>
    
  <li>Integration with WebRTC  
  <ul>  
  

   <li>Processing audio received from a remote peer using a <a href="#MediaStreamAudioSourceNode">MediaStream</a>.
    </li>

  <li>Sending a generated or processed audio stream to a remote peer using a <a href="#MediaStreamAudioDestinationNode">MediaStream</a>.
     </li>

     </ul>
     </li>

  <li>Audio stream synthesis and processing <a
    href="#JavaScriptProcessing-section">directly in JavaScript</a>. </li>
  <li><a href="#Spatialization-section">Spatialized audio</a> supporting a wide
    range of 3D games and immersive environments: 
    <ul>
      <li>Panning models: equal-power, HRTF, pass-through </li>
      <li>Distance Attenuation </li>
      <li>Sound Cones </li>
      <li>Obstruction / Occlusion </li>
      <li>Doppler Shift </li>
      <li>Source / Listener based</li>
    </ul>
  </li>
  <li>A <a href="#Convolution-section">convolution engine</a> for a wide range
    of linear effects, especially very high-quality room effects. Here are some
    examples of possible effects: 
    <ul>
      <li>Small / large room </li>
      <li>Cathedral </li>
      <li>Concert hall </li>
      <li>Cave </li>
      <li>Tunnel </li>
      <li>Hallway </li>
      <li>Forest </li>
      <li>Amphitheater </li>
      <li>Sound of a distant room through a doorway </li>
      <li>Extreme filters</li>
      <li>Strange backwards effects</li>
      <li>Extreme comb filter effects </li>
    </ul>
  </li>
  <li>Dynamics compression for overall control and sweetening of the mix </li>
  <li>Efficient <a href="#AnalyserNode">real-time time-domain and
    frequency analysis / music visualizer support</a></li>
  <li>Efficient biquad filters for lowpass, highpass, and other common filters.
  </li>
  <li>A Waveshaping effect for distortion and other non-linear effects</li>
  <li>Oscillators</li>

</ul>

<div id="ModularRouting-section">
<h2 id="ModularRouting">1.2. Modular Routing</h2>

<p>Modular routing allows arbitrary connections between different <a
href="#AudioNode-section"><code>AudioNode</code></a> objects. Each node can
have <dfn>inputs</dfn> and/or <dfn>outputs</dfn>. A <dfn>source node</dfn> has no inputs
and a single output. A <dfn>destination node</dfn>  has
one input and no outputs, the most common example being <a
href="#AudioDestinationNode-section"><code>AudioDestinationNode</code></a> the final destination to the audio
hardware. Other nodes such as filters can be placed between the source and destination nodes.
The developer doesn't have to worry about low-level stream format details
when two objects are connected together; <a href="#UpMix-section">the right
thing just happens</a>. For example, if a mono audio stream is connected to a
stereo input it should just mix to left and right channels <a
href="#UpMix-section">appropriately</a>. </p>

<p>In the simplest case, a single source can be routed directly to the output.
All routing occurs within an <a
href="#AudioContext-section"><code>AudioContext</code></a> containing a single
<a href="#AudioDestinationNode-section"><code>AudioDestinationNode</code></a>:
</p>
<img alt="modular routing" src="images/modular-routing1.png" /> 

<p>Illustrating this simple routing, here's a simple example playing a single
sound: </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span> </div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 

var context = new AudioContext();

function playSound() {
    var source = context.createBufferSource();
    source.buffer = dogBarkingBuffer;
    source.connect(context.destination);
    source.start(0);
}
                    </code></pre>
</div>
</div>

<p>Here's a more complex example with three sources and a convolution reverb
send with a dynamics compressor at the final output stage: </p>
<img alt="modular routing2" src="images/modular-routing2.png" /> 

<div class="example">

<div class="exampleHeader">
Example</div>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span></div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 

var context = 0;
var compressor = 0;
var reverb = 0;

var source1 = 0;
var source2 = 0;
var source3 = 0;

var lowpassFilter = 0;
var waveShaper = 0;
var panner = 0;

var dry1 = 0;
var dry2 = 0;
var dry3 = 0;

var wet1 = 0;
var wet2 = 0;
var wet3 = 0;

var masterDry = 0;
var masterWet = 0;

function setupRoutingGraph () {
    context = new AudioContext();

    // Create the effects nodes.
    lowpassFilter = context.createBiquadFilter();
    waveShaper = context.createWaveShaper();
    panner = context.createPanner();
    compressor = context.createDynamicsCompressor();
    reverb = context.createConvolver();

    // Create master wet and dry.
    masterDry = context.createGain();
    masterWet = context.createGain();

    // Connect final compressor to final destination.
    compressor.connect(context.destination);

    // Connect master dry and wet to compressor.
    masterDry.connect(compressor);
    masterWet.connect(compressor);

    // Connect reverb to master wet.
    reverb.connect(masterWet);

    // Create a few sources.
    source1 = context.createBufferSource();
    source2 = context.createBufferSource();
    source3 = context.createOscillator();

    source1.buffer = manTalkingBuffer;
    source2.buffer = footstepsBuffer;
    source3.frequency.value = 440;

    // Connect source1
    dry1 = context.createGain();
    wet1 = context.createGain();
    source1.connect(lowpassFilter);
    lowpassFilter.connect(dry1);
    lowpassFilter.connect(wet1);
    dry1.connect(masterDry);
    wet1.connect(reverb);

    // Connect source2
    dry2 = context.createGain();
    wet2 = context.createGain();
    source2.connect(waveShaper);
    waveShaper.connect(dry2);
    waveShaper.connect(wet2);
    dry2.connect(masterDry);
    wet2.connect(reverb);

    // Connect source3
    dry3 = context.createGain();
    wet3 = context.createGain();
    source3.connect(panner);
    panner.connect(dry3);
    panner.connect(wet3);
    dry3.connect(masterDry);
    wet3.connect(reverb);
    
    // Start the sources now.
    source1.start(0);
    source2.start(0);
    source3.start(0);
}
 </code></pre>
</div>
</div>
</div>
</div>

</div>

<div id="APIOverview-section" class="section">
<h2 id="APIOverview">1.3. API Overview</h2>
</div>

<p>The interfaces defined are: </p>
<ul>
  <li>An <a class="dfnref" href="#AudioContext-section">AudioContext</a>
    interface, which contains an audio signal graph representing connections
    betweens AudioNodes. </li>
  <li>An <a class="dfnref" href="#AudioNode-section">AudioNode</a> interface,
    which represents audio sources, audio outputs, and intermediate processing
    modules. AudioNodes can be dynamically connected together in a <a
    href="#ModularRouting-section">modular fashion</a>. <code>AudioNodes</code>
    exist in the context of an <code>AudioContext</code> </li>
  <li>An <a class="dfnref"
    href="#AudioDestinationNode-section">AudioDestinationNode</a> interface, an
    AudioNode subclass representing the final destination for all rendered
    audio. </li>
  <li>An <a class="dfnref" href="#AudioBuffer-section">AudioBuffer</a>
    interface, for working with memory-resident audio assets. These can
    represent one-shot sounds, or longer audio clips. </li>
  <li>An <a class="dfnref"
    href="#AudioBufferSourceNode-section">AudioBufferSourceNode</a> interface,
    an AudioNode which generates audio from an AudioBuffer. </li>
  <li>A <a class="dfnref"
    href="#MediaElementAudioSourceNode-section">MediaElementAudioSourceNode</a>
    interface, an AudioNode which is the audio source from an
    <code>audio</code>, <code>video</code>, or other media element. </li>
  <li>A <a class="dfnref"
    href="#MediaStreamAudioSourceNode-section">MediaStreamAudioSourceNode</a>
    interface, an AudioNode which is the audio source from a
    MediaStream such as live audio input, or from a remote peer. </li>
  <li>A <a class="dfnref"
    href="#MediaStreamAudioDestinationNode-section">MediaStreamAudioDestinationNode</a>
    interface, an AudioNode which is the audio destination to a
    MediaStream sent to a remote peer. </li>
  <li>A <a class="dfnref"
    href="#ScriptProcessorNode-section">ScriptProcessorNode</a> interface, an
    AudioNode for generating or processing audio directly in JavaScript. </li>
  <li>An <a class="dfnref"
    href="#AudioProcessingEvent-section">AudioProcessingEvent</a> interface,
    which is an event type used with <code>ScriptProcessorNode</code> objects.
  </li>
  <li>An <a class="dfnref" href="#AudioParam-section">AudioParam</a> interface,
    for controlling an individual aspect of an AudioNode's functioning, such as
    volume. </li>
  <li>An <a class="dfnref" href="#GainNode-section">GainNode</a>
    interface, for explicit gain control. Because inputs to AudioNodes support
    multiple connections (as a unity-gain summing junction), mixers can be <a
    href="#MixerGainStructure-section">easily built</a> with GainNodes.
  </li>
  <li>A <a class="dfnref" href="#BiquadFilterNode-section">BiquadFilterNode</a>
    interface, an AudioNode for common low-order filters such as: 
    <ul>
      <li>Low Pass</li>
      <li>High Pass </li>
      <li>Band Pass </li>
      <li>Low Shelf </li>
      <li>High Shelf </li>
      <li>Peaking </li>
      <li>Notch </li>
      <li>Allpass </li>
    </ul>
  </li>
  <li>A <a class="dfnref" href="#DelayNode-section">DelayNode</a> interface, an
    AudioNode which applies a dynamically adjustable variable delay. </li>
  <li>An <a class="dfnref" href="#PannerNode-section">PannerNode</a>
    interface, for spatializing / positioning audio in 3D space. </li>
  <li>An <a class="dfnref" href="#AudioListener-section">AudioListener</a>
    interface, which works with an <code>PannerNode</code> for
    spatialization. </li>
  <li>A <a class="dfnref" href="#ConvolverNode-section">ConvolverNode</a>
    interface, an AudioNode for applying a <a
    href="#Convolution-section">real-time linear effect</a> (such as the sound
    of a concert hall). </li>
  <li>A <a class="dfnref"
    href="#AnalyserNode-section">AnalyserNode</a> interface,
    for use with music visualizers, or other visualization applications. </li>
  <li>A <a class="dfnref"
    href="#ChannelSplitterNode-section">ChannelSplitterNode</a> interface,
    for accessing the individual channels of an audio stream in the routing
    graph. </li>
  <li>A <a class="dfnref"
    href="#ChannelMergerNode-section">ChannelMergerNode</a> interface, for
    combining channels from multiple audio streams into a single audio stream.
  </li>
  <li>A <a
    href="#DynamicsCompressorNode-section">DynamicsCompressorNode</a> interface, an 
    AudioNode for dynamics compression. </li>
  <li>A <a class="dfnref" href="#dfn-WaveShaperNode">WaveShaperNode</a>
    interface, an AudioNode which applies a non-linear waveshaping effect for
    distortion and other more subtle warming effects. </li>
  <li>A <a class="dfnref" href="#dfn-OscillatorNode">OscillatorNode</a>
    interface, an audio source generating a periodic waveform. </li>
</ul>
</div>

<div id="conformance-section" class="section">
<h2 id="conformance">2. Conformance</h2>

<p>Everything in this specification is normative except for examples and
sections marked as being informative. </p>

<p>The keywords “<span class="rfc2119">MUST</span>”, “<span
class="rfc2119">MUST NOT</span>”, “<span
class="rfc2119">REQUIRED</span>”, “<span class="rfc2119">SHALL</span>”,
“<span class="rfc2119">SHALL NOT</span>”, “<span
class="rfc2119">RECOMMENDED</span>”, “<span class="rfc2119">MAY</span>”
and “<span class="rfc2119">OPTIONAL</span>” in this document are to be
interpreted as described in <cite><a href="http://www.ietf.org/rfc/rfc2119">Key
words for use in RFCs to Indicate Requirement Levels</a></cite> <a
href="#RFC2119">[RFC2119]</a>. </p>

<p>The following conformance classes are defined by this specification: </p>
<dl>
  <dt><dfn id="dfn-conforming-implementation">conforming
  implementation</dfn></dt>
    <dd><p>A user agent is considered to be a <a class="dfnref"
      href="#dfn-conforming-implementation">conforming implementation</a> if it
      satisfies all of the <span class="rfc2119">MUST</span>-, <span
      class="rfc2119">REQUIRED</span>- and <span
      class="rfc2119">SHALL</span>-level criteria in this specification that
      apply to implementations. </p>
    </dd>
</dl>
</div>

<div id="terminology-section" class="section">

<div id="API-section-section" class="section">
<h2 id="API-section">4. The Audio API</h2>
</div>

<div id="AudioContext-section-section" class="section">
<h2 id="AudioContext-section">4.1. The AudioContext Interface</h2>

<p>This interface represents a set of <a
href="#AudioNode-section"><code>AudioNode</code></a> objects and their
connections. It allows for arbitrary routing of signals to the <a
href="#AudioDestinationNode-section"><code>AudioDestinationNode</code></a>
(what the user ultimately hears). Nodes are created from the context and are
then <a href="#ModularRouting-section">connected</a> together. In most use
cases, only a single AudioContext is used per document.</p>

<br>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-context-idl">

callback DecodeSuccessCallback = void (AudioBuffer decodedData);
callback DecodeErrorCallback = void ();

[Constructor]
interface <dfn id="dfn-AudioContext">AudioContext</dfn> : EventTarget {

    readonly attribute AudioDestinationNode destination;
    readonly attribute float sampleRate;
    readonly attribute double currentTime;
    readonly attribute AudioListener listener;

    AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);

    void decodeAudioData(ArrayBuffer audioData,
                         DecodeSuccessCallback successCallback,
                         optional DecodeErrorCallback errorCallback);


    <span class="comment">// AudioNode creation </span>
    AudioBufferSourceNode createBufferSource();

    MediaElementAudioSourceNode createMediaElementSource(HTMLMediaElement mediaElement);

    MediaStreamAudioSourceNode createMediaStreamSource(MediaStream mediaStream);
    MediaStreamAudioDestinationNode createMediaStreamDestination();

    ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
                                              optional unsigned long numberOfInputChannels = 2,
                                              optional unsigned long numberOfOutputChannels = 2);

    AnalyserNode createAnalyser();
    GainNode createGain();
    DelayNode createDelay(optional double maxDelayTime = 1.0);
    BiquadFilterNode createBiquadFilter();
    WaveShaperNode createWaveShaper();
    PannerNode createPanner();
    ConvolverNode createConvolver();

    ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
    ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);

    DynamicsCompressorNode createDynamicsCompressor();

    OscillatorNode createOscillator();
    PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag);

};
</code></pre>
</div>
</div>

<div id="attributes-AudioContext-section" class="section">
<h3 id="attributes-AudioContext">4.1.1. Attributes</h3>
<dl>
  <dt id="dfn-destination"><code>destination</code></dt>
    <dd><p>An <a
      href="#AudioDestinationNode-section"><code>AudioDestinationNode</code></a>
      with a single input representing the final destination for all audio.
      Usually this will represent the actual audio hardware.
      All AudioNodes actively rendering
      audio will directly or indirectly connect to <code>destination</code>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-sampleRate"><code>sampleRate</code></dt>
    <dd><p>The sample rate (in sample-frames per second) at which the
      AudioContext handles audio. It is assumed that all AudioNodes in the
      context run at this rate. In making this assumption, sample-rate
      converters or "varispeed" processors are not supported in real-time
      processing.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-currentTime"><code>currentTime</code></dt>
    <dd><p>This is a time in seconds which starts at zero when the context is
      created and increases in real-time. All scheduled times are relative to
      it. This is not a "transport" time which can be started, paused, and
      re-positioned. It is always moving forward. A GarageBand-like timeline
      transport system can be very easily built on top of this (in JavaScript).
      This time corresponds to an ever-increasing hardware timestamp. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-listener"><code>listener</code></dt>
    <dd><p>An <a href="#AudioListener-section"><code>AudioListener</code></a>
      which is used for 3D <a
      href="#Spatialization-section">spatialization</a>.</p>
    </dd>
</dl>
</div>

<div id="methodsandparams-AudioContext-section" class="section">
<h3 id="methodsandparams-AudioContext">4.1.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-createBuffer">The <code>createBuffer</code> method</dt>
    <dd><p>Creates an AudioBuffer of the given size. The audio data in the
      buffer will be zero-initialized (silent).  An NOT_SUPPORTED_ERR exception will be thrown if
      the <code>numberOfChannels</code> or <code>sampleRate</code> are out-of-bounds,
      or if length is 0.</p>
      <p>The <dfn id="dfn-numberOfChannels">numberOfChannels</dfn> parameter
      determines how many channels the buffer will have.  An implementation must support at least 32 channels. </p>
      <p>The <dfn id="dfn-length">length</dfn> parameter determines the size of
      the buffer in sample-frames. </p>
      <p>The <dfn id="dfn-sampleRate_2">sampleRate</dfn> parameter describes
      the sample-rate of the linear PCM audio data in the buffer in
      sample-frames per second.  An implementation must support sample-rates in at least the range 22050 to 96000.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-decodeAudioData">The <code>decodeAudioData</code> method</dt>
    <dd><p>Asynchronously decodes the audio file data contained in the
      ArrayBuffer. The ArrayBuffer can, for example, be loaded from an XMLHttpRequest's
      <code>response</code> attribute after setting the <code>responseType</code> to "arraybuffer".
       Audio file data can be in any of the
      formats supported by the <code>audio</code> element. </p>
      <p><dfn id="dfn-audioData">audioData</dfn> is an ArrayBuffer containing
      audio file data.</p>
      <p><dfn id="dfn-successCallback">successCallback</dfn> is a callback
      function which will be invoked when the decoding is finished. The single
      argument to this callback is an AudioBuffer representing the decoded PCM
      audio data.</p>
      <p><dfn id="dfn-errorCallback">errorCallback</dfn> is a callback function
      which will be invoked if there is an error decoding the audio file
      data.</p>
      
      <p>
      The following steps must be performed:
      </p>
      <ol>
      
      <li>Temporarily neuter the <dfn>audioData</dfn> ArrayBuffer in such a way that JavaScript code may not
      access or modify the data.</li>
      <li>Queue a decoding operation to be performed on another thread.</li>
      <li>The decoding thread will attempt to decode the encoded <dfn>audioData</dfn> into linear PCM.
      If a decoding error is encountered due to the audio format not being recognized or supported, or
      because of corrupted/unexpected/inconsistent data then the <dfn>audioData</dfn> neutered state
      will be restored to normal and the <dfn>errorCallback</dfn> will be
      scheduled to run on the main thread's event loop and these steps will be terminated.</li>
      <li>The decoding thread will take the result, representing the decoded linear PCM audio data,
      and resample it to the sample-rate of the AudioContext if it is different from the sample-rate
      of <dfn>audioData</dfn>.  The final result (after possibly sample-rate converting) will be stored
      in an AudioBuffer.
      </li>
      <li>The <dfn>audioData</dfn> neutered state will be restored to normal
      </li>
      <li>
      The <dfn>successCallback</dfn> function will be scheduled to run on the main thread's event loop
      given the AudioBuffer from step (4) as an argument.
      </li>
      </ol>
    </dd>
</dl>
<dl>
  <dt id="dfn-createBufferSource">The <code>createBufferSource</code>
  method</dt>
    <dd><p>Creates an <a
      href="#AudioBufferSourceNode-section"><code>AudioBufferSourceNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createMediaElementSource">The <code>createMediaElementSource</code>
  method</dt>
    <dd><p>Creates a <a
      href="#MediaElementAudioSourceNode-section"><code>MediaElementAudioSourceNode</code></a> given an HTMLMediaElement.
      As a consequence of calling this method, audio playback from the HTMLMediaElement will be re-routed
      into the processing graph of the AudioContext.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createMediaStreamSource">The <code>createMediaStreamSource</code>
  method</dt>
    <dd><p>Creates a <a
      href="#MediaStreamAudioSourceNode-section"><code>MediaStreamAudioSourceNode</code></a> given a MediaStream.
      As a consequence of calling this method, audio playback from the MediaStream will be re-routed
      into the processing graph of the AudioContext.</p>
    </dd>
</dl>

<dl>
  <dt id="dfn-createMediaStreamDestination">The <code>createMediaStreamDestination</code>
  method</dt>
    <dd><p>Creates a <a
      href="#MediaStreamAudioDestinationNode-section"><code>MediaStreamAudioDestinationNode</code></a>.
      </p>
    </dd>
</dl>

<dl>
  <dt id="dfn-createScriptProcessor">The <code>createScriptProcessor</code>
  method</dt>
    <dd><p>Creates a <a
      href="#ScriptProcessorNode"><code>ScriptProcessorNode</code></a> for
      direct audio processing using JavaScript.  An INDEX_SIZE_ERR exception MUST be thrown if <code>bufferSize</code> or <code>numberOfInputChannels</code> or <code>numberOfOutputChannels</code>
      are outside the valid range. </p>
      <p>The <dfn id="dfn-bufferSize">bufferSize</dfn> parameter determines the
      buffer size in units of sample-frames.  If it's not passed in, or if the
      value is 0, then the implementation will choose the best buffer size for
      the given environment, which will be constant power of 2 throughout the lifetime
      of the node. Otherwise if the author explicitly specifies the bufferSize,
      it must be one of the following values: 256, 512, 1024, 2048, 4096, 8192,
      16384. This value controls how
      frequently the <code>audioprocess</code> event is dispatched and
      how many sample-frames need to be processed each call. Lower values for
      <code>bufferSize</code> will result in a lower (better) <a
      href="#Latency-section">latency</a>. Higher values will be necessary to
      avoid audio breakup and <a href="#Glitching-section">glitches</a>.
      It is recommended for authors to not specify this buffer size and allow
      the implementation to pick a good buffer size to balance between latency
      and audio quality.
      </p>
      <p>The <dfn id="dfn-numberOfInputChannels">numberOfInputChannels</dfn> parameter (defaults to 2) and
      determines the number of channels for this node's input.  Values of up to 32 must be supported. </p>
      <p>The <dfn id="dfn-numberOfOutputChannels">numberOfOutputChannels</dfn> parameter (defaults to 2) and
      determines the number of channels for this node's output.  Values of up to 32 must be supported.</p>
      <p>It is invalid for both <code>numberOfInputChannels</code> and
      <code>numberOfOutputChannels</code> to be zero. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createAnalyser">The <code>createAnalyser</code> method</dt>
    <dd><p>Creates a <a
      href="#AnalyserNode-section"><code>AnalyserNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createGain">The <code>createGain</code> method</dt>
    <dd><p>Creates a <a
      href="#GainNode-section"><code>GainNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createDelay">The <code>createDelay</code> method</dt>
    <dd><p>Creates a <a href="#DelayNode-section"><code>DelayNode</code></a>
      representing a variable delay line. The initial default delay time will
      be 0 seconds.</p>
      <p>The <dfn id="dfn-maxDelayTime">maxDelayTime</dfn> parameter is
      optional and specifies the maximum delay time in seconds allowed for the delay line.  If specified, this value MUST be
      greater than zero and less than three minutes or a NOT_SUPPORTED_ERR exception will be thrown.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createBiquadFilter">The <code>createBiquadFilter</code>
  method</dt>
    <dd><p>Creates a <a
      href="#BiquadFilterNode-section"><code>BiquadFilterNode</code></a>
      representing a second order filter which can be configured as one of
      several common filter types.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createWaveShaper">The <code>createWaveShaper</code>
  method</dt>
    <dd><p>Creates a <a
      href="#WaveShaperNode-section"><code>WaveShaperNode</code></a>
      representing a non-linear distortion.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createPanner">The <code>createPanner</code> method</dt>
    <dd><p>Creates an <a
      href="#PannerNode-section"><code>PannerNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createConvolver">The <code>createConvolver</code> method</dt>
    <dd><p>Creates a <a
      href="#ConvolverNode-section"><code>ConvolverNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createChannelSplitter">The <code>createChannelSplitter</code>
  method</dt>
    <dd><p>Creates an <a
      href="#ChannelSplitterNode-section"><code>ChannelSplitterNode</code></a>
      representing a channel splitter.  An exception will be thrown for invalid parameter values.</p>
      <p>The <dfn id="dfn-numberOfOutputs">numberOfOutputs</dfn> parameter
      determines the number of outputs.  Values of up to 32 must be supported.  If not specified, then 6 will be used. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createChannelMerger">The <code>createChannelMerger</code>
  method</dt>
    <dd><p>Creates an <a
      href="#ChannelMergerNode-section"><code>ChannelMergerNode</code></a>
      representing a channel merger.  An exception will be thrown for invalid parameter values.</p>
      <p>The <dfn id="dfn-numberOfInputs">numberOfInputs</dfn> parameter
      determines the number of inputs.  Values of up to 32 must be supported.  If not specified, then 6 will be used. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createDynamicsCompressor">The
  <code>createDynamicsCompressor</code> method</dt>
    <dd><p>Creates a <a
      href="#DynamicsCompressorNode-section"><code>DynamicsCompressorNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createOscillator">The
  <code>createOscillator</code> method</dt>
    <dd><p>Creates an <a
      href="#OscillatorNode-section"><code>OscillatorNode</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-createPeriodicWave">The
  <code>createPeriodicWave</code> method</dt>
    <dd><p>Creates a <a
      href="#PeriodicWave-section"><code>PeriodicWave</code></a> representing a waveform containing arbitrary harmonic content.
      The <code>real</code> and <code>imag</code> parameters must be of type <code>Float32Array</code> of equal
      lengths greater than zero and less than or equal to 4096 or an exception will be thrown.
      These parameters specify the Fourier coefficients of a
      <a href="http://en.wikipedia.org/wiki/Fourier_series">Fourier series</a> representing the partials of a periodic waveform.
      The created PeriodicWave will be used with an <a href="#OscillatorNode-section"><code>OscillatorNode</code></a>
      and will represent a <em>normalized</em> time-domain waveform having maximum absolute peak value of 1.
      Another way of saying this is that the generated waveform of an <a href="#OscillatorNode-section"><code>OscillatorNode</code></a>
      will have maximum peak value at 0dBFS. Conveniently, this corresponds to the full-range of the signal values used by the Web Audio API.
      Because the PeriodicWave will be normalized on creation, the <code>real</code> and <code>imag</code> parameters
      represent <em>relative</em> values.
      </p>
      <p>The <dfn id="dfn-real">real</dfn> parameter represents an array of <code>cosine</code> terms (traditionally the A terms).
      In audio terminology, the first element (index 0) is the DC-offset of the periodic waveform and is usually set to zero.
      The second element (index 1) represents the fundamental frequency.  The third element represents the first overtone, and so on.</p>
      <p>The <dfn id="dfn-imag">imag</dfn> parameter represents an array of <code>sine</code> terms (traditionally the B terms).
      The first element (index 0) should be set to zero (and will be ignored) since this term does not exist in the Fourier series.
      The second element (index 1) represents the fundamental frequency.  The third element represents the first overtone, and so on.</p>
    </dd>
</dl>
</div>
</div>

<h3 id="lifetime-AudioContext">4.1.3. Lifetime</h3>
<p class="norm">This section is informative.</p>

<p>
Once created, an <code>AudioContext</code> will continue to play sound until it has no more sound to play, or
the page goes away.
</p>

<div id="OfflineAudioContext-section-section" class="section">
<h2 id="OfflineAudioContext-section">4.1b. The OfflineAudioContext Interface</h2>
<p>
OfflineAudioContext is a particular type of AudioContext for rendering/mixing-down (potentially) faster than real-time.
It does not render to the audio hardware, but instead renders as quickly as possible, calling a completion event handler
with the result provided as an AudioBuffer.
</p>


<p>
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="offline-audio-context-idl">
[Constructor(unsigned long numberOfChannels, unsigned long length, float sampleRate)]
interface <dfn id="dfn-OfflineAudioContext">OfflineAudioContext</dfn> : AudioContext {

    void startRendering();
    
    attribute EventHandler oncomplete;

};
</code></pre>
</div>
</div>


<div id="attributes-OfflineAudioContext-section" class="section">
<h3 id="attributes-OfflineAudioContext">4.1b.1. Attributes</h3>
<dl>
  <dt id="dfn-oncomplete"><code>oncomplete</code></dt>
    <dd><p>An EventHandler of type <a href="#OfflineAudioCompletionEvent-section">OfflineAudioCompletionEvent</a>.</p>
    </dd>
</dl>
</div>


<div id="methodsandparams-OfflineAudioContext-section" class="section">
<h3 id="methodsandparams-OfflineAudioContext">4.1b.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-startRendering">The <code>startRendering</code>
  method</dt>
    <dd><p>Given the current connections and scheduled changes, starts rendering audio.  The
    <code>oncomplete</code> handler will be called once the rendering has finished.
    This method must only be called one time or an exception will be thrown.</p>
    </dd>
</dl>
</div>


<div id="OfflineAudioCompletionEvent-section" class="section">
<h2 id="OfflineAudioCompletionEvent">4.1c. The OfflineAudioCompletionEvent Interface</h2>

<p>This is an <code>Event</code> object which is dispatched to <a
href="#OfflineAudioContext-section"><code>OfflineAudioContext</code></a>. </p>


<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="offline-audio-completion-event-idl">

interface <dfn id="dfn-OfflineAudioCompletionEvent">OfflineAudioCompletionEvent</dfn> : Event {

    readonly attribute AudioBuffer renderedBuffer;

};
</code></pre>
</div>
</div>

<div id="attributes-OfflineAudioCompletionEvent-section" class="section">
<h3 id="attributes-OfflineAudioCompletionEvent">4.1c.1. Attributes</h3>
<dl>
  <dt id="dfn-renderedBuffer"><code>renderedBuffer</code></dt>
    <dd><p>An AudioBuffer containing the rendered audio data once an OfflineAudioContext has finished rendering.
    It will have a number of channels equal to the <code>numberOfChannels</code> parameter
    of the OfflineAudioContext constructor.</p>
    </dd>
</dl>
</div>
</div>


<div id="AudioNode-section-section" class="section">
<h2 id="AudioNode-section">4.2. The AudioNode Interface</h2>

<p>AudioNodes are the building blocks of an <a
href="#AudioContext-section"><code>AudioContext</code></a>. This interface
represents audio sources, the audio destination, and intermediate processing
modules. These modules can be connected together to form <a
href="#ModularRouting-section">processing graphs</a> for rendering audio to the
audio hardware. Each node can have <dfn>inputs</dfn> and/or <dfn>outputs</dfn>.
A <dfn>source node</dfn> has no inputs
and a single output. An <a
href="#AudioDestinationNode-section"><code>AudioDestinationNode</code></a> has
one input and no outputs and represents the final destination to the audio
hardware. Most processing nodes such as filters will have one input and one
output.  Each type of <code>AudioNode</code> differs in the details of how it processes or synthesizes audio.  But, in general, <code>AudioNodes</code>
will process its inputs (if it has any), and generate audio for its outputs (if it has any).
 </p>
 
<p>
Each <dfn>output</dfn> has one or more <dfn>channels</dfn>.  The exact number of channels depends on the details of the specific AudioNode.
</p>

<p>
An output may connect to one or more <code>AudioNode</code> inputs, thus <em>fan-out</em> is supported.  An input initially has no connections,
but may be connected from one
or more <code>AudioNode</code> outputs, thus <em>fan-in</em> is supported.  When the <code>connect()</code> method is called to connect
an output of an AudioNode to an input of an AudioNode, we call that a <dfn>connection</dfn> to the input.
</p>

<p>
Each AudioNode <dfn>input</dfn> has a specific number of channels at any given time.  This number can change depending on the <dfn>connection(s)</dfn>
made to the input.  If the input has no connections then it has one channel which is silent.
</p>

<p>
For each <dfn>input</dfn>, an <code>AudioNode</code> performs a mixing (usually an up-mixing) of all connections to that input.

Please see <a href="#MixerGainStructure-section">Mixer Gain Structure</a> for more informative details, and the <a href="#UpMix-section">Channel up-mixing and down-mixing</a>
  section for normative requirements.

</p>

<p>
For performance reasons, practical implementations will need to use block processing, with each <code>AudioNode</code> processing a
fixed number of sample-frames of size <em>block-size</em>.  In order to get uniform behavior across implementations, we will define this
value explicitly.  <em>block-size</em> is defined to be 128 sample-frames which corresponds to roughly 3ms at a sample-rate of 44.1KHz.
</p>

<p>
AudioNodes are <em>EventTarget</em>s, as described in <cite><a href="http://dom.spec.whatwg.org/">DOM</a></cite>
<a href="#DOM">[DOM]</a>.  This means that it is possible to dispatch events to AudioNodes the same
way that other EventTargets accept events.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-node-idl">

enum <dfn>ChannelCountMode</dfn> {
    "max",
    "clamped-max",
    "explicit"
};

enum <dfn>ChannelInterpretation</dfn> {
    "speakers",
    "discrete"
};

interface <dfn id="dfn-AudioNode">AudioNode</dfn> : EventTarget {

    void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
    void connect(AudioParam destination, optional unsigned long output = 0);
    void disconnect(optional unsigned long output = 0);

    readonly attribute AudioContext context;
    readonly attribute unsigned long numberOfInputs;
    readonly attribute unsigned long numberOfOutputs;

    // Channel up-mixing and down-mixing rules for all inputs.
    attribute unsigned long channelCount;
    attribute ChannelCountMode channelCountMode;
    attribute ChannelInterpretation channelInterpretation;

};
</code></pre>
</div>
</div>

<div id="attributes-AudioNode-section" class="section">
<h3 id="attributes-AudioNode">4.2.1. Attributes</h3>
<dl>
  <dt id="dfn-context"><code>context</code></dt>
    <dd><p>The AudioContext which owns this AudioNode.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-numberOfInputs_2"><code>numberOfInputs</code></dt>
    <dd><p>The number of inputs feeding into the AudioNode. For <dfn>source nodes</dfn>,
    this will be 0.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-numberOfOutputs_2"><code>numberOfOutputs</code></dt>
    <dd><p>The number of outputs coming out of the AudioNode. This will be 0
      for an AudioDestinationNode.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-channelCount"><code>channelCount</code><dt>
    <dd><p>The number of channels used when up-mixing and down-mixing connections to any inputs to the node.  The default value is 2
       except for specific nodes where its value is specially determined.
       This attribute has no effect for nodes with no inputs.
       If this value is set to zero, the implementation MUST raise the
       NOT_SUPPORTED_ERR exception.</p>
      <p>See the <a href="#UpMix-section">Channel up-mixing and down-mixing</a>
        section for more information on this attribute.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-channelCountMode"><code>channelCountMode</code><dt>
    <dd><p>Determines how channels will be counted when up-mixing and down-mixing connections to any inputs to the node
      .  This attribute has no effect for nodes with no inputs.</p>
      <p>See the <a href="#UpMix-section">Channel up-mixing and down-mixing</a>
        section for more information on this attribute.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-channelInterpretation"><code>channelInterpretation</code><dt>
    <dd><p>Determines how individual channels will be treated when up-mixing and down-mixing connections to any inputs to the node.
    This attribute has no effect for nodes with no inputs.</p>
      <p>See the <a href="#UpMix-section">Channel up-mixing and down-mixing</a>
        section for more information on this attribute.</p>
    </dd>
</dl>
</div>

<div id="methodsandparams-AudioNode-section" class="section">
<h3 id="methodsandparams-AudioNode">4.2.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-connect-AudioNode">The <code>connect</code> to AudioNode method</dt>
    <dd><p>Connects the AudioNode to another AudioNode.</p>
      <p>The <dfn id="dfn-destination_2">destination</dfn> parameter is the
      AudioNode to connect to.</p>
      <p>The <dfn id="dfn-output_2">output</dfn> parameter is an index
      describing which output of the AudioNode from which to connect. An
      out-of-bound value throws an exception.</p>
      <p>The <dfn id="dfn-input_2">input</dfn> parameter is an index describing
      which input of the destination AudioNode to connect to. An out-of-bound
      value throws an exception. </p>
      <p>It is possible to connect an AudioNode output to more than one input
      with multiple calls to connect(). Thus, "fan-out" is supported. </p>
      <p>
      It is possible to connect an AudioNode to another AudioNode which creates a <em>cycle</em>.
      In other words, an AudioNode may connect to another AudioNode, which in turn connects back
      to the first AudioNode.  This is allowed only if there is at least one
      <a class="dfnref" href="#DelayNode-section">DelayNode</a> in the <em>cycle</em> or an exception will
      be thrown.
      </p>
      
      <p>
      There can only be one connection between a given output of one specific node and a given input of another specific node.
      Multiple connections with the same termini are ignored.  For example: 
      </p>

      <pre>
      nodeA.connect(nodeB);
      nodeA.connect(nodeB);

      will have the same effect as

      nodeA.connect(nodeB);
      </pre>
      
    </dd>
</dl>
<dl>
  <dt id="dfn-connect-AudioParam">The <code>connect</code> to AudioParam method</dt>
    <dd><p>Connects the AudioNode to an AudioParam, controlling the parameter
      value with an audio-rate signal.
      </p>

      <p>The <dfn id="dfn-destination_3">destination</dfn> parameter is the
      AudioParam to connect to.</p>
      <p>The <dfn id="dfn-output_3-destination">output</dfn> parameter is an index
      describing which output of the AudioNode from which to connect. An
      out-of-bound value throws an exception.</p>      

      <p>It is possible to connect an AudioNode output to more than one AudioParam
      with multiple calls to connect(). Thus, "fan-out" is supported. </p>
      <p>It is possible to connect more than one AudioNode output to a single AudioParam
      with multiple calls to connect().  Thus, "fan-in" is supported. </p>
      <p>An AudioParam will take the rendered audio data from any AudioNode output connected to it and <a href="#down-mix">convert it to mono</a> by down-mixing if it is not
      already mono, then mix it together with other such outputs and finally will mix with the <em>intrinsic</em>
      parameter value (the value the AudioParam would normally have without any audio connections), including any timeline changes
      scheduled for the parameter. </p>

      <p>
      There can only be one connection between a given output of one specific node and a specific AudioParam.
      Multiple connections with the same termini are ignored.  For example: 
      </p>

      <pre>
      nodeA.connect(param);
      nodeA.connect(param);

      will have the same effect as

      nodeA.connect(param);
      </pre>

    </dd>
</dl>
<dl>
  <dt id="dfn-disconnect">The <code>disconnect</code> method</dt>
    <dd><p>Disconnects an AudioNode's output.</p>
      <p>The <dfn id="dfn-output_3-disconnect">output</dfn> parameter is an index
      describing which output of the AudioNode to disconnect.  An out-of-bound
      value throws an exception.</p>
    </dd>
</dl>
</div>
</div>

<h3 id="lifetime-AudioNode">4.2.3. Lifetime</h3>

<p class="norm">This section is informative.</p>

<p>An implementation may choose any method to avoid unnecessary resource usage and unbounded memory growth of unused/finished
nodes.  The following is a description to help guide the general expectation of how node lifetime would be managed.
</p>

<p>
An <code>AudioNode</code> will live as long as there are any references to it.  There are several types of references:
</p>

<ol>
<li>A <em>normal</em> JavaScript reference obeying normal garbage collection rules. </li>
<li>A <em>playing</em> reference for both <code>AudioBufferSourceNodes</code> and <code>OscillatorNodes</code>.
These nodes maintain a <em>playing</em>
reference to themselves while they are currently playing.</li>
<li>A <em>connection</em> reference which occurs if another <code>AudioNode</code> is connected to it.   </li>
<li>A <em>tail-time</em> reference which an <code>AudioNode</code> maintains on itself as long as it has
any internal processing state which has not yet been emitted.  For example, a <code>ConvolverNode</code> has
a tail which continues to play even after receiving silent input (think about clapping your hands in a large concert
  hall and continuing to hear the sound reverberate throughout the hall).  Some <code>AudioNodes</code> have this
  property.  Please see details for specific nodes.</li>
</ol>

<p>
Any <code>AudioNodes</code> which are connected in a cycle <em>and</em> are directly or indirectly connected to the
<code>AudioDestinationNode</code> of the <code>AudioContext</code> will stay alive as long as the <code>AudioContext</code> is alive.
</p>

<p>
When an <code>AudioNode</code> has no references it will be deleted.  But before it is deleted, it will disconnect itself
from any other <code>AudioNodes</code> which it is connected to.  In this way it releases all connection references (3) it has to other nodes.
</p>

<p>
Regardless of any of the above references, it can be assumed that the <code>AudioNode</code> will be deleted when its <code>AudioContext</code> is deleted.
</p>


<div id="AudioDestinationNode-section" class="section">
<h2 id="AudioDestinationNode">4.4. The AudioDestinationNode Interface</h2>

<p>This is an <a href="#AudioNode-section"><code>AudioNode</code></a>
representing the final audio destination and is what the user will ultimately
hear. It can often be considered as an audio output device which is connected to
speakers. All rendered audio to be heard will be routed to this node, a
"terminal" node in the AudioContext's routing graph. There is only a single
AudioDestinationNode per AudioContext, provided through the
<code>destination</code> attribute of <a
href="#AudioContext-section"><code>AudioContext</code></a>. </p>
<pre>
      numberOfInputs  : 1
      numberOfOutputs : 0

      channelCount = 2;
      channelCountMode = "explicit";
      channelInterpretation = "speakers";
</pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-destination-node-idl">

interface <dfn id="dfn-AudioDestinationNode">AudioDestinationNode</dfn> : AudioNode {

    readonly attribute unsigned long maxChannelCount;

};
</code></pre>
</div>
</div>

<div id="attributes-AudioDestinationNode-section" class="section">
<h3 id="attributes-AudioDestinationNode">4.4.1. Attributes</h3>
<dl>
  <dt id="dfn-maxChannelCount"><code>maxChannelCount</code></dt>
    <dd><p>The maximum number of channels that the <code>channelCount</code> attribute can be set to.
    An <code>AudioDestinationNode</code> representing the audio hardware end-point (the normal case) can potentially output more than
    2 channels of audio if the audio hardware is multi-channel.  <code>maxChannelCount</code> is the maximum number of channels that
    this hardware is capable of supporting.  If this value is 0, then this indicates that <code>channelCount</code> may not be
    changed.  This will be the case for an <code>AudioDestinationNode</code> in an <code>OfflineAudioContext</code> and also for
    basic implementations with hardware support for stereo output only.</p>

    <p><code>channelCount</code> defaults to 2 for a destination in a normal AudioContext, and may be set to any non-zero value less than or equal
    to <code>maxChannelCount</code>.  An exception will be thrown if this value is not within the valid range.  Giving a concrete example, if
    the audio hardware supports 8-channel output, then we may set <code>numberOfChannels</code> to 8, and render 8-channels of output.
    </p>
    
    <p>
    For an AudioDestinationNode in an OfflineAudioContext, the <code>channelCount</code> is determined when the offline context is created and this value
    may not be changed.
    </p>
    
    </dd>
</dl>

</div>
</div>

<div id="AudioParam-section" class="section">
<h2 id="AudioParam">4.5. The AudioParam Interface</h2>

<p>AudioParam controls an individual aspect of an <a
href="#AudioNode-section"><code>AudioNode</code></a>'s functioning, such as
volume. The parameter can be set immediately to a particular value using the
"value" attribute. Or, value changes can be scheduled to happen at
very precise times (in the coordinate system of AudioContext.currentTime), for envelopes, volume fades, LFOs, filter sweeps, grain
windows, etc. In this way, arbitrary timeline-based automation curves can be
set on any AudioParam.  Additionally, audio signals from the outputs of <code>AudioNodes</code> can be connected
to an <code>AudioParam</code>, summing with the <em>intrinsic</em> parameter value.
</p>

<p>
Some synthesis and processing <code>AudioNodes</code> have <code>AudioParams</code> as attributes whose values must
 be taken into account on a per-audio-sample basis.
For other <code>AudioParams</code>, sample-accuracy is not important and the value changes can be sampled more coarsely.
Each individual <code>AudioParam</code> will specify that it is either an <em>a-rate</em> parameter
which means that its values must be taken into account on a per-audio-sample basis, or it is a <em>k-rate</em> parameter.  
</p>

<p>
Implementations must use block processing, with each <code>AudioNode</code>
processing 128 sample-frames in each block.
</p>

<p>
For each 128 sample-frame block, the value of a <em>k-rate</em> parameter must
be sampled at the time of the very first sample-frame, and that value must be
used for the entire block.  <em>a-rate</em> parameters must be sampled for each
sample-frame of the block.
</p>


<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-param-idl">

interface <dfn id="dfn-AudioParam">AudioParam</dfn> {

    attribute float value;
    readonly attribute float defaultValue;

    <span class="comment">// Parameter automation. </span>
    void setValueAtTime(float value, double startTime);
    void linearRampToValueAtTime(float value, double endTime);
    void exponentialRampToValueAtTime(float value, double endTime);

    <span class="comment">// Exponentially approach the target value with a rate having the given time constant. </span>
    void setTargetAtTime(float target, double startTime, double timeConstant);

    <span class="comment">// Sets an array of arbitrary parameter values starting at time for the given duration. </span>
    <span class="comment">// The number of values will be scaled to fit into the desired duration. </span>
    void setValueCurveAtTime(Float32Array values, double startTime, double duration);

    <span class="comment">// Cancels all scheduled parameter changes with times greater than or equal to startTime. </span>
    void cancelScheduledValues(double startTime);

};
</code></pre>
</div>
</div>



<div id="attributes-AudioParam-section" class="section">
<h3 id="attributes-AudioParam">4.5.1. Attributes</h3>

<dl>
  <dt id="dfn-value"><code>value</code></dt>
    <dd><p>The parameter's floating-point value.  This attribute is initialized to the
      <code>defaultValue</code>.  If a value is set during a time when there are any automation events scheduled then
      it will be ignored and no exception will be thrown.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-defaultValue"><code>defaultValue</code></dt>
    <dd><p>Initial value for the value attribute</p>
    </dd>
</dl>
</div>

<div id="methodsandparams-AudioParam-section" class="section">
<h3 id="methodsandparams-AudioParam">4.5.2. Methods and Parameters</h3>

<p>
An <code>AudioParam</code> maintains a time-ordered event list which is initially empty.  The times are in
the time coordinate system of AudioContext.currentTime.  The events define a mapping from time to value.  The following methods
can change the event list by adding a new event into the list of a type specific to the method.  Each event
has a time associated with it, and the events will always be kept in time-order in the list.  These
methods will be called <em>automation</em> methods:</p>

<ul>
<li>setValueAtTime() - <em>SetValue</em></li>
<li>linearRampToValueAtTime() - <em>LinearRampToValue</em></li>
<li>exponentialRampToValueAtTime() - <em>ExponentialRampToValue</em></li>
<li>setTargetAtTime() - <em>SetTarget</em></li>
<li>setValueCurveAtTime() - <em>SetValueCurve</em></li>
</ul>

<p>
The following rules will apply when calling these methods:
</p>
<ul>
<li>If one of these events is added at a time where there is already an event of the exact same type, then the new event will replace the old
one.</li>
<li>If one of these events is added at a time where there is already one or more events of a different type, then it will be
placed in the list after them, but before events whose times are after the event. </li>
<li>If setValueCurveAtTime() is called for time T and duration D and there are any events having a time greater than T, but less than
T + D, then an exception will be thrown.  In other words, it's not ok to schedule a value curve during a time period containing other events.</li>
<li>Similarly an exception will be thrown if any <em>automation</em> method is called at a time which is inside of the time interval
of a <em>SetValueCurve</em> event at time T and duration D.</li>
</ul>
<p>
</p>

<dl>
  <dt id="dfn-setValueAtTime">The <code>setValueAtTime</code> method</dt>
    <dd><p>Schedules a parameter value change at the given time.</p>
      <p>The <dfn id="dfn-value_2">value</dfn> parameter is the value the
      parameter will change to at the given time.</p>
      <p>The <dfn id="dfn-startTime_2">startTime</dfn> parameter is the time in the same time coordinate system as AudioContext.currentTime.</p>
      <p>
      If there are no more events after this <em>SetValue</em> event, then for t >= startTime,  v(t) = value.  In other words, the value will remain constant.
      </p>
      <p>
      If the next event (having time T1) after this <em>SetValue</em> event is not of type <em>LinearRampToValue</em> or <em>ExponentialRampToValue</em>,
      then, for t: startTime &lt;= t &lt; T1,  v(t) = value.
      In other words, the value will remain constant during this time interval, allowing the creation of "step" functions.
      </p>
      <p>
      If the next event after this <em>SetValue</em> event is of type <em>LinearRampToValue</em> or <em>ExponentialRampToValue</em> then please
      see details below.
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-linearRampToValueAtTime">The <code>linearRampToValueAtTime</code>
  method</dt>
    <dd><p>Schedules a linear continuous change in parameter value from the
      previous scheduled parameter value to the given value.</p>
      <p>The <dfn id="dfn-value_3">value</dfn> parameter is the value the
      parameter will linearly ramp to at the given time.</p>
      <p>The <dfn id="dfn-endTime_3">endTime</dfn> parameter is the time in the same time coordinate system as AudioContext.currentTime.</p>

      <p>
      The value during the time interval T0 &lt;= t &lt; T1 (where T0 is the time of the previous event and T1 is the endTime parameter passed into this method)
      will be calculated as:
      </p>
      <pre>
      v(t) = V0 + (V1 - V0) * ((t - T0) / (T1 - T0))
      </pre>
      <p>
      Where V0 is the value at the time T0 and V1 is the value parameter passed into this method.
      </p>
      <p>
      If there are no more events after this LinearRampToValue event then for t >= T1, v(t) = V1
      </p>

    </dd>
</dl>
<dl>
  <dt id="dfn-exponentialRampToValueAtTime">The
  <code>exponentialRampToValueAtTime</code> method</dt>
    <dd><p>Schedules an exponential continuous change in parameter value from
      the previous scheduled parameter value to the given value. Parameters
      representing filter frequencies and playback rate are best changed
      exponentially because of the way humans perceive sound. </p>
      <p>The <dfn id="dfn-value_4">value</dfn> parameter is the value the
      parameter will exponentially ramp to at the given time.  An exception will be thrown if this value is less than
      or equal to 0, or if the value at the time of the previous event is less than or equal to 0.</p>
      <p>The <dfn id="dfn-endTime_4">endTime</dfn> parameter is the time in the same time coordinate system as AudioContext.currentTime.</p>
      <p>
      The value during the time interval T0 &lt;= t &lt; T1 (where T0 is the time of the previous event and T1 is the endTime parameter passed into this method)
      will be calculated as:
      </p>
      <pre>
      v(t) = V0 * (V1 / V0) ^ ((t - T0) / (T1 - T0))
      </pre>
      <p>
      Where V0 is the value at the time T0 and V1 is the value parameter passed into this method.
      </p>
      <p>
      If there are no more events after this ExponentialRampToValue event then for t >= T1, v(t) = V1
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setTargetAtTime">The <code>setTargetAtTime</code>
  method</dt>
    <dd><p>Start exponentially approaching the target value at the given time
      with a rate having the given time constant. Among other uses, this is
      useful for implementing the "decay" and "release" portions of an ADSR
      envelope. Please note that the parameter value does not immediately
      change to the target value at the given time, but instead gradually
      changes to the target value.</p>
      <p>The <dfn id="dfn-target">target</dfn> parameter is the value
      the parameter will <em>start</em> changing to at the given time.</p>
      <p>The <dfn id="dfn-startTime">startTime</dfn> parameter is the time in the same time coordinate system as AudioContext.currentTime.</p>
      <p>The <dfn id="dfn-timeConstant">timeConstant</dfn> parameter is the
      time-constant value of first-order filter (exponential) approach to the
      target value. The larger this value is, the slower the transition will
      be.</p>
      <p>
      More precisely, <em>timeConstant</em> is the time it takes a first-order linear continuous time-invariant system
      to reach the value 1 - 1/e (around 63.2%) given a step input response (transition from 0 to 1 value).
      </p>
      <p>
      During the time interval: <em>T0</em> &lt;= t &lt; <em>T1</em>, where T0 is the <em>startTime</em> parameter and T1 represents the time of the event following this
      event (or <em>infinity</em> if there are no following events):
      </p>
      <pre>
      v(t) = V1 + (V0 - V1) * exp(-(t - T0) / <em>timeConstant</em>)
      </pre>
      <p>
      Where V0 is the initial value (the .value attribute) at T0 (the <em>startTime</em> parameter) and V1 is equal to the <em>target</em>
      parameter.
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setValueCurveAtTime">The <code>setValueCurveAtTime</code>
  method</dt>
    <dd><p>Sets an array of arbitrary parameter values starting at the given
      time for the given duration. The number of values will be scaled to fit
      into the desired duration. </p>
      <p>The <dfn id="dfn-values">values</dfn> parameter is a Float32Array
      representing a parameter value curve. These values will apply starting at
      the given time and lasting for the given duration. </p>
      <p>The <dfn id="dfn-startTime_5">startTime</dfn> parameter is the time in the same time coordinate system as AudioContext.currentTime.</p>
      <p>The <dfn id="dfn-duration_5">duration</dfn> parameter is the
      amount of time in seconds (after the <em>time</em> parameter) where values will be calculated according to the <em>values</em> parameter..</p>
      <p>
      During the time interval: <em>startTime</em> &lt;= t &lt; <em>startTime</em> + <em>duration</em>, values will be calculated:
      </p>
      <pre>
      v(t) = values[N * (t - startTime) / duration], where <em>N</em> is the length of the <em>values</em> array.
      </pre>
      <p>
      After the end of the curve time interval (t >= <em>startTime</em> + <em>duration</em>), the value will remain constant at the final curve value,
      until there is another automation event (if any).
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-cancelScheduledValues">The <code>cancelScheduledValues</code>
  method</dt>
    <dd><p>Cancels all scheduled parameter changes with times greater than or
      equal to startTime.</p>
      <p>The <dfn>startTime</dfn> parameter is the starting
      time at and after which any previously scheduled parameter changes will
      be cancelled.  It is a time in the same time coordinate system as AudioContext.currentTime.</p>
    </dd>
</dl>
</div>
</div>



<div id="computedValue-AudioParam-section" class="section">
<h3>4.5.3. Computation of Value</h3>

<p>
<dfn>computedValue</dfn> is the final value controlling the audio DSP and is computed by the audio rendering thread during each rendering time quantum.
  It must be internally computed as follows:
</p>

<ol>
<li>An <em>intrinsic</em> parameter value will be calculated at each time, which is either the value set directly to the .value attribute,
or, if there are any scheduled parameter changes (automation events) with times before or at this time,
the value as calculated from these events.  If the .value attribute
is set after any automation events have been scheduled, then these events will be removed.  When read, the .value attribute
always returns the <em>intrinsic</em> value for the current time.  If automation events are removed from a given time range, then the
<em>intrinsic</em> value will remain unchanged and stay at its previous value until either the .value attribute is directly set, or automation events are added
for the time range.
</li>

<li>
An AudioParam will take the rendered audio data from any AudioNode output connected to it and <a href="#down-mix">convert it to mono</a> by down-mixing if it is not
already mono, then mix it together with other such outputs.  If there are no AudioNodes connected to it, then this value is 0, having no
effect on the <em>computedValue</em>.
</li>

<li>
The <em>computedValue</em> is the sum of the <em>intrinsic</em> value and the value calculated from (2).
</li>

</ol>

</div>


<div id="example1-AudioParam-section" class="section">
<h3 id="example1-AudioParam">4.5.4. AudioParam Automation Example</h3>



<div class="example">

<div class="exampleHeader">
Example</div>
<img alt="AudioParam automation" src="images/audioparam-automation1.png" /> 

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span></div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 
var t0 = 0;
var t1 = 0.1;
var t2 = 0.2;
var t3 = 0.3;
var t4 = 0.4;
var t5 = 0.6;
var t6 = 0.7;
var t7 = 1.0;

var curveLength = 44100;
var curve = new Float32Array(curveLength);
for (var i = 0; i &lt; curveLength; ++i)
    curve[i] = Math.sin(Math.PI * i / curveLength);

param.setValueAtTime(0.2, t0);
param.setValueAtTime(0.3, t1);
param.setValueAtTime(0.4, t2);
param.linearRampToValueAtTime(1, t3);
param.linearRampToValueAtTime(0.15, t4);
param.exponentialRampToValueAtTime(0.75, t5);
param.exponentialRampToValueAtTime(0.05, t6);
param.setValueCurveAtTime(curve, t6, t7 - t6);
</code></pre>
</div>
</div>
</div>
</div>

<div id="GainNode-section" class="section">
<h2 id="GainNode">4.7. The GainNode Interface</h2>

<p>Changing the gain of an audio signal is a fundamental operation in audio
applications.  The <code>GainNode</code> is one of the building blocks for creating <a
href="#MixerGainStructure-section">mixers</a>.
This interface is an AudioNode with a single input and single
output: </p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>

<p>It multiplies the input audio signal by the (possibly time-varying) <code>gain</code> attribute, copying the result to the output.
 By default, it will take the input and pass it through to the output unchanged, which represents a constant gain change
 of 1. 
</p>

<p>
As with other <code>AudioParams</code>, the <code>gain</code> parameter represents a mapping from time
(in the coordinate system of AudioContext.currentTime) to floating-point value.

Every PCM audio sample in the input is multiplied by the <code>gain</code> parameter's value for the specific time
corresponding to that audio sample.  This multiplied value represents the PCM audio sample for the output.
</p>

<p>
The number of channels of the output will always equal the number of channels of the input, with each channel
of the input being multiplied by the <code>gain</code> values and being copied into the corresponding channel
of the output.
</p>

<p>
 The implementation must make
gain changes to the audio stream smoothly, without introducing noticeable
clicks or glitches. This process is called "de-zippering". </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="gain-node-idl">

interface <dfn id="dfn-GainNode">GainNode</dfn> : AudioNode {

    readonly attribute AudioParam gain;

};
</code></pre>
</div>
</div>

<div id="attributes-GainNode-section" class="section">
<h3 id="attributes-GainNode">4.7.1. Attributes</h3>
<dl>
  <dt id="dfn-gain"><code>gain</code></dt>
    <dd><p>Represents the amount of gain to apply. Its
      default <code>value</code> is 1 (no gain change). The nominal <code>minValue</code> is 0, but may be
      set negative for phase inversion.  The nominal <code>maxValue</code> is 1, but higher values are allowed (no
      exception thrown).This parameter is <em>a-rate</em> </p>
    </dd>
</dl>
</div>
</div>

<div id="DelayNode-section" class="section">
<h2 id="DelayNode">4.8. The DelayNode Interface</h2>

<p>A delay-line is a fundamental building block in audio applications. This
interface is an AudioNode with a single input and single output: </p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>

<p>
The number of channels of the output always equals the number of channels of the input.
</p>

<p>It delays the incoming audio signal by a certain amount. The default
amount is 0 seconds (no delay). When the delay time is changed, the
implementation must make the transition smoothly, without introducing
noticeable clicks or glitches to the audio stream. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="delay-node-idl">

interface <dfn id="dfn-DelayNode">DelayNode</dfn> : AudioNode {

    readonly attribute AudioParam delayTime;

};
</code></pre>
</div>
</div>

<div id="attributes-GainNode-section_2" class="section">
<h3 id="attributes-GainNode_2">4.8.1. Attributes</h3>
<dl>
  <dt id="dfn-delayTime_2"><code>delayTime</code></dt>
    <dd><p>An AudioParam object representing the amount of delay (in seconds)
      to apply. The default value (<code>delayTime.value</code>) is 0 (no
      delay). The minimum value is 0 and the maximum value is determined by the <em>maxDelayTime</em>
      argument to the <code>AudioContext</code> method <code>createDelay</code>.  This parameter is <em>a-rate</em></p>
    </dd>
</dl>
</div>
</div>

<div id="AudioBuffer-section" class="section">
<h2 id="AudioBuffer">4.9. The AudioBuffer Interface</h2>

<p>This interface represents a memory-resident audio asset (for one-shot sounds
and other short audio clips). Its format is non-interleaved IEEE 32-bit linear PCM with a
nominal range of -1 -&gt; +1. It can contain one or more channels.  Typically, it would be expected that the length
of the PCM data would be fairly short (usually somewhat less than a minute).
For longer sounds, such as music soundtracks, streaming should be used with the
<code>audio</code> element and <code>MediaElementAudioSourceNode</code>. </p>

<p>
An AudioBuffer may be used by one or more AudioContexts.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-buffer-idl">

interface <dfn id="dfn-AudioBuffer">AudioBuffer</dfn> {

    readonly attribute float sampleRate;
    readonly attribute long length;

    <span class="comment">// in seconds </span>
    readonly attribute double duration;

    readonly attribute long numberOfChannels;

    Float32Array getChannelData(unsigned long channel);

};
</code></pre>
</div>
</div>

<div id="attributes-AudioBuffer-section" class="section">
<h3 id="attributes-AudioBuffer">4.9.1. Attributes</h3>
<dl>
  <dt id="dfn-sampleRate_AudioBuffer"><code>sampleRate</code></dt>
    <dd><p>The sample-rate for the PCM audio data in samples per second.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-length_AudioBuffer"><code>length</code></dt>
    <dd><p>Length of the PCM audio data in sample-frames.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-duration_AudioBuffer"><code>duration</code></dt>
    <dd><p>Duration of the PCM audio data in seconds.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-numberOfChannels_AudioBuffer"><code>numberOfChannels</code></dt>
    <dd><p>The number of discrete audio channels.</p>
    </dd>
</dl>
</div>

<div id="methodsandparams-AudioBuffer-section" class="section">
<h3 id="methodsandparams-AudioBuffer">4.9.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-getChannelData">The <code>getChannelData</code> method</dt>
    <dd><p>Returns the <code>Float32Array</code> representing the PCM audio data for the specific channel.</p>
      <p>The <dfn id="dfn-channel">channel</dfn> parameter is an index
      representing the particular channel to get data for.  An index value of 0 represents
      the first channel.  This  index value MUST be less than <code>numberOfChannels</code>
      or an exception will be thrown.</p>
    </dd>
</dl>
</div>
</div>

<div id="AudioBufferSourceNode-section" class="section">
<h2 id="AudioBufferSourceNode">4.10. The AudioBufferSourceNode Interface</h2>

<p>This interface represents an audio source from an in-memory audio asset in
an <code>AudioBuffer</code>. It is useful for playing short audio assets
which require a high degree of scheduling flexibility (can playback in
rhythmically perfect ways). The start() method is used to schedule when 
sound playback will happen.  The playback will stop automatically when
the buffer's audio data has been completely
played (if the <code>loop</code> attribute is false), or when the stop()
method has been called and the specified time has been reached. Please see more
details in the start() and stop() description.  start() and stop() may not be issued
multiple times for a given
AudioBufferSourceNode. </p>
<pre>    numberOfInputs  : 0
    numberOfOutputs : 1
    </pre>

<p>
The number of channels of the output always equals the number of channels of the AudioBuffer
assigned to the .buffer attribute, or is one channel of silence if .buffer is NULL.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-buffer-source-node-idl">

interface <dfn id="dfn-AudioBufferSourceNode">AudioBufferSourceNode</dfn> : AudioNode {

    attribute AudioBuffer? buffer;

    readonly attribute AudioParam playbackRate;

    attribute boolean loop;
    attribute double loopStart;
    attribute double loopEnd;

    void start(optional double when = 0, optional double offset = 0, optional double duration);
    void stop(optional double when = 0);

    attribute EventHandler onended;

};
</code></pre>
</div>
</div>

<div id="attributes-AudioBufferSourceNode-section" class="section">
<h3 id="attributes-AudioBufferSourceNode">4.10.1. Attributes</h3>
<dl>
  <dt id="dfn-buffer_AudioBufferSourceNode"><code>buffer</code></dt>
    <dd><p>Represents the audio asset to be played. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-playbackRate_AudioBufferSourceNode"><code>playbackRate</code></dt>
    <dd><p>The speed at which to render the audio stream. The default
      playbackRate.value is 1.  This parameter is <em>a-rate</em> </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-loop_AudioBufferSourceNode"><code>loop</code></dt>
    <dd><p>Indicates if the audio data should play in a loop.  The default value is false. </p>
    </dd>
</dl>

<dl>
  <dt id="dfn-loopStart_AudioBufferSourceNode"><code>loopStart</code></dt>
    <dd><p>An optional value in seconds where looping should begin if the <code>loop</code> attribute is true.
    Its default value is 0, and it may usefully be set to any value between 0 and the duration of the buffer.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-loopEnd_AudioBufferSourceNode"><code>loopEnd</code></dt>
    <dd><p>An optional value in seconds where looping should end if the <code>loop</code> attribute is true.
    Its default value is 0, and it may usefully be set to any value between 0 and the duration of the buffer.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-onended_AudioBufferSourceNode"><code>onended</code></dt>
    <dd><p>A property used to set the <code>EventHandler</code> (described in <cite><a
      href="http://www.whatwg.org/specs/web-apps/current-work/#eventhandler">HTML</a></cite>)
      for the ended event that is dispatched to <a
      href="#AudioBufferSourceNode-section"><code>AudioBufferSourceNode</code></a>
      node types.  When the playback of the buffer for an <code>AudioBufferSourceNode</code>
      is finished, an event of type <code>Event</code> (described in <cite><a
      href="http://www.whatwg.org/specs/web-apps/current-work/#event">HTML</a></cite>)
      will be dispatched to the event handler. </p>
    </dd>
</dl>


</div>
</div>

<div id="methodsandparams-AudioBufferSourceNode-section" class="section">
<h3 id="methodsandparams-AudioBufferSourceNode">4.10.2. Methods and
Parameters</h3>
<dl>
  <dt id="dfn-start">The <code>start</code> method</dt>
    <dd><p>Schedules a sound to playback at an exact time.</p>
      <p>The <dfn id="dfn-when">when</dfn> parameter describes at what time (in
      seconds) the sound should start playing. It is in the same
      time coordinate system as AudioContext.currentTime. If 0 is passed in for
      this value or if the value is less than <b>currentTime</b>, then the
      sound will start playing immediately.  <code>start</code> may only be called one time
      and must be called before <code>stop</code> is called or an exception will be thrown.</p>
      <p>The <dfn id="dfn-offset">offset</dfn> parameter describes
      the offset time in the buffer (in seconds) where playback will begin. If 0 is passed
      in for this value, then playback will start from the beginning of the buffer.</p>
      <p>The <dfn id="dfn-duration">duration</dfn> parameter
      describes the duration of the portion (in seconds) to be played.  If this parameter is not passed,
      the duration will be equal to the total duration of the AudioBuffer minus the <code>offset</code> parameter.
      Thus if neither <code>offset</code> nor <code>duration</code> are specified then the implied duration is
      the total duration of the AudioBuffer.
      </p>

    </dd>
</dl>
<dl>
  <dt id="dfn-stop">The <code>stop</code> method</dt>
    <dd><p>Schedules a sound to stop playback at an exact time.</p>
      <p>The <dfn id="dfn-when_AudioBufferSourceNode_2">when</dfn> parameter
      describes at what time (in seconds) the sound should stop playing.
      It is in the same time coordinate system as AudioContext.currentTime.
      If 0 is passed in for this value or if the value is less than
      <b>currentTime</b>, then the sound will stop playing immediately.
      <code>stop</code> must only be called one time and only after a call to <code>start</code> or <code>stop</code>,
      or an exception will be thrown.</p>
    </dd>
</dl>
</div>

<div id="looping-AudioBufferSourceNode-section" class="section">
<h3 id="looping-AudioBufferSourceNode">4.10.3. Looping</h3>
<p>
If the <code>loop</code> attribute is true when <code>start()</code> is called, then playback will continue indefinitely
until <code>stop()</code> is called and the stop time is reached.  We'll call this "loop" mode.  Playback always starts at the point in the buffer indicated
by the <code>offset</code> argument of <code>start()</code>, and in <em>loop</em> mode will continue playing until it reaches the <em>actualLoopEnd</em> position
in the buffer (or the end of the buffer), at which point it will wrap back around to the <em>actualLoopStart</em> position in the buffer, and continue
playing according to this pattern.
</p>

<p>
In <em>loop</em> mode then the <em>actual</em> loop points are calculated as follows from the <code>loopStart</code> and <code>loopEnd</code> attributes:
</p>

<blockquote>
<pre>
    if ((loopStart || loopEnd) &amp;&amp; loopStart >= 0 &amp;&amp; loopEnd > 0 &amp;&amp; loopStart &lt; loopEnd) {
        actualLoopStart = loopStart;
        actualLoopEnd = min(loopEnd, buffer.length);
    } else {
        actualLoopStart = 0;
        actualLoopEnd = buffer.length;
    }
</pre>
</blockquote>

<p>
Note that the default values for <code>loopStart</code> and <code>loopEnd</code> are both 0, which indicates that looping should occur from the very start
to the very end of the buffer.
</p>

<p>
Please note that as a low-level implementation detail, the AudioBuffer is at a specific sample-rate (usually the same as the AudioContext sample-rate), and
that the loop times (in seconds) must be converted to the appropriate sample-frame positions in the buffer according to this sample-rate.
</p>

</div>

<div id="MediaElementAudioSourceNode-section" class="section">
<h2 id="MediaElementAudioSourceNode">4.11. The MediaElementAudioSourceNode
Interface</h2>

<p>This interface represents an audio source from an <code>audio</code> or
<code>video</code> element. </p>
<pre>    numberOfInputs  : 0
    numberOfOutputs : 1
    </pre>

<p>
The number of channels of the output corresponds to the number of channels of the media referenced by the HTMLMediaElement.
Thus, changes to the media element's .src attribute can change the number of channels output by this node.
If the .src attribute is not set, then the number of channels output will be one silent channel.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="media-element-audio-source-node-idl">

interface <dfn id="dfn-MediaElementAudioSourceNode">MediaElementAudioSourceNode</dfn> : AudioNode {

};
</code></pre>
</div>
</div>
</div>

<p>A MediaElementAudioSourceNode
is created given an HTMLMediaElement using the AudioContext <a href="#dfn-createMediaElementSource">createMediaElementSource()</a> method. </p>

<p>
The number of channels of the single output equals the number of channels of the audio referenced by
the HTMLMediaElement passed in as the argument to createMediaElementSource(), or is 1 if the HTMLMediaElement
has no audio.
</p>

<p>
The HTMLMediaElement must behave in an identical fashion after the MediaElementAudioSourceNode has
been created, <em>except</em> that the rendered audio will no longer be heard directly, but instead will be heard
as a consequence of the MediaElementAudioSourceNode being connected through the routing graph.  Thus pausing, seeking,
volume, <code>.src</code> attribute changes, and other aspects of the HTMLMediaElement must behave as they normally would
if <em>not</em> used with a MediaElementAudioSourceNode.
</p>

<div class="example">

<div class="exampleHeader">
Example</div>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span></div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 
var mediaElement = document.getElementById('mediaElementID');
var sourceNode = context.createMediaElementSource(mediaElement);
sourceNode.connect(filterNode);
 </code></pre>
</div>
</div>
</div>
</div>


<div id="ScriptProcessorNode-section" class="section">
<h2 id="ScriptProcessorNode">4.12. The ScriptProcessorNode Interface</h2>

<p>This interface is an AudioNode which can generate, process, or analyse audio
directly using JavaScript. </p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCount = numberOfInputChannels;
    channelCountMode = "explicit";
    channelInterpretation = "speakers";
</pre>

<p>The ScriptProcessorNode is constructed with a <code>bufferSize</code> which
must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384.
This value controls how frequently the <code>audioprocess</code> event
is dispatched and how many sample-frames need to be processed each call.
Lower numbers for <code>bufferSize</code> will result in a lower (better) <a
href="#Latency-section">latency</a>. Higher numbers will be necessary to avoid
audio breakup and <a href="#Glitching-section">glitches</a>.
This value will be picked by the implementation if the bufferSize argument
to <code>createScriptProcessor</code> is not passed in, or is set to 0.</p>

<p><code>numberOfInputChannels</code> and <code>numberOfOutputChannels</code>
determine the number of input and output channels. It is invalid for both
<code>numberOfInputChannels</code> and <code>numberOfOutputChannels</code> to
be zero. </p>
<pre>    var node = context.createScriptProcessor(bufferSize, numberOfInputChannels, numberOfOutputChannels);
    </pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="script-processor-node-idl">

interface <dfn id="dfn-ScriptProcessorNode">ScriptProcessorNode</dfn> : AudioNode {

    attribute EventHandler onaudioprocess;

    readonly attribute long bufferSize;

};
</code></pre>
</div>
</div>

<div id="attributes-ScriptProcessorNode-section" class="section">
<h3 id="attributes-ScriptProcessorNode">4.12.1. Attributes</h3>
<dl>
  <dt id="dfn-onaudioprocess"><code>onaudioprocess</code></dt>
    <dd><p>A property used to set the <code>EventHandler</code> (described in <cite><a
      href="http://www.whatwg.org/specs/web-apps/current-work/#eventhandler">HTML</a></cite>)
      for the audioprocess event that is dispatched to <a
      href="#ScriptProcessorNode-section"><code>ScriptProcessorNode</code></a>
      node types. An event of type <a
      href="#AudioProcessingEvent-section"><code>AudioProcessingEvent</code></a>
      will be dispatched to the event handler. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-bufferSize_ScriptProcessorNode"><code>bufferSize</code></dt>
    <dd><p>The size of the buffer (in sample-frames) which needs to be
      processed each time <code>onprocessaudio</code> is called. Legal values
      are (256, 512, 1024, 2048, 4096, 8192, 16384). </p>
    </dd>
</dl>
</div>
</div>

<div id="AudioProcessingEvent-section" class="section">
<h2 id="AudioProcessingEvent">4.13. The AudioProcessingEvent Interface</h2>

<p>This is an <code>Event</code> object which is dispatched to <a
href="#ScriptProcessorNode-section"><code>ScriptProcessorNode</code></a> nodes. </p>

<p>The event handler processes audio from the input (if any) by accessing the
audio data from the <code>inputBuffer</code> attribute. The audio data which is
the result of the processing (or the synthesized data if there are no inputs)
is then placed into the <code>outputBuffer</code>. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-processing-event-idl">

interface <dfn id="dfn-AudioProcessingEvent">AudioProcessingEvent</dfn> : Event {

    readonly attribute double playbackTime;
    readonly attribute AudioBuffer inputBuffer;
    readonly attribute AudioBuffer outputBuffer;

};
</code></pre>
</div>
</div>

<div id="attributes-AudioProcessingEvent-section" class="section">
<h3 id="attributes-AudioProcessingEvent">4.13.1. Attributes</h3>
<dl>
  <dt id="dfn-playbackTime"><code>playbackTime</code></dt>
    <dd><p>The time when the audio will be played in the same time coordinate system as AudioContext.currentTime.
      <code>playbackTime</code> allows for very tight synchronization between
      processing directly in JavaScript with the other events in the context's
      rendering graph. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-inputBuffer"><code>inputBuffer</code></dt>
    <dd><p>An AudioBuffer containing the input audio data.  It will have a number of channels equal to the <code>numberOfInputChannels</code> parameter
    of the createScriptProcessor() method.  This AudioBuffer is only valid while in the scope of the <code>onaudioprocess</code>
    function.  Its values will be meaningless outside of this scope.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-outputBuffer"><code>outputBuffer</code></dt>
    <dd><p>An AudioBuffer where the output audio data should be written.  It will have a number of channels equal to the
    <code>numberOfOutputChannels</code> parameter of the createScriptProcessor() method.
      Script code within the scope of the <code>onaudioprocess</code> function is expected to modify the
      <code>Float32Array</code> arrays representing channel data in this AudioBuffer.
      Any script modifications to this AudioBuffer outside of this scope will not produce any audible effects.</p>
    </dd>
</dl>
</div>
</div>

<div id="PannerNode-section" class="section">
<h2 id="PannerNode">4.14. The PannerNode Interface</h2>

<p>This interface represents a processing node which <a
href="#Spatialization-section">positions / spatializes</a> an incoming audio
stream in three-dimensional space. The spatialization is in relation to the <a
href="#AudioContext-section"><code>AudioContext</code></a>'s <a
href="#AudioListener-section"><code>AudioListener</code></a>
(<code>listener</code> attribute). </p>

<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCount = 2;
    channelCountMode = "clamped-max";
    channelInterpretation = "speakers";
</pre>

<p>
The audio stream from the input will be either mono or stereo, depending on the connection(s) to the input.
</p>

<p>
The output of this node is hard-coded to stereo (2 channels) and <em>currently</em> cannot be configured.
</p>


<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="panner-node-idl">

enum <dfn>PanningModelType</dfn> {
  "equalpower",
  "HRTF"
};

enum <dfn>DistanceModelType</dfn> {
  "linear",
  "inverse",
  "exponential"
};

interface <dfn id="dfn-PannerNode">PannerNode</dfn> : AudioNode {

    <span class="comment">// Default for stereo is HRTF </span>
    attribute PanningModelType panningModel;

    <span class="comment">// Uses a 3D cartesian coordinate system </span>
    void setPosition(double x, double y, double z);
    void setOrientation(double x, double y, double z);
    void setVelocity(double x, double y, double z);

    <span class="comment">// Distance model and attributes </span>
    attribute DistanceModelType distanceModel;
    attribute double refDistance;
    attribute double maxDistance;
    attribute double rolloffFactor;

    <span class="comment">// Directional sound cone </span>
    attribute double coneInnerAngle;
    attribute double coneOuterAngle;
    attribute double coneOuterGain;

};
</code></pre>
</div>
</div>
</div>

<div id="attributes-PannerNode_attributes-section" class="section">
<h3 id="attributes-PannerNode_attributes">4.14.2. Attributes</h3>
<dl>
  <dt id="dfn-panningModel"><code>panningModel</code></dt>
    <dd><p>Determines which spatialization algorithm will be used to position
      the audio in 3D space. The default is "HRTF". </p>

      <dl>
        <dt id="dfn-EQUALPOWER"><code>"equalpower"</code></dt>
          <dd><p>A simple and efficient spatialization algorithm using equal-power
            panning. </p>
          </dd>
      </dl>
      <dl>
        <dt id="dfn-HRTF"><code>"HRTF"</code></dt>
          <dd><p>A higher quality spatialization algorithm using a convolution with
            measured impulse responses from human subjects. This panning method
            renders stereo output. </p>
          </dd>
      </dl>
    </dd>
</dl>
<dl>
  <dt id="dfn-distanceModel"><code>distanceModel</code></dt>
    <dd><p>Determines which algorithm will be used to reduce the volume of an
      audio source as it moves away from the listener.  The default is "inverse".
</p>

<dl>
  <dt id="dfn-LINEAR_DISTANCE"><code>"linear"</code></dt>
    <dd><p>A linear distance model which calculates <em>distanceGain</em> according to: </p>
    <pre>
1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)
    </pre>
    </dd>
</dl>
<dl>
  <dt id="dfn-INVERSE_DISTANCE"><code>"inverse"</code></dt>
  <dd><p>An inverse distance model which calculates <em>distanceGain</em> according to: </p>
    <pre>
refDistance / (refDistance + rolloffFactor * (distance - refDistance))
    </pre>
    </dd>
</dl>
<dl>
  <dt id="dfn-EXPONENTIAL_DISTANCE"><code>"exponential"</code></dt>
  <dd><p>An exponential distance model which calculates <em>distanceGain</em> according to: </p>
  <pre>
pow(distance / refDistance, -rolloffFactor)
  </pre>
    </dd>
</dl>


    </dd>
</dl>
<dl>
  <dt id="dfn-refDistance"><code>refDistance</code></dt>
    <dd><p>A reference distance for reducing volume as source move further from
      the listener.  The default value is 1. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-maxDistance"><code>maxDistance</code></dt>
    <dd><p>The maximum distance between source and listener, after which the
      volume will not be reduced any further.  The default value is 10000. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-rolloffFactor"><code>rolloffFactor</code></dt>
    <dd><p>Describes how quickly the volume is reduced as source moves away
      from listener.  The default value is 1. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-coneInnerAngle"><code>coneInnerAngle</code></dt>
    <dd><p>A parameter for directional audio sources, this is an angle, inside
      of which there will be no volume reduction.  The default value is 360. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-coneOuterAngle"><code>coneOuterAngle</code></dt>
    <dd><p>A parameter for directional audio sources, this is an angle, outside
      of which the volume will be reduced to a constant value of
      <b>coneOuterGain</b>.  The default value is 360. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-coneOuterGain"><code>coneOuterGain</code></dt>
    <dd><p>A parameter for directional audio sources, this is the amount of
      volume reduction outside of the <b>coneOuterAngle</b>.  The default value is 0. </p>
    </dd>
</dl>
</div>

<h3 id="Methods_and_Parameters">4.14.3. Methods and Parameters</h3>
<dl>
  <dt id="dfn-setPosition">The <code>setPosition</code> method</dt>
    <dd><p>Sets the position of the audio source relative to the
      <b>listener</b> attribute. A 3D cartesian coordinate system is used.</p>
      <p>The <dfn id="dfn-x">x, y, z</dfn> parameters represent the coordinates
      in 3D space. </p>
      <p>The default value is (0,0,0)
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setOrientation">The <code>setOrientation</code> method</dt>
    <dd><p>Describes which direction the audio source is pointing in the 3D
      cartesian coordinate space. Depending on how directional the sound is
      (controlled by the <b>cone</b> attributes), a sound pointing away from
      the listener can be very quiet or completely silent.</p>
      <p>The <dfn id="dfn-x_2">x, y, z</dfn> parameters represent a direction
      vector in 3D space. </p>
      <p>The default value is (1,0,0)
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setVelocity">The <code>setVelocity</code> method</dt>
    <dd><p>Sets the velocity vector of the audio source. This vector controls
      both the direction of travel and the speed in 3D space. This velocity
      relative to the listener's velocity is used to determine how much doppler
      shift (pitch change) to apply.  The units used for this vector is <em>meters / second</em>
      and is independent of the units used for position and orientation vectors.</p>
      <p>The <dfn id="dfn-x_3">x, y, z</dfn> parameters describe a direction
      vector indicating direction of travel and intensity. </p>
      <p>The default value is (0,0,0)
      </p>
    </dd>
</dl>

<div id="AudioListener-section" class="section">
<h2 id="AudioListener">4.15. The AudioListener Interface</h2>

<p>This interface represents the position and orientation of the person
listening to the audio scene. All <a
href="#PannerNode-section"><code>PannerNode</code></a> objects
spatialize in relation to the AudioContext's <code>listener</code>. See <a
href="#Spatialization-section">this</a> section for more details about
spatialization. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="audio-listener-idl">

interface <dfn id="dfn-AudioListener">AudioListener</dfn> {

    attribute double dopplerFactor;
    attribute double speedOfSound;

    <span class="comment">// Uses a 3D cartesian coordinate system </span>
    void setPosition(double x, double y, double z);
    void setOrientation(double x, double y, double z, double xUp, double yUp, double zUp);
    void setVelocity(double x, double y, double z);

};
</code></pre>
</div>
</div>
</div>

<div id="attributes-AudioListener-section" class="section">
<h3 id="attributes-AudioListener">4.15.1. Attributes</h3>
<dl>
  <dt id="dfn-dopplerFactor"><code>dopplerFactor</code></dt>
    <dd><p>A constant used to determine the amount of pitch shift to use when
      rendering a doppler effect.  The default value is 1. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-speedOfSound"><code>speedOfSound</code></dt>
    <dd><p>The speed of sound used for calculating doppler shift. The default
      value is 343.3. </p>
    </dd>
</dl>
</div>

<h3 id="L15842">4.15.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-setPosition_2">The <code>setPosition</code> method</dt>
    <dd><p>Sets the position of the listener in a 3D cartesian coordinate
      space. <code>PannerNode</code> objects use this position relative to
      individual audio sources for spatialization.</p>
      <p>The <dfn id="dfn-x_AudioListener">x, y, z</dfn> parameters represent
      the coordinates in 3D space. </p>
      <p>The default value is (0,0,0)
      </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setOrientation_2">The <code>setOrientation</code> method</dt>
    <dd><p>Describes which direction the listener is pointing in the 3D
      cartesian coordinate space. Both a <b>front</b> vector and an <b>up</b>
      vector are provided.  In simple human terms, the <b>front</b> vector represents which
      direction the person's nose is pointing.  The <b>up</b> vector represents the
      direction the top of a person's head is pointing.  These values are expected to
      be linearly independent (at right angles to each other).  For normative requirements
      of how these values are to be interpreted, see the
      <a href="#Spatialization-section">spatialization section</a>.
      </p>
      <p>The <dfn id="dfn-x_setOrientation">x, y, z</dfn> parameters represent
      a <b>front</b> direction vector in 3D space, with the default value being (0,0,-1) </p>
      <p>The <dfn id="dfn-x_setOrientation_2">xUp, yUp, zUp</dfn> parameters
      represent an <b>up</b> direction vector in 3D space, with the default value being (0,1,0)  </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-setVelocity_4">The <code>setVelocity</code> method</dt>
    <dd><p>Sets the velocity vector of the listener. This vector controls both
      the direction of travel and the speed in 3D space. This velocity relative to
      an audio source's velocity is used to determine how much doppler shift
      (pitch change) to apply.  The units used for this vector is <em>meters / second</em>
        and is independent of the units used for position and orientation vectors.</p>
      <p>The <dfn id="dfn-x_setVelocity_5">x, y, z</dfn> parameters describe a
      direction vector indicating direction of travel and intensity. </p>
      <p>The default value is (0,0,0)
      </p>
    </dd>
</dl>

<div id="ConvolverNode-section" class="section">
<h2 id="ConvolverNode">4.16. The ConvolverNode Interface</h2>

<p>This interface represents a processing node which applies a <a
href="#Convolution-section">linear convolution effect</a> given an impulse
response.  Normative requirements for multi-channel convolution matrixing are described
<a href="#Convolution-reverb-effect">here</a>. </p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCount = 2;
    channelCountMode = "clamped-max";
    channelInterpretation = "speakers";
</pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="convolver-node-idl">

interface <dfn id="dfn-ConvolverNode">ConvolverNode</dfn> : AudioNode {

    attribute AudioBuffer? buffer;
    attribute boolean normalize;

};
</code></pre>
</div>
</div>
</div>

<div id="attributes-ConvolverNode-section" class="section">
<h3 id="attributes-ConvolverNode">4.16.1. Attributes</h3>
<dl>
  <dt id="dfn-buffer_ConvolverNode"><code>buffer</code></dt>
    <dd><p>A mono, stereo, or 4-channel <code>AudioBuffer</code> containing the (possibly multi-channel) impulse response
      used by the ConvolverNode.  This <code>AudioBuffer</code> must be of the same sample-rate as the AudioContext or an exception will
      be thrown.  At the time when this attribute is set, the <em>buffer</em> and the state of the <em>normalize</em>
      attribute will be used to configure the ConvolverNode with this impulse response having the given normalization.
      The initial value of this attribute is null.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-normalize"><code>normalize</code></dt>
    <dd><p>Controls whether the impulse response from the buffer will be scaled
      by an equal-power normalization when the <code>buffer</code> atttribute
      is set. Its default value is <code>true</code> in order to achieve a more
      uniform output level from the convolver when loaded with diverse impulse
      responses. If <code>normalize</code> is set to <code>false</code>, then
      the convolution will be rendered with no pre-processing/scaling of the
      impulse response.  Changes to this value do not take effect until the next time
      the <em>buffer</em> attribute is set. </p>
      
    </dd>
</dl>

      <p>
      If the <em>normalize</em> attribute is false when the <em>buffer</em> attribute is set then the
      ConvolverNode will perform a linear convolution given the exact impulse response contained within the <em>buffer</em>.
      </p>
      <p>
      Otherwise, if the <em>normalize</em> attribute is true when the <em>buffer</em> attribute is set then the
      ConvolverNode will first perform a scaled RMS-power analysis of the audio data contained within <em>buffer</em> to calculate a
      <em>normalizationScale</em> given this algorithm:
      </p>


      <div class="block">

      <div class="blockTitleDiv">

      <div class="blockContent">
      <pre class="code"><code class="es-code"> 

float calculateNormalizationScale(buffer)
{
    const float GainCalibration = 0.00125;
    const float GainCalibrationSampleRate = 44100;
    const float MinPower = 0.000125;
  
    // Normalize by RMS power.
    size_t numberOfChannels = buffer->numberOfChannels();
    size_t length = buffer->length();

    float power = 0;

    for (size_t i = 0; i &lt; numberOfChannels; ++i) {
        float* sourceP = buffer->channel(i)->data();
        float channelPower = 0;

        int n = length;
        while (n--) {
            float sample = *sourceP++;
            channelPower += sample * sample;
        }

        power += channelPower;
    }

    power = sqrt(power / (numberOfChannels * length));

    // Protect against accidental overload.
    if (isinf(power) || isnan(power) || power &lt; MinPower)
        power = MinPower;

    float scale = 1 / power;

    // Calibrate to make perceived volume same as unprocessed.
    scale *= GainCalibration;

    // Scale depends on sample-rate.
    if (buffer->sampleRate())
        scale *= GainCalibrationSampleRate / buffer->sampleRate();

    // True-stereo compensation.
    if (buffer->numberOfChannels() == 4)
        scale *= 0.5;

    return scale;
}
          </code></pre>

      </div>
      </div>
      </div>

<p>
During processing, the ConvolverNode will then take this calculated <em>normalizationScale</em> value and multiply it by the result of the linear convolution
resulting from processing the input with the impulse response (represented by the <em>buffer</em>) to produce the
final output.  Or any mathematically equivalent operation may be used, such as pre-multiplying the
input by <em>normalizationScale</em>, or pre-multiplying a version of the impulse-response by <em>normalizationScale</em>.
</p>

</div>

<div id="AnalyserNode-section" class="section">
<h2 id="AnalyserNode">4.17. The AnalyserNode Interface</h2>

<p>This interface represents a node which is able to provide real-time
frequency and time-domain <a href="#AnalyserNode">analysis</a>
information. The audio stream will be passed un-processed from input to output.
</p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1    <em>Note that this output may be left unconnected.</em>

    channelCount = 1;
    channelCountMode = "explicit";
    channelInterpretation = "speakers";
</pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="analyser-node-idl">

interface <dfn id="dfn-AnalyserNode">AnalyserNode</dfn> : AudioNode {

    <span class="comment">// Real-time frequency-domain data </span>
    void getFloatFrequencyData(Float32Array array);
    void getByteFrequencyData(Uint8Array array);

    <span class="comment">// Real-time waveform data </span>
    void getByteTimeDomainData(Uint8Array array);

    attribute unsigned long fftSize;
    readonly attribute unsigned long frequencyBinCount;

    attribute double minDecibels;
    attribute double maxDecibels;

    attribute double smoothingTimeConstant;

};
</code></pre>
</div>
</div>
</div>

<div id="attributes-ConvolverNode-section_2" class="section">
<h3 id="attributes-ConvolverNode_2">4.17.1. Attributes</h3>
<dl>
  <dt id="dfn-fftSize"><code>fftSize</code></dt>
    <dd><p>The size of the FFT used for frequency-domain analysis. This must be
      a non-zero power of two in the range 32 to 2048, otherwise an INDEX_SIZE_ERR exception MUST be thrown.
      The default value is 2048.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-frequencyBinCount"><code>frequencyBinCount</code></dt>
    <dd><p>Half the FFT size. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-minDecibels"><code>minDecibels</code></dt>
    <dd><p>The minimum power value in the scaling range for the FFT analysis
      data for conversion to unsigned byte values.
      The default value is -100.
      If the value of this attribute is set to a value more than or equal to <code>maxDecibels</code>,
      an INDEX_SIZE_ERR exception MUST be thrown.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-maxDecibels"><code>maxDecibels</code></dt>
    <dd><p>The maximum power value in the scaling range for the FFT analysis
      data for conversion to unsigned byte values.
      The default value is -30.
      If the value of this attribute is set to a value less than or equal to <code>minDecibels</code>,
      an INDEX_SIZE_ERR exception MUST be thrown.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-smoothingTimeConstant"><code>smoothingTimeConstant</code></dt>
    <dd><p>A value from 0 -&gt; 1 where 0 represents no time averaging
      with the last analysis frame.
      The default value is 0.8.
      If the value of this attribute is set to a value less than 0 or more than 1,
      an INDEX_SIZE_ERR exception MUST be thrown.</p>
    </dd>
</dl>
</div>

<h3 id="methods-and-parameters">4.17.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-getFloatFrequencyData">The <code>getFloatFrequencyData</code>
  method</dt>
    <dd><p>Copies the current frequency data into the passed floating-point
      array. If the array has fewer elements than the frequencyBinCount, the
      excess elements will be dropped. If the array has more elements than
      the frequencyBinCount, the excess elements will be ignored.</p>
      <p>The <dfn id="dfn-array">array</dfn> parameter is where
      frequency-domain analysis data will be copied. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-getByteFrequencyData">The <code>getByteFrequencyData</code>
  method</dt>
    <dd><p>Copies the current frequency data into the passed unsigned byte
      array. If the array has fewer elements than the frequencyBinCount, the
      excess elements will be dropped. If the array has more elements than
      the frequencyBinCount, the excess elements will be ignored.</p>
      <p>The <dfn id="dfn-array_2">array</dfn> parameter is where
      frequency-domain analysis data will be copied. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-getByteTimeDomainData">The <code>getByteTimeDomainData</code>
  method</dt>
    <dd><p>Copies the current time-domain (waveform) data into the passed
      unsigned byte array. If the array has fewer elements than the
      fftSize, the excess elements will be dropped. If the array has more
      elements than fftSize, the excess elements will be ignored.</p>
      <p>The <dfn id="dfn-array_3">array</dfn> parameter is where time-domain
      analysis data will be copied. </p>
    </dd>
</dl>

<div id="ChannelSplitterNode-section" class="section">
<h2 id="ChannelSplitterNode">4.18. The ChannelSplitterNode Interface</h2>

<p>The <code>ChannelSplitterNode</code> is for use in more advanced
applications and would often be used in conjunction with <a
href="#ChannelMergerNode-section"><code>ChannelMergerNode</code></a>. </p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : Variable N (defaults to 6) // number of "active" (non-silent) outputs is determined by number of channels in the input

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>

<p>This interface represents an AudioNode for accessing the individual channels
of an audio stream in the routing graph. It has a single input, and a number of
"active" outputs which equals the number of channels in the input audio stream.
For example, if a stereo input is connected to an
<code>ChannelSplitterNode</code> then the number of active outputs will be two
(one from the left channel and one from the right). There are always a total
number of N outputs (determined by the <code>numberOfOutputs</code> parameter to the AudioContext method <code>createChannelSplitter()</code>),
 The default number is 6 if this value is not provided. Any outputs
which are not "active" will output silence and would typically not be connected
to anything. </p>

<h3 id="example-1">Example:</h3>
<img alt="channel splitter" src="images/channel-splitter.png" /> 

<p>Please note that in this example, the splitter does <b>not</b> interpret the channel identities (such as left, right, etc.), but
simply splits out channels in the order that they are input.</p>

<p>One application for <code>ChannelSplitterNode</code> is for doing "matrix
mixing" where individual gain control of each channel is desired. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="channel-splitter-node-idl">

interface <dfn id="dfn-ChannelSplitterNode">ChannelSplitterNode</dfn> : AudioNode {

};
</code></pre>
</div>
</div>
</div>

<div id="ChannelMergerNode-section" class="section">
<h2 id="ChannelMergerNode">4.19. The ChannelMergerNode Interface</h2>

<p>The <code>ChannelMergerNode</code> is for use in more advanced applications
and would often be used in conjunction with <a
href="#ChannelSplitterNode-section"><code>ChannelSplitterNode</code></a>. </p>
<pre>
    numberOfInputs  : Variable N (default to 6)  // number of connected inputs may be less than this
    numberOfOutputs : 1

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>

<p>This interface represents an AudioNode for combining channels from multiple
audio streams into a single audio stream. It has a variable number of inputs (defaulting to 6), but not all of them
need be connected. There is a single output whose audio stream has a number of
channels equal to the sum of the numbers of channels of all the connected
inputs. For example, if an <code>ChannelMergerNode</code> has two connected
inputs (both stereo), then the output will be four channels, the first two from
the first input and the second two from the second input. In another example
with two connected inputs (both mono), the output will be two channels
(stereo), with the left channel coming from the first input and the right
channel coming from the second input. </p>

<h3 id="example-2">Example:</h3>
<img alt="channel merger" src="images/channel-merger.png" /> 

<p>Please note that in this example, the merger does <b>not</b> interpret the channel identities (such as left, right, etc.), but
simply combines channels in the order that they are input.</p>


<p>Be aware that it is possible to connect an <code>ChannelMergerNode</code>
in such a way that it outputs an audio stream with a large number of channels
greater than the maximum supported by the audio hardware. In this case where such an output is connected
to the AudioContext .destination (the audio hardware), then the extra channels will be ignored.
Thus, the <code>ChannelMergerNode</code> should be used in situations where the number
of channels is well understood. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="channel-merger-node-idl">

interface <dfn id="dfn-ChannelMergerNode">ChannelMergerNode</dfn> : AudioNode {

};
</code></pre>
</div>
</div>
</div>

<div id="DynamicsCompressorNode-section" class="section">
<h2 id="DynamicsCompressorNode">4.20. The DynamicsCompressorNode Interface</h2>

<p>DynamicsCompressorNode is an AudioNode processor implementing a dynamics
compression effect. </p>

<p>Dynamics compression is very commonly used in musical production and game
audio. It lowers the volume of the loudest parts of the signal and raises the
volume of the softest parts. Overall, a louder, richer, and fuller sound can be
achieved. It is especially important in games and musical applications where
large numbers of individual sounds are played simultaneous to control the
overall signal level and help avoid clipping (distorting) the audio output to
the speakers. </p>
<pre>    
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCount = 2;
    channelCountMode = "explicit";
    channelInterpretation = "speakers";
</pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="dynamics-compressor-node-idl">

interface <dfn id="dfn-DynamicsCompressorNode">DynamicsCompressorNode</dfn> : AudioNode {

    readonly attribute AudioParam threshold; // in Decibels
    readonly attribute AudioParam knee; // in Decibels
    readonly attribute AudioParam ratio; // unit-less
    readonly attribute AudioParam reduction; // in Decibels
    readonly attribute AudioParam attack; // in Seconds
    readonly attribute AudioParam release; // in Seconds

};
</code>
</pre>
</div>
</div>

<div id="attributes-DynamicsCompressorNode-section" class="section">
<h3 id="attributes-DynamicsCompressorNode">4.20.1. Attributes</h3>
<p>
All parameters are <em>k-rate</em>
</p>

<dl>
  <dt id="dfn-threshold"><code>threshold</code></dt>
    <dd><p>The decibel value above which the compression will start taking
      effect.  Its default value is -24, with a nominal range of -100 to 0. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-knee"><code>knee</code></dt>
    <dd><p>A decibel value representing the range above the threshold where the
      curve smoothly transitions to the "ratio" portion. Its default value is 30, with a nominal range of 0 to 40. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-ratio"><code>ratio</code></dt>
    <dd><p>The amount of dB change in input for a 1 dB change in output. Its default value is 12, with a nominal range of 1 to 20. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-reduction"><code>reduction</code></dt>
    <dd><p>A read-only decibel value for metering purposes, representing the
      current amount of gain reduction that the compressor is applying to the
      signal. If fed no signal the value will be 0 (no gain reduction).  The nominal range is -20 to 0. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-attack"><code>attack</code></dt>
    <dd><p>The amount of time (in seconds) to reduce the gain by 10dB.   Its default value is 0.003, with a nominal range of 0 to 1. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-release"><code>release</code></dt>
    <dd><p>The amount of time (in seconds) to increase the gain by 10dB.  Its default value is 0.250, with a nominal range of 0 to 1. </p>
    </dd>
</dl>
</div>
</div>

<div id="BiquadFilterNode-section" class="section">
<h2 id="BiquadFilterNode">4.21. The BiquadFilterNode Interface</h2>

<p>BiquadFilterNode is an AudioNode processor implementing very common
low-order filters. </p>

<p>Low-order filters are the building blocks of basic tone controls (bass, mid,
treble), graphic equalizers, and more advanced filters. Multiple
BiquadFilterNode filters can be combined to form more complex filters. The
filter parameters such as "frequency" can be changed over time for filter
sweeps, etc. Each BiquadFilterNode can be configured as one of a number of
common filter types as shown in the IDL below.  The default filter type
is "lowpass".</p>
<pre>    
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>
<p>
The number of channels of the output always equals the number of channels of the input.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="biquad-filter-node-idl">

enum <dfn>BiquadFilterType</dfn> {
  "lowpass",
  "highpass",
  "bandpass",
  "lowshelf",
  "highshelf",
  "peaking",
  "notch",
  "allpass"
};

interface <dfn id="dfn-BiquadFilterNode">BiquadFilterNode</dfn> : AudioNode {

    attribute BiquadFilterType type;
    readonly attribute AudioParam frequency; // in Hertz
    readonly attribute AudioParam detune; // in Cents
    readonly attribute AudioParam Q; // Quality factor
    readonly attribute AudioParam gain; // in Decibels

    void getFrequencyResponse(Float32Array frequencyHz,
                              Float32Array magResponse,
                              Float32Array phaseResponse);

};
</code></pre>
</div>
</div>
</div>

<p>The filter types are briefly described below. We note that all of these
filters are very commonly used in audio processing. In terms of implementation,
they have all been derived from standard analog filter prototypes. For more
technical details, we refer the reader to the excellent <a
href="http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt">reference</a> by
Robert Bristow-Johnson.</p>

<p>
All parameters are <em>k-rate</em> with the following default parameter values:
</p>

<blockquote>
<dl>
  <dt>frequency</dt>
    <dd>350Hz, with a nominal range of 10 to the Nyquist frequency (half the sample-rate).
    </dd>
  <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
    <dd>1, with a nominal range of 0.0001 to 1000.</dd>
  <dt>gain</dt>
    <dd>0, with a nominal range of -40 to 40.</dd>
</dl>
</blockquote>



<div id="BiquadFilterNode-description-section" class="section">
<h3 id="BiquadFilterNode-description">4.21.1 "lowpass"</h3>

<p>A <a href="http://en.wikipedia.org/wiki/Low-pass_filter">lowpass filter</a>
allows frequencies below the cutoff frequency to pass through and attenuates
frequencies above the cutoff. It implements a standard second-order
resonant lowpass filter with 12dB/octave rolloff.</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The cutoff frequency</dd>
    <dt>Q</dt>
      <dd>Controls how peaked the response will be at the cutoff frequency. A
        large value makes the response more peaked.  Please note that for this filter type, this
        value is not a traditional Q, but is a resonance value in decibels.</dd>
    <dt>gain</dt>
      <dd>Not used in this filter type</dd>
  </dl>
</blockquote>

<h3 id="HIGHPASS">4.21.2 "highpass"</h3>

<p>A <a href="http://en.wikipedia.org/wiki/High-pass_filter">highpass
filter</a> is the opposite of a lowpass filter. Frequencies above the cutoff
frequency are passed through, but frequencies below the cutoff are attenuated.
It implements a standard second-order resonant highpass filter with
12dB/octave rolloff.</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The cutoff frequency below which the frequencies are attenuated</dd>
    <dt>Q</dt>
      <dd>Controls how peaked the response will be at the cutoff frequency. A
        large value makes the response more peaked. Please note that for this filter type, this
        value is not a traditional Q, but is a resonance value in decibels.</dd>
    <dt>gain</dt>
      <dd>Not used in this filter type</dd>
  </dl>
</blockquote>

<h3 id="BANDPASS">4.21.3 "bandpass"</h3>

<p>A <a href="http://en.wikipedia.org/wiki/Band-pass_filter">bandpass
filter</a> allows a range of frequencies to pass through and attenuates the
frequencies below and above this frequency range. It implements a
second-order bandpass filter.</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The center of the frequency band</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Controls the width of the band. The width becomes narrower as the Q
        value increases.</dd>
    <dt>gain</dt>
      <dd>Not used in this filter type</dd>
  </dl>
</blockquote>

<h3 id="LOWSHELF">4.21.4 "lowshelf"</h3>

<p>The lowshelf filter allows all frequencies through, but adds a boost (or
attenuation) to the lower frequencies. It implements a second-order
lowshelf filter.</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The upper limit of the frequences where the boost (or attenuation) is
        applied.</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Not used in this filter type.</dd>
    <dt>gain</dt>
      <dd>The boost, in dB, to be applied. If the value is negative, the
        frequencies are attenuated.</dd>
  </dl>
</blockquote>

<h3 id="L16352">4.21.5 "highshelf"</h3>

<p>The highshelf filter is the opposite of the lowshelf filter and allows all
frequencies through, but adds a boost to the higher frequencies. It
implements a second-order highshelf filter</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The lower limit of the frequences where the boost (or attenuation) is
        applied.</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Not used in this filter type.</dd>
    <dt>gain</dt>
      <dd>The boost, in dB, to be applied. If the value is negative, the
        frequencies are attenuated.</dd>
  </dl>
</blockquote>

<h3 id="PEAKING">4.21.6 "peaking"</h3>

<p>The peaking filter allows all frequencies through, but adds a boost (or
attenuation) to a range of frequencies. </p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The center frequency of where the boost is applied.</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Controls the width of the band of frequencies that are boosted. A
        large value implies a narrow width.</dd>
    <dt>gain</dt>
      <dd>The boost, in dB, to be applied. If the value is negative, the
        frequencies are attenuated.</dd>
  </dl>
</blockquote>

<h3 id="NOTCH">4.21.7 "notch"</h3>

<p>The notch filter (also known as a <a
href="http://en.wikipedia.org/wiki/Band-stop_filter">band-stop or
band-rejection filter</a>) is the opposite of a bandpass filter. It allows all
frequencies through, except for a set of frequencies.</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The center frequency of where the notch is applied.</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Controls the width of the band of frequencies that are attenuated. A
        large value implies a narrow width.</dd>
    <dt>gain</dt>
      <dd>Not used in this filter type.</dd>
  </dl>
</blockquote>

<h3 id="ALLPASS">4.21.8 "allpass"</h3>

<p>An <a
href="http://en.wikipedia.org/wiki/All-pass_filter#Digital_Implementation">allpass
filter</a> allows all frequencies through, but changes the phase relationship
between the various frequencies. It implements a second-order allpass
filter</p>

<blockquote>
  <dl>
    <dt>frequency</dt>
      <dd>The frequency where the center of the phase transition occurs. Viewed
        another way, this is the frequency with maximal <a
        href="http://en.wikipedia.org/wiki/Group_delay">group delay</a>.</dd>
    <dt><a href="http://en.wikipedia.org/wiki/Q_factor">Q</a></dt>
      <dd>Controls how sharp the phase transition is at the center frequency. A
        larger value implies a sharper transition and a larger group delay.</dd>
    <dt>gain</dt>
      <dd>Not used in this filter type.</dd>
  </dl>
</blockquote>

<h3 id="Methods">4.21.9. Methods</h3>
<dl>
  <dt id="dfn-getFrequencyResponse">The <code>getFrequencyResponse</code>
  method</dt>
    <dd><p>Given the current filter parameter settings, calculates the
      frequency response for the specified frequencies. </p>
      <p>The <dfn id="dfn-frequencyHz">frequencyHz</dfn> parameter specifies an
      array of frequencies at which the response values will be calculated.</p>
      <p>The <dfn id="dfn-magResponse">magResponse</dfn> parameter specifies an
      output array receiving the linear magnitude response values.</p>
      <p>The <dfn id="dfn-phaseResponse">phaseResponse</dfn> parameter
      specifies an output array receiving the phase response values in
      radians.</p>
    </dd>
</dl>
</div>

<div id="WaveShaperNode-section" class="section">
<h2 id="WaveShaperNode">4.22. The WaveShaperNode Interface</h2>

<p>WaveShaperNode is an AudioNode processor implementing non-linear distortion
effects. </p>

<p>Non-linear waveshaping distortion is commonly used for both subtle
non-linear warming, or more obvious distortion effects. Arbitrary non-linear
shaping curves may be specified.</p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 1

    channelCountMode = "max";
    channelInterpretation = "speakers";
</pre>

<p>
The number of channels of the output always equals the number of channels of the input.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="wave-shaper-node-idl">

enum <dfn>OverSampleType</dfn> {
    "none",
    "2x",
    "4x"
};

interface <dfn id="dfn-WaveShaperNode">WaveShaperNode</dfn> : AudioNode {

    attribute Float32Array? curve;
    attribute OverSampleType oversample;

};
</code></pre>
</div>
</div>

<div id="attributes-WaveShaperNode-section" class="section">
<h3 id="attributes-WaveShaperNode">4.22.1. Attributes</h3>
<dl>
  <dt id="dfn-curve"><code>curve</code></dt>
    <dd><p>The shaping curve used for the waveshaping effect. The input signal
      is nominally within the range -1 -&gt; +1. Each input sample within this
      range will index into the shaping curve with a signal level of zero
      corresponding to the center value of the curve array. Any sample value
      less than -1 will correspond to the first value in the curve array. Any
      sample value greater than +1 will correspond to the last value in
      the curve array.  The implementation must perform linear interpolation between
      adjacent points in the curve.  Initially the curve attribute is null, which means that
      the WaveShaperNode will pass its input to its output without modification.</p>
    </dd>
</dl>

<dl>
  <dt id="dfn-oversample"><code>oversample</code></dt>
    <dd><p>Specifies what type of oversampling (if any) should be used when applying the shaping curve.    
    The default value is "none", meaning the curve will be applied directly to the input samples.
    A value of "2x" or "4x" can improve the quality of the processing by avoiding some aliasing, with
    the "4x" value yielding the highest quality.  For some applications, it's better to use no oversampling
    in order to get a very precise shaping curve.
    </p>
    <p>
    A value of "2x" or "4x" means that the following steps must be performed:
    <ol>
    <li>Up-sample the input samples to 2x or 4x the sample-rate of the AudioContext.  Thus for each
    processing block of 128 samples, generate 256 (for 2x) or 512 (for 4x) samples.</li>
    <li>Apply the shaping curve.</li>
    <li>Down-sample the result back to the sample-rate of the AudioContext.  Thus taking the 256 (or 512) processed samples, generating 128 as
    the final result.
    </ol>
    The exact up-sampling and down-sampling filters are not specified, and can be tuned for sound quality (low aliasing, etc.), low latency, and performance.
    </p>
    </dd>
</dl>
</div>
</div>

<div id="OscillatorNode-section" class="section">
<h2 id="OscillatorNode">4.23. The OscillatorNode Interface</h2>

<p>OscillatorNode represents an audio source generating a periodic waveform. It can be set to
a few commonly used waveforms. Additionally, it can be set to an arbitrary periodic
waveform through the use of a <a href="#PeriodicWave-section"><code>PeriodicWave</code></a> object. </p>

<p>Oscillators are common foundational building blocks in audio synthesis.  An OscillatorNode will start emitting sound at the time
specified by the <code>start()</code> method. </p>

<p>
Mathematically speaking, a <em>continuous-time</em> periodic waveform can have very high (or infinitely high) frequency information when considered
in the frequency domain.  When this waveform is sampled as a discrete-time digital audio signal at a particular sample-rate,
then care must be taken to discard (filter out) the high-frequency information higher than the <em>Nyquist</em> frequency (half the sample-rate)
before converting the waveform to a digital form.  If this is not done, then <em>aliasing</em> of higher frequencies (than the Nyquist frequency) will fold
back as mirror images into frequencies lower than the Nyquist frequency.  In many cases this will cause audibly objectionable artifacts.
This is a basic and well understood principle of audio DSP.
</p>

<p>
There are several practical approaches that an implementation may take to avoid this aliasing.
But regardless of approach, the <em>idealized</em> discrete-time digital audio signal is well defined mathematically.
The trade-off for the implementation is a matter of implementation cost (in terms of CPU usage) versus fidelity to
achieving this ideal.
</p>

<p>
It is expected that an implementation will take some care in achieving this ideal, but it is reasonable to consider lower-quality,
less-costly approaches on lower-end hardware.
</p>

<p>
Both .frequency and .detune are <em>a-rate</em> parameters and are used together to determine a <em>computedFrequency</em> value:
</p>

<pre>
computedFrequency(t) = frequency(t) * pow(2, detune(t) / 1200)
</pre>

<p>
The OscillatorNode's instantaneous phase at each time is the time integral of <em>computedFrequency</em>.
</p>

<pre>    numberOfInputs  : 0
    numberOfOutputs : 1 (mono output)
    </pre>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="oscillator-node-idl">

enum <dfn>OscillatorType</dfn> {
  "sine",
  "square",
  "sawtooth",
  "triangle",
  "custom"
};

interface <dfn id="dfn-OscillatorNode">OscillatorNode</dfn> : AudioNode {

    attribute OscillatorType type;

    readonly attribute AudioParam frequency; // in Hertz
    readonly attribute AudioParam detune; // in Cents

    void start(double when);
    void stop(double when);
    void setPeriodicWave(PeriodicWave periodicWave);

    attribute EventHandler onended;

};
</code></pre>
</div>
</div>

<div id="attributes-OscillatorNode-section" class="section">
<h3 id="attributes-OscillatorNode">4.23.1. Attributes</h3>
<dl>
  <dt id="dfn-type"><code>type</code></dt>
    <dd><p>The shape of the periodic waveform.  It may directly be set to any of the type constant values except for "custom".
    The <a href="#dfn-setPeriodicWave"><code>setPeriodicWave()</code></a> method can be used to set a custom waveform, which results in this attribute
    being set to "custom".  The default value is "sine". </p>
    </dd>
</dl>

<dl>
  <dt id="dfn-frequency"><code>frequency</code></dt>
    <dd><p>The frequency (in Hertz) of the periodic waveform. This parameter is <em>a-rate</em> </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-detune"><code>detune</code></dt>
    <dd><p>A detuning value (in Cents) which will offset the <code>frequency</code> by the given amount.
     This parameter is <em>a-rate</em> </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-onended"><code>onended</code></dt>
    <dd><p>A property used to set the <code>EventHandler</code> (described in <cite><a
      href="http://www.whatwg.org/specs/web-apps/current-work/#eventhandler">HTML</a></cite>)
      for the ended event that is dispatched to <a
      href="#OscillatorNode-section"><code>OscillatorNode</code></a>
      node types.  When the playback of the buffer for an <code>OscillatorNode</code>
      is finished, an event of type <code>Event</code> (described in <cite><a
      href="http://www.whatwg.org/specs/web-apps/current-work/#event">HTML</a></cite>)
      will be dispatched to the event handler. </p>
    </dd>
</dl>
</div>
</div>

<div id="methodsandparams-OscillatorNode-section" class="section">
<h3 id="methodsandparams-OscillatorNode">4.23.2. Methods and Parameters</h3>
<dl>
  <dt id="dfn-setPeriodicWave">The <code>setPeriodicWave</code>
  method</dt>
    <dd><p>Sets an arbitrary custom periodic waveform given a <a href="#PeriodicWave-section"><code>PeriodicWave</code></a>.</p>
    </dd>
</dl>
<dl>
  <dt id="dfn-start-AudioBufferSourceNode">The <code>start</code>
  method</dt>
    <dd><p>defined as in <a href="#AudioBufferSourceNode-section"><code>AudioBufferSourceNode</code></a>. </p>
    </dd>
</dl>
<dl>
  <dt id="dfn-stop-AudioBufferSourceNode">The <code>stop</code>
  method</dt>
    <dd><p>defined as in <a href="#AudioBufferSourceNode-section"><code>AudioBufferSourceNode</code></a>. </p>
    </dd>
</dl>
</div>


<div id="PeriodicWave-section" class="section">
<h2 id="PeriodicWave">4.24. The PeriodicWave Interface</h2>

<p>PeriodicWave represents an arbitrary periodic waveform to be used with an <a href="#OscillatorNode-section"><code>OscillatorNode</code></a>.
Please see <a href="#dfn-createPeriodicWave">createPeriodicWave()</a> and <a href="#dfn-setPeriodicWave">setPeriodicWave()</a> and for more details. </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="wavetable-idl">

interface <dfn id="dfn-PeriodicWave">PeriodicWave</dfn> {

};
</code></pre>
</div>
</div>
</div>

<div id="MediaStreamAudioSourceNode-section" class="section">
<h2 id="MediaStreamAudioSourceNode">4.25. The MediaStreamAudioSourceNode
Interface</h2>

<p>This interface represents an audio source from a <code>MediaStream</code>.
The first <code>AudioMediaStreamTrack</code> from the <code>MediaStream</code> will be
used as a source of audio.</p>
<pre>    numberOfInputs  : 0
    numberOfOutputs : 1
</pre>

  <p>
  The number of channels of the output corresponds to the number of channels of the <code>AudioMediaStreamTrack</code>.
  If there is no valid audio track, then the number of channels output will be one silent channel.
  </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="media-stream-audio-source-node-idl">

interface <dfn id="dfn-MediaStreamAudioSourceNode">MediaStreamAudioSourceNode</dfn> : AudioNode {

};
</code></pre>
</div>
</div>
</div>

<div id="MediaStreamAudioDestinationNode-section" class="section">
<h2 id="MediaStreamAudioDestinationNode">4.26. The MediaStreamAudioDestinationNode
Interface</h2>

<p>This interface is an audio destination representing a <code>MediaStream</code> with a single <code>AudioMediaStreamTrack</code>.
This MediaStream is created when the node is created and is accessible via the <dfn>stream</dfn> attribute.
This stream can be used in a similar way as a MediaStream obtained via getUserMedia(), and
can, for example, be sent to a remote peer using the RTCPeerConnection addStream() method.
</p>
<pre>
    numberOfInputs  : 1
    numberOfOutputs : 0

    channelCount = 2;
    channelCountMode = "explicit";
    channelInterpretation = "speakers";
</pre>

<p>
The number of channels of the input is by default 2 (stereo).  Any connections to the input
are up-mixed/down-mixed to the number of channels of the input.
</p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">Web IDL</span></div>

<div class="blockContent">
<pre class="code"><code class="idl-code" id="media-stream-audio-destination-node-idl">

interface <dfn id="dfn-MediaStreamAudioDestinationNode">MediaStreamAudioDestinationNode</dfn> : AudioNode {

    readonly attribute MediaStream stream;

};
</code></pre>
</div>
</div>

<div id="attributes-MediaStreamAudioDestinationNode-section" class="section">
<h3 id="attributes-MediaStreamAudioDestinationNode">4.26.1. Attributes</h3>
<dl>
  <dt id="dfn-stream"><code>stream</code></dt>
    <dd><p>A MediaStream containing a single AudioMediaStreamTrack with the same number of channels
    as the node itself.</p>
    </dd>
</dl>
</div>

</div>

<div id="MixerGainStructure-section" class="section">
<h2 id="MixerGainStructure">6. Mixer Gain Structure</h2>

<p class="norm">This section is informative.</p>

<h3 id="background">Background</h3>

<p>One of the most important considerations when dealing with audio processing
graphs is how to adjust the gain (volume) at various points. For example, in a
standard mixing board model, each input bus has pre-gain, post-gain, and
send-gains. Submix and master out busses also have gain control. The gain
control described here can be used to implement standard mixing boards as well
as other architectures. </p>

<div id="SummingJunction-section" class="section">
<h3 id="SummingJunction">Summing Inputs</h3>
</div>

<p>The inputs to <a href="#AudioNode-section"><code>AudioNodes</code></a> have
the ability to accept connections from multiple outputs. The input then acts as
a unity gain summing junction with each output signal being added with the
others: </p>
<img alt="unity gain summing junction"
src="images/unity-gain-summing-junction.png" /> 

<p>In cases where the channel layouts of the outputs do not match, a mix (usually up-mix) will occur according to the <a
href="#UpMix-section">mixing rules</a>.
</p>

<h3 id="gain-Control">Gain Control</h3>

<p>But many times, it's important to be able to control the gain for each of
the output signals. The <a
href="#GainNode-section"><code>GainNode</code></a> gives this
control: </p>
<img alt="mixer architecture new" src="images/mixer-architecture-new.png" /> 

<p>Using these two concepts of unity gain summing junctions and GainNodes,
it's possible to construct simple or complex mixing scenarios. </p>

<h3 id="Example-mixer-with-send-busses">Example: Mixer with Send Busses</h3>

<p>In a routing scenario involving multiple sends and submixes, explicit
control is needed over the volume or "gain" of each connection to a mixer. Such
routing topologies are very common and exist in even the simplest of electronic
gear sitting around in a basic recording studio. </p>

<p>Here's an example with two send mixers and a main mixer. Although possible,
for simplicity's sake, pre-gain control and insert effects are not illustrated:
</p>
<img alt="mixer gain structure" src="images/mixer-gain-structure.png" /> 

<p>This diagram is using a shorthand notation where "send 1", "send 2", and
"main bus" are actually inputs to AudioNodes, but here are represented as
summing busses, where the intersections g2_1, g3_1, etc. represent the "gain"
or volume for the given source on the given mixer. In order to expose this
gain, an <a href="#dfn-GainNode"><code>GainNode</code></a> is used:
</p>

<p>Here's how the above diagram could be constructed in JavaScript: </p>

<div class="example">

<div class="exampleHeader">
Example</div>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span></div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 

var context = 0;
var compressor = 0;
var reverb = 0;
var delay = 0;
var s1 = 0;
var s2 = 0;

var source1 = 0;
var source2 = 0;
var g1_1 = 0;
var g2_1 = 0;
var g3_1 = 0;
var g1_2 = 0;
var g2_2 = 0;
var g3_2 = 0;

<span class="comment">// Setup routing graph </span>
function setupRoutingGraph() {
    context = new AudioContext();

    compressor = context.createDynamicsCompressor();

    <span class="comment">// Send1 effect </span>
    reverb = context.createConvolver();
    <span class="comment">// Convolver impulse response may be set here or later </span>

    <span class="comment">// Send2 effect </span>
    delay = context.createDelay();

    <span class="comment">// Connect final compressor to final destination </span>
    compressor.connect(context.destination);

    <span class="comment">// Connect sends 1 &amp; 2 through effects to main mixer </span>
    s1 = context.createGain();
    reverb.connect(s1);
    s1.connect(compressor);
    
    s2 = context.createGain();
    delay.connect(s2);
    s2.connect(compressor);

    <span class="comment">// Create a couple of sources </span>
    source1 = context.createBufferSource();
    source2 = context.createBufferSource();
    source1.buffer = manTalkingBuffer;
    source2.buffer = footstepsBuffer;

    <span class="comment">// Connect source1 </span>
    g1_1 = context.createGain();
    g2_1 = context.createGain();
    g3_1 = context.createGain();
    source1.connect(g1_1);
    source1.connect(g2_1);
    source1.connect(g3_1);
    g1_1.connect(compressor);
    g2_1.connect(reverb);
    g3_1.connect(delay);

    <span class="comment">// Connect source2 </span>
    g1_2 = context.createGain();
    g2_2 = context.createGain();
    g3_2 = context.createGain();
    source2.connect(g1_2);
    source2.connect(g2_2);
    source2.connect(g3_2);
    g1_2.connect(compressor);
    g2_2.connect(reverb);
    g3_2.connect(delay);

    <span class="comment">// We now have explicit control over all the volumes g1_1, g2_1, ..., s1, s2 </span>
    g2_1.gain.value = 0.2; <span class="comment"> // For example, set source1 reverb gain </span>

    <span class="comment"> // Because g2_1.gain is an "AudioParam", </span>
    <span class="comment"> // an automation curve could also be attached to it. </span>
    <span class="comment"> // A "mixing board" UI could be created in canvas or WebGL controlling these gains. </span>
}

 </code></pre>
</div>
</div>
</div>
</div>
<br />


<div id="DynamicLifetime-section">
<h2 id="DynamicLifetime">7. Dynamic Lifetime</h2>

<h3 id="DynamicLifetime-background">Background</h3>

<p class="norm">This section is informative. Please see <a href="#lifetime-AudioContext">AudioContext lifetime</a>
and <a href="#lifetime-AudioNode">AudioNode lifetime</a>  for normative requirements
</p>

<p>In addition to allowing the creation of static routing configurations, it
should also be possible to do custom effect routing on dynamically allocated
voices which have a limited lifetime. For the purposes of this discussion,
let's call these short-lived voices "notes". Many audio applications
incorporate the ideas of notes, examples being drum machines, sequencers, and
3D games with many one-shot sounds being triggered according to game play. </p>

<p>In a traditional software synthesizer, notes are dynamically allocated and
released from a pool of available resources. The note is allocated when a MIDI
note-on message is received. It is released when the note has finished playing
either due to it having reached the end of its sample-data (if non-looping), it
having reached a sustain phase of its envelope which is zero, or due to a MIDI
note-off message putting it into the release phase of its envelope. In the MIDI
note-off case, the note is not released immediately, but only when the release
envelope phase has finished. At any given time, there can be a large number of
notes playing but the set of notes is constantly changing as new notes are
added into the routing graph, and old ones are released. </p>

<p>The audio system automatically deals with tearing-down the part of the
routing graph for individual "note" events. A "note" is represented by an
<code>AudioBufferSourceNode</code>, which can be directly connected to other
processing nodes. When the note has finished playing, the context will
automatically release the reference to the <code>AudioBufferSourceNode</code>,
which in turn will release references to any nodes it is connected to, and so
on. The nodes will automatically get disconnected from the graph and will be
deleted when they have no more references. Nodes in the graph which are
long-lived and shared between dynamic voices can be managed explicitly.
Although it sounds complicated, this all happens automatically with no extra
JavaScript handling required. </p>

<h3 id="Example-DynamicLifetime">Example</h3>

<div class="example">

<div class="exampleHeader">
Example</div>
<img alt="dynamic allocation" src="images/dynamic-allocation.png" /> 

<p>The low-pass filter, panner, and second gain nodes are directly connected
from the one-shot sound. So when it has finished playing the context will
automatically release them (everything within the dotted line). If there are no
longer any JavaScript references to the one-shot sound and connected nodes,
then they will be immediately removed from the graph and deleted. The streaming
source, has a global reference and will remain connected until it is explicitly
disconnected. Here's how it might look in JavaScript: </p>

<div class="block">

<div class="blockTitleDiv">
<span class="blockTitle">ECMAScript</span></div>

<div class="blockContent">
<pre class="code"><code class="es-code"> 

var context = 0;
var compressor = 0;
var gainNode1 = 0;
var streamingAudioSource = 0;

<span class="comment">// Initial setup of the "long-lived" part of the routing graph </span> 
function setupAudioContext() {
    context = new AudioContext();

    compressor = context.createDynamicsCompressor();
    gainNode1 = context.createGain();

    // Create a streaming audio source.
    var audioElement = document.getElementById('audioTagID');
    streamingAudioSource = context.createMediaElementSource(audioElement);
    streamingAudioSource.connect(gainNode1);

    gainNode1.connect(compressor);
    compressor.connect(context.destination);
}

<span class="comment">// Later in response to some user action (typically mouse or key event) </span>
<span class="comment">// a one-shot sound can be played. </span>
function playSound() {
    var oneShotSound = context.createBufferSource();
    oneShotSound.buffer = dogBarkingBuffer;

    <span class="comment">// Create a filter, panner, and gain node. </span>
    var lowpass = context.createBiquadFilter();
    var panner = context.createPanner();
    var gainNode2 = context.createGain();

    <span class="comment">// Make connections </span>
    oneShotSound.connect(lowpass);
    lowpass.connect(panner);
    panner.connect(gainNode2);
    gainNode2.connect(compressor);

    <span class="comment">// Play 0.75 seconds from now (to play immediately pass in 0)</span>
    oneShotSound.start(context.currentTime + 0.75);
}
</code></pre>
</div>
</div>
</div>
</div>



<div id="UpMix-section" class="section">
<h2 id="UpMix">9. Channel up-mixing and down-mixing</h2>

<p class="norm">This section is normative.</p>

<img src="images/unity-gain-summing-junction.png">

<p>
<a href="#MixerGainStructure-section">Mixer Gain Structure</a>
describes how an <dfn>input</dfn> to an AudioNode can be connected from one or more <dfn>outputs</dfn>
of an AudioNode.  Each of these connections from an output represents a stream with
a specific non-zero number of channels.  An input has <em>mixing rules</em> for combining the channels
from all of the connections to it.  As a simple example, if an input is connected from a mono output and
a stereo output, then the mono connection will usually be up-mixed to stereo and summed with
the stereo connection.  But, of course, it's important to define the exact <em>mixing rules</em> for
every input to every AudioNode.  The default mixing rules for all of the inputs have been chosen so that
things "just work" without worrying too much about the details, especially in the very common
case of mono and stereo streams.  But the rules can be changed for advanced use cases, especially
multi-channel.
</p>

<p>
To define some terms, <em>up-mixing</em> refers to the process of taking a stream with a smaller
number of channels and converting it to a stream with a larger number of channels.  <em>down-mixing</em>
refers to the process of taking a stream with a larger number of channels and converting it to a stream
with a smaller number of channels.
</p>

<p>
An AudioNode input use three basic pieces of information to determine how to mix all the outputs
connected to it.  As part of this process it computes an internal value <dfn>computedNumberOfChannels</dfn>
 representing the actual number of channels of the input at any given time:
</p>

<p>
The AudioNode attributes involved in channel up-mixing and down-mixing rules are defined
<a href="#attributes-AudioNode-section">above</a>.  The following is a more precise specification
on what each of them mean.
</p>

<ul>
<li><dfn>channelCount</dfn> is used to help compute <dfn>computedNumberOfChannels</dfn>.</li>

<li><dfn>channelCountMode</dfn> determines how <dfn>computedNumberOfChannels</dfn> will be computed.
Once this number is computed, all of the connections will be up or down-mixed to that many channels.  For most nodes,
the default value is "max".
<ul>
<li>“max”: <dfn>computedNumberOfChannels</dfn> is computed as the maximum of the number of channels of all connections.
In this mode <dfn>channelCount</dfn> is ignored.</li>
<li>“clamped-max”: same as “max” up to a limit of the <dfn>channelCount</dfn></li>
<li>“explicit”: <dfn>computedNumberOfChannels</dfn> is the exact value as specified in <dfn>channelCount</dfn></li>
</ul>

</li>

<li><dfn>channelInterpretation</dfn> determines how the individual channels will be treated.
For example, will they be treated as speakers having a specific layout, or will they
be treated as simple discrete channels?  This value influences exactly how the up and down mixing is
performed.  The default value is "speakers".

<ul>
<li>“speakers”: use <a href="#ChannelLayouts">up-down-mix equations for mono/stereo/quad/5.1</a>.
In cases where the number of channels do not match any of these basic speaker layouts, revert
to "discrete".
</li>
<li>“discrete”: up-mix by filling channels until they run out then zero out remaining channels.
                  down-mix by filling as many channels as possible, then dropping remaining channels</li>
</ul>

</li>

</ul>

<p>
For each input of an AudioNode, an implementation must:
</p>

<ol>
<li>Compute <dfn>computedNumberOfChannels</dfn>.</li>
<li>For each connection to the input:
<ul>
<li> up-mix or down-mix the connection to <dfn>computedNumberOfChannels</dfn> according to <dfn>channelInterpretation</dfn>.</li>
<li> Mix it together with all of the other mixed streams (from other connections). This is a straight-forward mixing together of each of the corresponding channels from each
connection.</li>
</ul>
</li>
</ol>




<div id="ChannelLayouts-section" class="section">
<h3 id="ChannelLayouts">9.1. Speaker Channel Layouts</h3>

<p class="norm">This section is normative.</p>

<p>
When <dfn>channelInterpretation</dfn> is "speakers" then the up-mixing and down-mixing
is defined for specific channel layouts.
</p>

<p>It's important to define the channel ordering (and define some
abbreviations) for these speaker layouts.</p>

<p>
For now, only considers cases for mono, stereo, quad, 5.1. Later other channel
layouts can be defined. 
</p>

<h4 id ="ChannelOrdering">9.1.1. Channel ordering</h4>

<pre>  Mono
    0: M: mono
    
  Stereo
    0: L: left
    1: R: right
  </pre>

<pre>  Quad
    0: L:  left
    1: R:  right
    2: SL: surround left
    3: SR: surround right

  5.1
    0: L:   left
    1: R:   right
    2: C:   center
    3: LFE: subwoofer
    4: SL:  surround left
    5: SR:  surround right
  </pre>
</div>

<h4 id="UpMix-sub">9.1.2. Up Mixing speaker layouts</h4>

<pre>Mono up-mix:
    
    1 -&gt; 2 : up-mix from mono to stereo
        output.L = input;
        output.R = input;

    1 -&gt; 4 : up-mix from mono to quad
        output.L = input;
        output.R = input;
        output.SL = 0;
        output.SR = 0;

    1 -&gt; 5.1 : up-mix from mono to 5.1
        output.L = 0;
        output.R = 0;
        output.C = input; // put in center channel
        output.LFE = 0;
        output.SL = 0;
        output.SR = 0;

Stereo up-mix:

    2 -&gt; 4 : up-mix from stereo to quad
        output.L = input.L;
        output.R = input.R;
        output.SL = 0;
        output.SR = 0;

    2 -&gt; 5.1 : up-mix from stereo to 5.1
        output.L = input.L;
        output.R = input.R;
        output.C = 0;
        output.LFE = 0;
        output.SL = 0;
        output.SR = 0;

Quad up-mix:

    4 -&gt; 5.1 : up-mix from stereo to 5.1
        output.L = input.L;
        output.R = input.R;
        output.C = 0;
        output.LFE = 0;
        output.SL = input.SL;
        output.SR = input.SR;</pre>

<h4 id="down-mix">9.1.3. Down Mixing speaker layouts</h4>

<p>A down-mix will be necessary, for example, if processing 5.1 source
material, but playing back stereo. </p>
<pre>  
Mono down-mix:

    2 -&gt; 1 : stereo to mono
        output = 0.5 * (input.L + input.R);

    4 -&gt; 1 : quad to mono
        output = 0.25 * (input.L + input.R + input.SL + input.SR);

    5.1 -&gt; 1 : 5.1 to mono
        output = 0.7071 * (input.L + input.R) + input.C + 0.5 * (input.SL + input.SR)


Stereo down-mix:

    4 -&gt; 2 : quad to stereo
        output.L = 0.5 * (input.L + input.SL);
        output.R = 0.5 * (input.R + input.SR);

    5.1 -&gt; 2 : 5.1 to stereo
        output.L = L + 0.7071 * (input.C + input.SL)
        output.R = R + 0.7071 * (input.C + input.SR)

Quad down-mix:

    5.1 -&gt; 4 : 5.1 to quad
        output.L = L + 0.7071 * input.C
        output.R = R + 0.7071 * input.C
        output.SL = input.SL
        output.SR = input.SR

</pre>
</div>

<h3 id="ChannelRules-section">9.2. Channel Rules Examples</h3>

<p class="norm">This section is informative.</p>

<div class="block">
<div class="blockTitleDiv">
<div class="blockContent">
<pre class="code"><code class="idl-code"> 
// Set gain node to explicit 2-channels (stereo).
gain.channelCount = 2;
gain.channelCountMode = "explicit";
gain.channelInterpretation = "speakers";

// Set "hardware output" to 4-channels for DJ-app with two stereo output busses.
context.destination.channelCount = 4;
context.destination.channelCountMode = "explicit";
context.destination.channelInterpretation = "discrete";

// Set "hardware output" to 8-channels for custom multi-channel speaker array
// with custom matrix mixing.
context.destination.channelCount = 8;
context.destination.channelCountMode = "explicit";
context.destination.channelInterpretation = "discrete";

// Set "hardware output" to 5.1 to play an HTMLAudioElement.
context.destination.channelCount = 6;
context.destination.channelCountMode = "explicit";
context.destination.channelInterpretation = "speakers";

// Explicitly down-mix to mono.
gain.channelCount = 1;
gain.channelCountMode = "explicit";
gain.channelInterpretation = "speakers";
</code></pre>
</div>
</div>
</div>


<div id="Spatialization-section" class="section">
<h2 id="Spatialization">11. Spatialization / Panning </h2>

<h3 id="Spatialization-background">Background</h3>

<p>A common feature requirement for modern 3D games is the ability to
dynamically spatialize and move multiple audio sources in 3D space. Game audio
engines such as OpenAL, FMOD, Creative's EAX, Microsoft's XACT Audio, etc. have
this ability. </p>

<p>Using an <code>PannerNode</code>, an audio stream can be spatialized or
positioned in space relative to an <code>AudioListener</code>. An <a
href="#AudioContext-section"><code>AudioContext</code></a> will contain a
single <code>AudioListener</code>. Both panners and listeners have a position
in 3D space using a right-handed cartesian coordinate system.
The units used in the coordinate system are not defined, and do not need to be
because the effects calculated with these coordinates are independent/invariant
of any particular units such as meters or feet.  <code>PannerNode</code>
objects (representing the source stream) have an <code>orientation</code>
vector representing in which direction the sound is projecting. Additionally,
they have a <code>sound cone</code> representing how directional the sound is.
For example, the sound could be omnidirectional, in which case it would be
heard anywhere regardless of its orientation, or it can be more directional and
heard only if it is facing the listener. <code>AudioListener</code> objects
(representing a person's ears) have an <code>orientation</code> and
<code>up</code> vector representing in which direction the person is facing.
Because both the source stream and the listener can be moving, they both have a
<code>velocity</code> vector representing both the speed and direction of
movement. Taken together, these two velocities can be used to generate a
doppler shift effect which changes the pitch. </p>

<p>
During rendering, the <code>PannerNode</code> calculates an <em>azimuth</em>
and <em>elevation</em>.  These values are used internally by the implementation in
order to render the spatialization effect.  See the <a href="#Spatialization-panning-algorithm">Panning Algorithm</a> section
for details of how these values are used.
</p>

<p>
The following algorithm must be used to calculate the <em>azimuth</em>
and <em>elevation</em>:
</p>

<div class="block">
<div class="blockTitleDiv">
<div class="blockContent">
<pre class="code"><code class="es-code"> 
// Calculate the source-listener vector.
vec3 sourceListener = source.position - listener.position;

if (sourceListener.isZero()) {
    // Handle degenerate case if source and listener are at the same point.
    azimuth = 0;
    elevation = 0;
    return;
}

sourceListener.normalize();

// Align axes.
vec3 listenerFront = listener.orientation;
vec3 listenerUp = listener.up;
vec3 listenerRight = listenerFront.cross(listenerUp);
listenerRight.normalize();

vec3 listenerFrontNorm = listenerFront;
listenerFrontNorm.normalize();

vec3 up = listenerRight.cross(listenerFrontNorm);

float upProjection = sourceListener.dot(up);

vec3 projectedSource = sourceListener - upProjection * up;
projectedSource.normalize();

azimuth = 180 * acos(projectedSource.dot(listenerRight)) / PI;

// Source in front or behind the listener.
double frontBack = projectedSource.dot(listenerFrontNorm);
if (frontBack &lt; 0)
    azimuth = 360 - azimuth;

// Make azimuth relative to "front" and not "right" listener vector.
if ((azimuth >= 0) &amp;&amp; (azimuth &lt;= 270))
    azimuth = 90 - azimuth;
else
    azimuth = 450 - azimuth;

elevation = 90 - 180 * acos(sourceListener.dot(up)) / PI;

if (elevation > 90)
    elevation = 180 - elevation;
else if (elevation &lt; -90)
    elevation = -180 - elevation;
</code></pre>
</div>
</div>
</div>

<h3 id="Spatialization-panning-algorithm">Panning Algorithm</h3>

<p>
<em>mono->stereo</em> and <em>stereo->stereo</em>  panning must be supported.
<em>mono->stereo</em> processing is used when all connections to the input are mono.
Otherwise <em>stereo->stereo</em> processing is used.</p>

<p>The following algorithms must be implemented: </p>
<ul>
  <li>Equal-power (Vector-based) panning 
    <p>This is a simple and relatively inexpensive algorithm which provides
    basic, but reasonable results.  It is commonly used when panning musical sources.
    </p>
    The <em>elevation</em> value is ignored in this panning algorithm.

    <p>
    The following steps are used for processing:
    </p>
    
    <ol>

    <li>
    <p>
    The <em>azimuth</em> value is first contained to be within the range -90 &lt;= <em>azimuth</em> &lt;= +90 according to:
    </p>
    <pre>
    // Clamp azimuth to allowed range of -180 -> +180.
    azimuth = max(-180, azimuth);
    azimuth = min(180, azimuth);

    // Now wrap to range -90 -> +90.
    if (azimuth &lt; -90)
        azimuth = -180 - azimuth;
    else if (azimuth > 90)
        azimuth = 180 - azimuth;
    </pre>
    </li>
    
    <li>
    <p>
    A 0 -> 1 normalized value <em>x</em> is calculated from <em>azimuth</em> for <em>mono->stereo</em> as:
    </p>
    <pre>
    x = (azimuth + 90) / 180    
    </pre>

    <p>
    Or for <em>stereo->stereo</em> as:
    </p>
    <pre>
    if (azimuth &lt;= 0) { // from -90 -> 0
        // inputL -> outputL and "equal-power pan" inputR as in mono case
        // by transforming the "azimuth" value from -90 -> 0 degrees into the range -90 -> +90.
        x = (azimuth + 90) / 90;
    } else { // from 0 -> +90
        // inputR -> outputR and "equal-power pan" inputL as in mono case
        // by transforming the "azimuth" value from 0 -> +90 degrees into the range -90 -> +90.
        x = azimuth / 90;
    }
    </pre>
    </li>
    
    <li>
    <p>
    Left and right gain values are then calculated:
    </p>
    <pre>
    gainL = cos(0.5 * PI * x);
    gainR = sin(0.5 * PI * x);    
    </pre>
    </li>
    
    <li>
    <p>For <em>mono->stereo</em>, the output is calculated as:</p>
    <pre>
    outputL = input * gainL
    outputR = input * gainR
    </pre>
    <p>Else for <em>stereo->stereo</em>, the output is calculated as:</p>
    <pre>
    if (azimuth &lt;= 0) { // from -90 -> 0
        outputL = inputL + inputR * gainL;
        outputR = inputR * gainR;
    } else { // from 0 -> +90
        outputL = inputL * gainL;
        outputR = inputR + inputL * gainR;
    }
    </pre>
    </li>
    
    </ol>
    
    
    
  </li>
  <li><a
    href="http://en.wikipedia.org/wiki/Head-related_transfer_function">HRTF</a>
    panning (stereo only) 
    <p>This requires a set of HRTF impulse responses recorded at a variety of
    azimuths and elevations. There are a small number of open/free impulse
    responses available. The implementation requires a highly optimized
    convolution function. It is somewhat more costly than "equal-power", but
    provides a more spatialized sound. </p>
    <img alt="HRTF panner" src="images/HRTF_panner.png" /></li>
</ul>

<h3 id="Spatialization-distance-effects">Distance Effects</h3>
<p>
Sounds which are closer are louder, while sounds further away are quieter.
Exactly <em>how</em> a sound's volume changes according to distance from the listener
depends on the <em>distanceModel</em> attribute.
</p>


<p>
During audio rendering, a <em>distance</em> value will be calculated based on the panner and listener positions according to:
</p>
<pre>
v = panner.position - listener.position
</pre>
<pre>
distance = sqrt(dot(v, v))
</pre>

<p>
<em>distance</em> will then be used to calculate <em>distanceGain</em> which depends
on the <em>distanceModel</em> attribute.  See the <a href="#dfn-distanceModel">distanceModel</a> section for details of
how this is calculated for each distance model.
</p>
<p>As part of its processing, the <code>PannerNode</code> scales/multiplies the input audio signal by <em>distanceGain</em>
to make distant sounds quieter and nearer ones louder.
</p>




<h3 id="Spatialization-sound-cones">Sound Cones</h3>

<p>The listener and each sound source have an orientation vector describing
which way they are facing. Each sound source's sound projection characteristics
are described by an inner and outer "cone" describing the sound intensity as a
function of the source/listener angle from the source's orientation vector.
Thus, a sound source pointing directly at the listener will be louder than if
it is pointed off-axis. Sound sources can also be omni-directional. </p>

<p>
The following algorithm must be used to calculate the gain contribution due
to the cone effect, given the source (the <code>PannerNode</code>) and the listener:
</p>

<div class="block">
<div class="blockTitleDiv">
<div class="blockContent">
<pre class="code"><code class="idl-code"> 
if (source.orientation.isZero() || ((source.coneInnerAngle == 360) &amp;&amp; (source.coneOuterAngle == 360)))
    return 1; // no cone specified - unity gain

// Normalized source-listener vector
vec3 sourceToListener = listener.position - source.position;
sourceToListener.normalize();

vec3 normalizedSourceOrientation = source.orientation;
normalizedSourceOrientation.normalize();

// Angle between the source orientation vector and the source-listener vector
double dotProduct = sourceToListener.dot(normalizedSourceOrientation);
double angle = 180 * acos(dotProduct) / PI;
double absAngle = fabs(angle);

// Divide by 2 here since API is entire angle (not half-angle)
double absInnerAngle = fabs(source.coneInnerAngle) / 2;
double absOuterAngle = fabs(source.coneOuterAngle) / 2;
double gain = 1;

if (absAngle &lt;= absInnerAngle)
    // No attenuation
    gain = 1;
else if (absAngle &gt;= absOuterAngle)
    // Max attenuation
    gain = source.coneOuterGain;
else {
    // Between inner and outer cones
    // inner -> outer, x goes from 0 -> 1
    double x = (absAngle - absInnerAngle) / (absOuterAngle - absInnerAngle);
    gain = (1 - x) + source.coneOuterGain * x;
}

return gain;
</code></pre>
</div>
</div>
</div>

<h3 id="Spatialization-doppler-shift">Doppler Shift</h3>
<ul>
  <li>Introduces a pitch shift which can realistically simulate moving
  sources.</li>
  <li>Depends on: source / listener velocity vectors, speed of sound, doppler
    factor.</li>
</ul>

<p>
The following algorithm must be used to calculate the doppler shift value which is used
as an additional playback rate scalar for all AudioBufferSourceNodes connecting directly or
indirectly to the AudioPannerNode:
</p>

<div class="block">
<div class="blockTitleDiv">
<div class="blockContent">
<pre class="code"><code class="idl-code"> 
double dopplerShift = 1; // Initialize to default value
double dopplerFactor = listener.dopplerFactor;

if (dopplerFactor > 0) {
    double speedOfSound = listener.speedOfSound;

    // Don't bother if both source and listener have no velocity.
    if (!source.velocity.isZero() || !listener.velocity.isZero()) {
        // Calculate the source to listener vector.
        vec3 sourceToListener = source.position - listener.position;

        double sourceListenerMagnitude = sourceToListener.length();

        double listenerProjection = sourceToListener.dot(listener.velocity) / sourceListenerMagnitude;
        double sourceProjection = sourceToListener.dot(source.velocity) / sourceListenerMagnitude;

        listenerProjection = -listenerProjection;
        sourceProjection = -sourceProjection;

        double scaledSpeedOfSound = speedOfSound / dopplerFactor;
        listenerProjection = min(listenerProjection, scaledSpeedOfSound);
        sourceProjection = min(sourceProjection, scaledSpeedOfSound);

        dopplerShift = ((speedOfSound - dopplerFactor * listenerProjection) / (speedOfSound - dopplerFactor * sourceProjection));
        fixNANs(dopplerShift); // Avoid illegal values

        // Limit the pitch shifting to 4 octaves up and 3 octaves down.
        dopplerShift = min(dopplerShift, 16);
        dopplerShift = max(dopplerShift, 0.125);
    }
}
</code></pre>
</div>
</div>
</div>




</div>

<div id="Convolution-section" class="section">
<h2 id="Convolution">12. Linear Effects using Convolution</h2>

<h3 id="Convolution-background">Background</h3>

<p><a href="http://en.wikipedia.org/wiki/Convolution">Convolution</a> is a
mathematical process which can be applied to an audio signal to achieve many
interesting high-quality linear effects. Very often, the effect is used to
simulate an acoustic space such as a concert hall, cathedral, or outdoor
amphitheater. It can also be used for complex filter effects, like a muffled
sound coming from inside a closet, sound underwater, sound coming through a
telephone, or playing through a vintage speaker cabinet. This technique is very
commonly used in major motion picture and music production and is considered to
be extremely versatile and of high quality. </p>

<p>Each unique effect is defined by an <code>impulse response</code>. An
impulse response can be represented as an audio file and <a
href="#recording-impulse-responses">can be recorded</a> from a real acoustic
space such as a cave, or can be synthetically generated through a great variety
of techniques. </p>

<h3 id="Convolution-motivation">Motivation for use as a Standard</h3>

<p>A key feature of many game audio engines (OpenAL, FMOD, Creative's EAX,
Microsoft's XACT Audio, etc.) is a reverberation effect for simulating the
sound of being in an acoustic space. But the code used to generate the effect
has generally been custom and algorithmic (generally using a hand-tweaked set
of delay lines and allpass filters which feedback into each other). In nearly
all cases, not only is the implementation custom, but the code is proprietary
and closed-source, each company adding its own "black magic" to achieve its
unique quality. Each implementation being custom with a different set of
parameters makes it impossible to achieve a uniform desired effect. And the
code being proprietary makes it impossible to adopt a single one of the
implementations as a standard. Additionally, algorithmic reverberation effects
are limited to a relatively narrow range of different effects, regardless of
how the parameters are tweaked. </p>

<p>A convolution effect solves these problems by using a very precisely defined
mathematical algorithm as the basis of its processing. An impulse response
represents an exact sound effect to be applied to an audio stream and is easily
represented by an audio file which can be referenced by URL. The range of
possible effects is enormous. </p>

<h3 id="Convolution-implementation-guide">Implementation Guide</h3>
<p>
Linear convolution can be implemented efficiently.
Here are some <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/convolution.html">notes</a>
describing how it can be practically implemented.
</p>

<h3 id="Convolution-reverb-effect">Reverb Effect (with matrixing)</h3>

<p class="norm">This section is normative.</p>

<p>
In the general case the source
has N input channels, the impulse response has K channels, and the playback
system has M output channels. Thus it's a matter of how to matrix these
channels to achieve the final result.
</p>

<p>
The subset of N, M, K below must be implemented (note that the first image in the diagram is just illustrating
the general case and is not normative, while the following images are normative).
Without loss of generality, developers desiring more complex and arbitrary matrixing can use multiple <code>ConvolverNode</code>
objects in conjunction with an <code>ChannelMergerNode</code>.
</p>


<p>Single channel convolution operates on a mono audio input, using a mono
impulse response, and generating a mono output. But to achieve a more spacious sound, 2 channel audio
inputs and 1, 2, or 4 channel impulse responses will be considered. The following diagram, illustrates the
common cases for stereo playback where N and M are 1 or 2 and K is 1, 2, or 4.
</p>
<img alt="reverb matrixing" src="images/reverb-matrixing.png" /> 

<h3 id="recording-impulse-responses">Recording Impulse Responses</h3>

<p class="norm">This section is informative.</p>
<img alt="impulse response" src="images/impulse-response.png" /> <br />
<br />


<p>The most <a
href="http://pcfarina.eng.unipr.it/Public/Papers/226-AES122.pdf">modern</a> and
accurate way to record the impulse response of a real acoustic space is to use
a long exponential sine sweep. The test-tone can be as long as 20 or 30
seconds, or longer. <br />
Several recordings of the test tone played through a speaker can be made with
microphones placed and oriented at various positions in the room. It's
important to document speaker placement/orientation, the types of microphones,
their settings, placement, and orientations for each recording taken. </p>

<p>Post-processing is required for each of these recordings by performing an
inverse-convolution with the test tone, yielding the impulse response of the
room with the corresponding microphone placement. These impulse responses are
then ready to be loaded into the convolution reverb engine to re-create the
sound of being in the room. </p>

<h3 id="tools">Tools</h3>

<p>Two command-line tools have been written: <br />
<code>generate_testtones</code> generates an exponential sine-sweep test-tone
and its inverse. Another tool <code>convolve</code> was written for
post-processing. With these tools, anybody with recording equipment can record
their own impulse responses. To test the tools in practice, several recordings
were made in a warehouse space with interesting acoustics. These were later
post-processed with the command-line tools. </p>
<pre>% generate_testtones -h
Usage: generate_testtone
	[-o /Path/To/File/To/Create] Two files will be created: .tone and .inverse
	[-rate &lt;sample rate&gt;] sample rate of the generated test tones
	[-duration &lt;duration&gt;] The duration, in seconds, of the generated files
	[-min_freq &lt;min_freq&gt;] The minimum frequency, in hertz, for the sine sweep

% convolve -h
Usage: convolve input_file impulse_response_file output_file</pre>
<br />


<h3 id="recording-setup">Recording Setup</h3>
<img alt="recording setup" src="images/recording-setup.png" /> <br />
<br />
Audio Interface: Metric Halo Mobile I/O 2882 <br />
<br />
<br />
<br />
<img alt="microphones speaker" src="images/microphones-speaker.png" /> <br />
<br />
<img alt="microphone" src="images/microphone.png" /> <img alt="speaker"
src="images/speaker.png" /> <br />
<br />
Microphones: AKG 414s, Speaker: Mackie HR824 <br />
<br />
<br />


<h3 id="warehouse">The Warehouse Space</h3>
<img alt="warehouse" src="images/warehouse.png" /> <br />
<br />
</div>

<div id="JavaScriptProcessing-section" class="section">
<h2 id="JavaScriptProcessing">13. JavaScript Synthesis and Processing</h2>

<p class="norm">This section is informative.</p>

<p>The Mozilla project has conducted <a
href="https://wiki.mozilla.org/Audio_Data_API">Experiments</a> to synthesize
and process audio directly in JavaScript. This approach is interesting for a
certain class of audio processing and they have produced a number of impressive
demos. This specification includes a means of synthesizing and processing
directly using JavaScript by using a special subtype of <a
href="#AudioNode-section"><code>AudioNode</code></a> called <a
href="#ScriptProcessorNode-section"><code>ScriptProcessorNode</code></a>. </p>

<p>Here are some interesting examples where direct JavaScript processing can be
useful: </p>

<h3 id="custom-DSP-effects">Custom DSP Effects</h3>

<p>Unusual and interesting custom audio processing can be done directly in JS.
It's also a good test-bed for prototyping new algorithms. This is an extremely
rich area. </p>

<h3 id="educational-applications">Educational Applications</h3>

<p>JS processing is ideal for illustrating concepts in computer music synthesis
and processing, such as showing the de-composition of a square wave into its
harmonic components, FM synthesis techniques, etc. </p>

<h3 id="javaScript-performance">JavaScript Performance</h3>

<p>JavaScript has a variety of <a
href="#JavaScriptPerformance-section">performance issues</a> so it is not
suitable for all types of audio processing. The approach proposed in this
document includes the ability to perform computationally intensive aspects of
the audio processing (too expensive for JavaScript to compute in real-time)
such as multi-source 3D spatialization and convolution in optimized C++ code.
Both direct JavaScript processing and C++ optimized code can be combined due to
the APIs <a href="#ModularRouting-section">modular approach</a>. </p>

<div id="Performance-section" class="section">
<h2 id="Performance">15. Performance Considerations</h2>

<div id="Latency-section" class="section">
<h3 id="Latency">15.1. Latency: What it is and Why it's Important</h3>
</div>
<img alt="latency" src="images/latency.png" /> 

<p>For web applications, the time delay between mouse and keyboard events
(keydown, mousedown, etc.) and a sound being heard is important. </p>

<p>This time delay is called latency and is caused by several factors (input
device latency, internal buffering latency, DSP processing latency, output
device latency, distance of user's ears from speakers, etc.), and is
cummulative. The larger this latency is, the less satisfying the user's
experience is going to be. In the extreme, it can make musical production or
game-play impossible. At moderate levels it can affect timing and give the
impression of sounds lagging behind or the game being non-responsive. For
musical applications the timing problems affect rhythm. For gaming, the timing
problems affect precision of gameplay. For interactive applications, it
generally cheapens the users experience much in the same way that very low
animation frame-rates do. Depending on the application, a reasonable latency
can be from as low as 3-6 milliseconds to 25-50 milliseconds. </p>

<div id="Glitching-section" class="section">
<h3 id="audio-glitching">15.2. Audio Glitching</h3>
</div>

<p>Audio glitches are caused by an interruption of the normal continuous audio
stream, resulting in loud clicks and pops. It is considered to be a
catastrophic failure of a multi-media system and must be avoided. It can be
caused by problems with the threads responsible for delivering the audio stream
to the hardware, such as scheduling latencies caused by threads not having the
proper priority and time-constraints. It can also be caused by the audio DSP
trying to do more work than is possible in real-time given the CPU's speed. </p>

<h3 id="hardware-scalability">15.3. Hardware Scalability</h3>

<p>The system should gracefully degrade to allow audio processing under
resource constrained conditions without dropping audio frames. </p>

<p>First of all, it should be clear that regardless of the platform, the audio
processing load should never be enough to completely lock up the machine.
Second, the audio rendering needs to produce a clean, un-interrupted audio
stream without audible <a href="#Glitching-section">glitches</a>. </p>

<p>The system should be able to run on a range of hardware, from mobile phones
and tablet devices to laptop and desktop computers. But the more limited
compute resources on a phone device make it necessary to consider techniques to
scale back and reduce the complexity of the audio rendering. For example,
voice-dropping algorithms can be implemented to reduce the total number of
notes playing at any given time. </p>

<p>Here's a list of some techniques which can be used to limit CPU usage: </p>

<h4 id="CPU-monitoring">15.3.1. CPU monitoring</h4>

<p>In order to avoid audio breakup, CPU usage must remain below 100%. </p>

<p>The relative CPU usage can be dynamically measured for each AudioNode (and
chains of connected nodes) as a percentage of the rendering time quantum. In a
single-threaded implementation, overall CPU usage must remain below 100%. The
measured usage may be used internally in the implementation for dynamic
adjustments to the rendering. It may also be exposed through a
<code>cpuUsage</code> attribute of <code>AudioNode</code> for use by
JavaScript. </p>

<p>In cases where the measured CPU usage is near 100% (or whatever threshold is
considered too high), then an attempt to add additional <code>AudioNodes</code>
into the rendering graph can trigger voice-dropping. </p>

<h4 id="Voice-dropping">15.3.2. Voice Dropping</h4>

<p>Voice-dropping is a technique which limits the number of voices (notes)
playing at the same time to keep CPU usage within a reasonable range. There can
either be an upper threshold on the total number of voices allowed at any given
time, or CPU usage can be dynamically monitored and voices dropped when CPU
usage exceeds a threshold. Or a combination of these two techniques can be
applied. When CPU usage is monitored for each voice, it can be measured all the
way from a source node through any effect processing nodes which apply
uniquely to that voice. </p>

<p>When a voice is "dropped", it needs to happen in such a way that it doesn't
introduce audible clicks or pops into the rendered audio stream. One way to
achieve this is to quickly fade-out the rendered audio for that voice before
completely removing it from the rendering graph. </p>

<p>When it is determined that one or more voices must be dropped, there are
various strategies for picking which voice(s) to drop out of the total ensemble
of voices currently playing. Here are some of the factors which can be used in
combination to help with this decision: </p>
<ul>
  <li>Older voices, which have been playing the longest can be dropped instead
    of more recent voices. </li>
  <li>Quieter voices, which are contributing less to the overall mix may be
    dropped instead of louder ones. </li>
  <li>Voices which are consuming relatively more CPU resources may be dropped
    instead of less "expensive" voices.</li>
  <li>An AudioNode can have a <code>priority</code> attribute to help determine
    the relative importance of the voices.</li>
</ul>

<h4 id="Simplification-of-Effects-Processing">15.3.3. Simplification of Effects
Processing</h4>

<p>Most of the effects described in this document are relatively inexpensive
and will likely be able to run even on the slower mobile devices. However, the
<a href="#ConvolverNode-section">convolution effect</a> can be configured with
a variety of impulse responses, some of which will likely be too heavy for
mobile devices. Generally speaking, CPU usage scales with the length of the
impulse response and the number of channels it has. Thus, it is reasonable to
consider that impulse responses which exceed a certain length will not be
allowed to run. The exact limit can be determined based on the speed of the
device. Instead of outright rejecting convolution with these long responses, it
may be interesting to consider truncating the impulse responses to the maximum
allowed length and/or reducing the number of channels of the impulse response.
</p>

<p>In addition to the convolution effect. The <a
href="#PannerNode-section"><code>PannerNode</code></a> may also be
expensive if using the HRTF panning model. For slower devices, a cheaper
algorithm such as EQUALPOWER can be used to conserve compute resources. </p>

<h4 id="Sample-rate">15.3.4. Sample Rate</h4>

<p>For very slow devices, it may be worth considering running the rendering at
a lower sample-rate than normal. For example, the sample-rate can be reduced
from 44.1KHz to 22.05KHz. This decision must be made when the
<code>AudioContext</code> is created, because changing the sample-rate
on-the-fly can be difficult to implement and will result in audible glitching
when the transition is made. </p>

<h4 id="pre-flighting">15.3.5. Pre-flighting</h4>

<p>It should be possible to invoke some kind of "pre-flighting" code (through
JavaScript) to roughly determine the power of the machine. The JavaScript code
can then use this information to scale back any more intensive processing it
may normally run on a more powerful machine. Also, the underlying
implementation may be able to factor in this information in the voice-dropping
algorithm. </p>

<p><span class="ednote">TODO: add specification and more detail here </span></p>

<h4 id="Authoring-for-different-user-agents">15.3.6. Authoring for different
user agents</h4>
JavaScript code can use information about user-agent to scale back any more
intensive processing it may normally run on a more powerful machine. 

<h4 id="Scalability-of-Direct-JavaScript-Synthesis">15.3.7. Scalability of
Direct JavaScript Synthesis / Processing</h4>

<p>Any audio DSP / processing code done directly in JavaScript should also be
concerned about scalability. To the extent possible, the JavaScript code itself
needs to monitor CPU usage and scale back any more ambitious processing when
run on less powerful devices. If it's an "all or nothing" type of processing,
then user-agent check or pre-flighting should be done to avoid generating an
audio stream with audio breakup. </p>

<div id="JavaScriptPerformance-section" class="section">
<h3 id="JavaScriptPerformance">15.4. JavaScript Issues with real-time
Processing and Synthesis: </h3>
</div>
While processing audio in JavaScript, it is extremely challenging to get
reliable, glitch-free audio while achieving a reasonably low-latency,
especially under heavy processor load. 
<ul>
  <li>JavaScript is very much slower than heavily optimized C++ code and is not
    able to take advantage of SSE optimizations and multi-threading which is
    critical for getting good performance on today's processors. Optimized
    native code can be on the order of twenty times faster for processing FFTs
    as compared with JavaScript. It is not efficient enough for heavy-duty
    processing of audio such as convolution and 3D spatialization of large
    numbers of audio sources. </li>
  <li>setInterval() and XHR handling will steal time from the audio processing.
    In a reasonably complex game, some JavaScript resources will be needed for
    game physics and graphics. This creates challenges because audio rendering
    is deadline driven (to avoid glitches and get low enough latency).</li>
  <li>JavaScript does not run in a real-time processing thread and thus can be
    pre-empted by many other threads running on the system.</li>
  <li>Garbage Collection (and autorelease pools on Mac OS X) can cause
    unpredictable delay on a JavaScript thread. </li>
  <li>Multiple JavaScript contexts can be running on the main thread, stealing
    time from the context doing the processing. </li>
  <li>Other code (other than JavaScript) such as page rendering runs on the
    main thread. </li>
  <li>Locks can be taken and memory is allocated on the JavaScript thread. This
    can cause additional thread preemption. </li>
</ul>
The problems are even more difficult with today's generation of mobile devices
which have processors with relatively poor performance and power consumption /
battery-life issues. <br />
<br />


<div id="ExampleApplications-section" class="section">
<h2 id="ExampleApplications">16. Example Applications</h2>

<p class="norm">This section is informative.</p>

<p>Please see the <a
href="http://chromium.googlecode.com/svn/trunk/samples/audio/index.html">demo</a>
page for working examples. </p>

<p>Here are some of the types of applications a web audio system should be able
to support: </p>

<h3 id="basic-sound-playback">Basic Sound Playback</h3>

<p>Simple and <a href="#Latency-section"><strong>low-latency</strong></a>
playback of sound effects in response to simple user actions such as mouse
click, roll-over, key press. </p>
<br />


<h3 id="threeD-environmentse-and-games">3D Environments and Games</h3>
<img alt="quake" src="http://payload48.cargocollective.com/1/2/66805/3278334/redteam_680.jpg" />
<br />
<br />


<p>Electronic Arts has produced an impressive immersive game called
 <a href="http://sophie-lu.com/Strike-Fortress-EA">Strike Fortress</a>,
taking advantage of 3D spatialization and convolution for room simulation.</p>

<img alt="beach demo" src="images/beach-demo.png" />

<p>3D environments with audio are common in games made for desktop applications
and game consoles. Imagine a 3D island environment with spatialized audio,
seagulls flying overhead, the waves crashing against the shore, the crackling
of the fire, the creaking of the bridge, and the rustling of the trees in the
wind. The sounds can be positioned naturally as one moves through the scene.
Even going underwater, low-pass filters can be tweaked for just the right
underwater sound. </p>
<br />
<br />
<img alt="box2d" src="images/box2d.png" /> <img alt="8-ball"
src="images/8-ball.png" /> <br />
<br />


<p><a href="http://box2d.org/">Box2D</a> is an interesting open-source
library for 2D game physics. It has various implementations, including one
based on Canvas 2D. A demo has been created with dynamic sound effects for each
of the object collisions, taking into account the velocities vectors and
positions to spatialize the sound events, and modulate audio effect parameters
such as filter cutoff. </p>

<p>A virtual pool game with multi-sampled sound effects has also been created.
</p>
<br />


<h3 id="musical-applications">Musical Applications</h3>
<img alt="garageband" src="images/garage-band.png" /> <img
alt="shiny drum machine" src="images/shiny-drum-machine.png" /> <img
alt="tonecraft" src="images/tonecraft.png" /> <br />
<br />
Many music composition and production applications are possible. Applications
requiring tight scheduling of audio events can be implemented and can be both
educational and entertaining. Drum machines, digital DJ applications, and even
timeline-based digital music production software with some of the features of
<a href="http://en.wikipedia.org/wiki/GarageBand">GarageBand</a> can be
written. <br />
<br />


<h3 id="music-visualizers">Music Visualizers</h3>
<img alt="music visualizer" src="images/music-visualizer.png" /> <br />
<br />
When combined with WebGL GLSL shaders, realtime analysis data can be presented
in entertaining ways. These can be as advanced as any found in iTunes. <br />
<br />


<h3 id="educational-applications_2">Educational Applications</h3>
<img alt="javascript processing" src="images/javascript-processing.png" /> 

<p>A variety of educational applications can be written, illustrating concepts
in music theory and computer music synthesis and processing. </p>
<br />


<h3 id="artistic-audio-exploration">Artistic Audio Exploration</h3>

<p>There are many creative possibilites for artistic sonic environments for
installation pieces. </p>
<br />
</div>

<div id="SecurityConsiderations-section" class="section">
<h2 id="SecurityConsiderations">17. Security Considerations</h2>

<p>This section is <em>informative.</em> </p>
</div>

<div id="PrivacyConsiderations-section" class="section">
<h2 id="PrivacyConsiderations">18. Privacy Considerations</h2>

<p>This section is <em>informative</em>. When giving various information on
available AudioNodes, the Web Audio API potentially exposes information on
characteristic features of the client (such as audio hardware sample-rate) to
any page that makes use of the AudioNode interface. Additionally, timing
information can be collected through the RealtimeAnalyzerNode or
ScriptProcessorNode interface. The information could subsequently be used to
create a fingerprint of the client. </p>

<p>Currently audio input is not specified in this document, but it will involve
gaining access to the client machine's audio input or microphone. This will
require asking the user for permission in an appropriate way, probably via the
<a href="http://developers.whatwg.org/">getUserMedia()
API</a>. </p>
</div>

<div id="requirements-section" class="section">
<h2 id="requirements">19. Requirements and Use Cases</h2>

<p>Please see <a href="#ExampleApplications-section">Example Applications</a>
</p>
</div>

<div id="oldnames-section" class="section">
<h2 id="OldNames">20. Old Names</h2>

<p class="norm">This section is informative.</p>

<p>Some method and attribute names have been improved during API review.
The new names are described in the main body of this specification in the
description for each node type, etc.  Here's a description of the older names
to help content authors migrate to the latest spec.  Note that the partial
interfaces are not normative and are only descriptive: 
</p>
<blockquote>
<pre>

partial interface <dfn>AudioBufferSourceNode</dfn> {
    // Same as start()
    void noteOn(double when);
    void noteGrainOn(double when, double grainOffset, double grainDuration);
    
    // Same as stop()
    void noteOff(double when);
};

partial interface <dfn>AudioContext</dfn> {
    // Same as createGain()
    GainNode createGainNode();
    
    // Same as createDelay()
    DelayNode createDelayNode(optional double maxDelayTime = 1.0);

    // Same as createScriptProcessor()
    ScriptProcessorNode createJavaScriptNode(optional unsigned long bufferSize = 0,
                                             optional unsigned long numberOfInputChannels = 2,
                                             optional unsigned long numberOfOutputChannels = 2);
};

partial interface <dfn>OscillatorNode</dfn> {
    // Same as start()
    void noteOn(double when);
    
    // Same as stop()
    void noteOff(double when);
};

partial interface <dfn>AudioParam</dfn> {
    // Same as setTargetAtTime()
    void setTargetValueAtTime(float target, double startTime, double timeConstant);
};

</pre>
</blockquote>

<p>Some attributes taking constant values have changed during API review.
The old way used integer values, while the new way uses Web IDL string values.
</p>

<blockquote>
<pre>
// PannerNode constants for the .panningModel attribute

// Old way
const unsigned short EQUALPOWER = 0;
const unsigned short HRTF = 1;

// New way
enum <dfn>PanningModelType</dfn> {
  "equalpower",
  "HRTF"
};
</pre>
</blockquote>

<blockquote>
<pre>
// PannerNode constants for the .distanceModel attribute

// Old way
const unsigned short LINEAR_DISTANCE = 0;
const unsigned short INVERSE_DISTANCE = 1;
const unsigned short EXPONENTIAL_DISTANCE = 2;

// New way
enum <dfn>DistanceModelType</dfn> {
  "linear",
  "inverse",
  "exponential"
};
</pre>
</blockquote>



<blockquote>
<pre>
// BiquadFilterNode constants for the .type attribute

// Old way
const unsigned short LOWPASS = 0;
const unsigned short HIGHPASS = 1;
const unsigned short BANDPASS = 2;
const unsigned short LOWSHELF = 3;
const unsigned short HIGHSHELF = 4;
const unsigned short PEAKING = 5;
const unsigned short NOTCH = 6;
const unsigned short ALLPASS = 7;

// New way
enum <dfn>BiquadFilterType</dfn> {
  "lowpass",
  "highpass",
  "bandpass",
  "lowshelf",
  "highshelf",
  "peaking",
  "notch",
  "allpass"
};
</pre>
</blockquote>

<blockquote>
<pre>
// OscillatorNode constants for the .type attribute

// Old way
const unsigned short SINE = 0;
const unsigned short SQUARE = 1;
const unsigned short SAWTOOTH = 2;
const unsigned short TRIANGLE = 3;
const unsigned short CUSTOM = 4;

// New way
enum <dfn>OscillatorType</dfn> {
  "sine",
  "square",
  "sawtooth",
  "triangle",
  "custom"
};
</pre>
</blockquote>



</div>

</div>
</div>

<div class="appendix section" id="references">
<h2 id="L17310">A.References</h2>

<div class="section" id="normative-references">
<h3 id="Normative-references">A.1 Normative references</h3>
<dl>
  <dt id="DOM">[DOM] </dt>
  <dd><a href="http://dom.spec.whatwg.org/">DOM</a>,
      A. van Kesteren, A. Gregor, Ms2ger. WHATWG.</dd>
  <dt id="HTML">[HTML] </dt>
  <dd><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML</a>,
      I. Hickson. WHATWG.</dd>
  <dt id="RFC2119">[RFC2119] </dt>
    <dd>S. Bradner. <a
      href="http://www.ietf.org/rfc/rfc2119.txt"><cite><span>Key words for use
      in RFCs to Indicate Requirement Levels.</span></cite></a> Internet RFC
      2119. URL: <a
      href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>
    </dd>
</dl>
</div>

<div class="section" id="informative-references">
<h3 id="Informative-references">A.2 Informative references</h3>

<p>No informative references.</p>
</div>
</div>

<div class="section" id="acknowledgements">
<h2 id="L17335">B.Acknowledgements</h2>

<p>Special thanks to the W3C <a href="http://www.w3.org/2011/audio/">Audio
Working Group</a>. Members of the Working Group are (at the time of writing,
and by alphabetical order): <br />
Berkovitz, Joe (public Invited expert);Cardoso, Gabriel (INRIA);Carlson, Eric
(Apple, Inc.);Gregan, Matthew (Mozilla Foundation);Jägenstedt, Philip (Opera
Software);Kalliokoski, Jussi (public Invited expert);Lowis, Chris (British
Broadcasting Corporation);MacDonald, Alistair (W3C Invited Experts);Michel,
Thierry (W3C/ERCIM);Noble, Jer (Apple, Inc.);O'Callahan, Robert(Mozilla
Foundation);Paradis, Matthew (British Broadcasting Corporation);Raman, T.V.
(Google, Inc.);Rogers, Chris (Google, Inc.);Schepers, Doug (W3C/MIT);Shires,
Glen (Google, Inc.);Smith, Michael (W3C/Keio);Thereaux, Olivier (British
Broadcasting Corporation);Wei, James (Intel Corporation);Wilson, Chris (Google,
Inc.); </p>
</div>

<div class="section" id="ChangeLog-section">
<h2 id="ChangeLog">C. Web Audio API Change Log</h2>
<pre>
user:        crogers
date:        Sun Dec 09 17:13:56 2012 -0800
summary:     Basic description of OfflineAudioContext

user:        crogers
date:        Tue Dec 04 15:59:30 2012 -0800
summary:     minor correction to wording for minValue and maxValue

user:        crogers
date:        Tue Dec 04 15:49:29 2012 -0800
summary:     Bug 20161: Make decodeAudioData neuter its array buffer argument when it begins decoding a buffer, and bring it back to normal when the decoding is finished

user:        crogers
date:        Tue Dec 04 15:35:17 2012 -0800
summary:     Bug 20039: Refine description of audio decoding

user:        crogers
date:        Tue Dec 04 15:23:07 2012 -0800
summary:     elaborate on decoding steps for AudioContext createBuffer() and decodeAudioData()

user:        crogers
date:        Tue Dec 04 14:56:19 2012 -0800
summary:     Bug 19770: Note that if the last event for an AudioParam is a setCurveValue event, the computed value after that event will be equal to the latest curve value

user:        crogers
date:        Tue Dec 04 14:48:04 2012 -0800
summary:     Bug 19769: Note that before the first automation event, the computed AudioParam value will be AudioParam.value

user:        crogers
date:        Tue Dec 04 14:40:51 2012 -0800
summary:     Bug 19768: Explicitly mention that the initial value of AudioParam.value will be defaultValue

user:        crogers
date:        Tue Dec 04 14:35:59 2012 -0800
summary:     Bug 19767: Explicitly mention that the 2nd component of AudioParam.computedValue will be 0 if there are no AudioNodes connected to it

user:        crogers
date:        Tue Dec 04 14:30:08 2012 -0800
summary:     Bug 19764: Note in the spec that AudioParam.minValue/maxValue are merely informational

user:        crogers
date:        Mon Dec 03 18:03:13 2012 -0800
summary:     Convert integer constants to Web IDL enum string constants

user:        crogers
date:        Mon Dec 03 15:19:22 2012 -0800
summary:     Bug 17411: (AudioPannerNodeUnits): AudioPannerNode units are underspecified

user:        Ehsan Akhgari (Mozilla)
date:        Thu Nov 29 15:59:38 2012 -0500
summary:     Change the Web IDL description of decodeAudioData arguments

user:        crogers
date:        Wed Nov 14 13:24:01 2012 -0800
summary:     Bug 17393: (UseDoubles): float/double inconsistency

user:        crogers
date:        Wed Nov 14 13:16:57 2012 -0800
summary:     Bug 17356: (AudioListenerOrientation): AudioListener.setOrientation vectors

user:        crogers
date:        Wed Nov 14 12:56:06 2012 -0800
summary:     Bug 19957: PannerNode.coneGain is unused

user:        crogers
date:        Wed Nov 14 12:40:46 2012 -0800
summary:     Bug 17412: AudioPannerNodeVectorNormalization): AudioPannerNode orientation normalization unspecified

user:        crogers
date:        Wed Nov 14 12:16:41 2012 -0800
summary:     Bug 17411: (AudioPannerNodeUnits): AudioPannerNode units are underspecified

user:        crogers
date:        Tue Nov 13 16:14:22 2012 -0800
summary:     be more explicit about maxDelayTime units

user:        crogers
date:        Tue Nov 13 16:02:50 2012 -0800
summary:     Bug 19766: Clarify that reading AudioParam.computedValue will return the latest computed value for the latest audio quantum

user:        crogers
date:        Tue Nov 13 15:47:25 2012 -0800
summary:     Bug 19872: Should specify the defaults for PannerNode's position, ...

user:        crogers
date:        Tue Nov 13 15:27:53 2012 -0800
summary:     Bug 17390: (Joe Berkovitz): Loop start/stop points

user:        croger
date:        Tue Nov 13 14:49:20 2012 -0800
summary:     Bug 19765: Note that setting AudioParam.value will be ignored when any automation events have been set on the object

user:        crogers
date:        Tue Nov 13 14:39:07 2012 -0800
summary:     Bug 19873: Clarify PannerNode.listener

user:        crogers
date:        Tue Nov 13 13:35:21 2012 -0800
summary:     Bug 19900: Clarify the default values for the AudioParam attributes of BiquadFilterNode

user:        crogers
date:        Tue Nov 13 13:06:38 2012 -0800
summary:     Bug 19884: Specify the default value and ranges for the DynamicsCompressorNode AudioParam members

user:        crogers
date:        Tue Nov 13 12:57:02 2012 -0800
summary:     Bug 19910: Disallow AudioContext.createDelay(max) where max &lt;= 0

user:        crogers
date:        Mon Nov 12 12:02:18 2012 -0800
summary:     Add example code for more complex example

user:        Ehsan Akhgari (Mozilla)
date:        Thu Nov 01 11:32:39 2012 -0400
summary:     Specify the default value for the AudioContext.createDelay() optional argument in Web IDL

user:        Ehsan Akhgari (Mozilla)
date:        Tue Oct 30 20:29:48 2012 -0400
summary:     Mark the AudioParam members as readonly

user:        Ehsan Akhgari (Mozilla)
date:        Tue Oct 30 20:24:52 2012 -0400
summary:     Make GainNode and DelayNode valid Web IDL

user:        crogers
date:        Mon Oct 29 14:29:23 2012 -0700
summary:     consolidate AudioBufferSourceNode start() method

user:        crogers
date:        Fri Oct 19 15:15:28 2012 -0700
summary:     Bug 18332: Node creation method naming inconsistencies

user:        crogers
date:        Mon Oct 15 17:22:54 2012 -0700
summary:     Bug 17407: Interface naming inconsistency

user:        crogers
date:        Tue Oct 09 17:21:19 2012 -0700
summary:     Bug 17369: Oscillator.detune attribute not defined

user:        crogers
date:        Tue Oct 09 16:08:50 2012 -0700
summary:     Bug 17346: HTMLMediaElement integration

user:        crogers
date:        Tue Oct 09 15:20:50 2012 -0700
summary:     Bug 17354: AudioListener default position, orientation and velocity

user:        crogers
date:        Tue Oct 09 15:02:04 2012 -0700
summary:     Bug 17795: Behavior of multiple connections to same node needs to be explicitly defined

user:        crogers
date:        Mon Oct 08 13:18:45 2012 -0700
summary:     Add missing AudioContext.createWaveShaper() method

user:        crogers
date:        Fri Oct 05 18:13:44 2012 -0700
summary:     Bug 17399: AudioParam sampling is undefined

user:        crogers
date:        Fri Oct 05 17:41:52 2012 -0700
summary:     Bug 17386: Realtime Analysis empty section

user:        crogers
date:        Fri Oct 05 17:38:14 2012 -0700
summary:     minor tweak to down-mix section

user:        crogers
date:        Fri Oct 05 17:35:05 2012 -0700
summary:     Bug 17380: Channel down mixing incomplete

user:        crogers
date:        Fri Oct 05 15:40:57 2012 -0700
summary:     Bug 17375: MixerGainStructure should be marked as informative

user:        crogers
date:        Fri Oct 05 14:29:20 2012 -0700
summary:     Bug 17381: (EventScheduling): Event Scheduling ('Need more detail here')

user:        crogers
date:        Fri Oct 05 13:12:46 2012 -0700
summary:     Fix 18663: Need a method to get a readonly reading of the combined value when using AudioParam automation curve

user:        crogers
date:        Fri Oct 05 12:48:36 2012 -0700
summary:     Fix 18662: Setting audioparam value while there is an automation curve will cancel that automation curve and set value immediately

user:        crogers
date:        Fri Oct 05 12:26:28 2012 -0700
summary:     Fix 18661: Use startTime / endTime parameter names for AudioParam automation methods

user:        crogers
date:        Wed Oct 03 12:26:39 2012 -0700
summary:     Specify default value for .distanceModel

user:        crogers
date:        Tue Oct 02 12:33:36 2012 -0700
summary:     Fix Issues 17338 and 17337: AudioGain interface is not needed (Part 2)

user:        crogers
date:        Tue Oct 02 12:28:55 2012 -0700
summary:     Fix Issues 17338 and 17337: AudioGain interface is not needed

user:        Ehsan Akhgari (Mozilla)
date:        Wed Sep 26 18:22:36 2012 -0400
summary:     Make AudioBufferSourceNode.buffer nullable

user:        crogers
date:        Tue Sep 25 12:56:14 2012 -0700
summary:     noteOn/noteOff changed to start/stop -- added deprecation notes

user:        Ehsan Akhgari (Mozilla)
date:        Fri Aug 24 18:27:29 2012 -0400
summary:     Make the AudioContext object have a constructor

user:        Ehsan Akhgari (Mozilla)
date:        Fri Aug 24 15:54:10 2012 -0400
summary:     Denote IDL definitions as Web IDL

user:        Ehsan Akhgari (Mozilla)
date:        Fri Aug 24 15:04:37 2012 -0400
summary:     Use `long` instead of `int`, since the int type doesn't exist in Web IDL

user:        Ehsan Akhgari (Mozilla)
date:        Fri Aug 24 15:02:43 2012 -0400
summary:     Add a missing attribute keyword in AudioProcessingEvent

user:        Ehsan Akhgari (Mozilla)
date:        Tue Aug 21 15:36:48 2012 -0400
summary:     Remove the 'raises' notation from the IDLs

user:        crogers
date:        Thu Aug 16 16:30:55 2012 -0700
summary:     Issue 17398: Add more detailed information about how AudioParam value is calculated

user:        crogers
date:        Thu Aug 16 15:21:38 2012 -0700
summary:     another try with the style sheet

user:        crogers
date:        Thu Aug 16 14:53:54 2012 -0700
summary:     use local style sheet to avoid https errors

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 23:05:49 2012 -0400
summary:     Replace the white-space based indentation of Web IDL code with a CSS-based one

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:56:03 2012 -0400
summary:     Remove more useless trailing whitespaces

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:47:21 2012 -0400
summary:     Remove the optional 'in' keyword from the Web IDL method declarations

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:42:03 2012 -0400
summary:     Add trailing semicolons for Web IDL interface declarations

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:37:32 2012 -0400
summary:     Remove useless trailing spaces

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:35:33 2012 -0400
summary:     Use the correct Web IDL notation for the AudioBufferCallback callback type

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:28:37 2012 -0400
summary:     Remove the extra semicolon in the IDL file for AudioContext

user:        Ehsan Akhgari (Mozilla)
date:        Wed Aug 15 22:24:02 2012 -0400
summary:     Replace the old [Optional] IDL tag with the Web IDL optional keyword

user:        Ehsan Akhgari (Mozilla)
date:        Tue Aug 14 10:18:19 2012 -0400
summary:     Empty changeset to test my commit access

date:        Mon Aug 13 13:26:52 2012 -0700
* Integrate Thierry Michel's 3rd public working draft edits

date:        Tue Jun 26 15:56:31 2012 -0700
* add MediaStreamAudioSourceNode

date:        Mon Jun 18 13:26:21 2012 -0700
* minor formatting fix

date:        Mon Jun 18 13:19:34 2012 -0700
* Add details for azimuth/elevation calculation

date:        Fri Jun 15 17:35:27 2012 -0700
* Add equal-power-panning details

date:        Thu Jun 14 17:31:16 2012 -0700
* Add equations for distance models

date:        Wed Jun 13 17:40:49 2012 -0700
* Bug 17334: Add precise equations for AudioParam.setTargetValueAtTime()

date:        Fri Jun 08 17:44:26 2012 -0700
* fix small typo

date:        Fri Jun 08 16:54:04 2012 -0700
* Bug 17413: AudioBuffers' relationship to AudioContext

date:        Fri Jun 08 16:05:45 2012 -0700
* Bug 17359: Add much more detail about ConvolverNode

date:        Fri Jun 08 12:59:29 2012 -0700
* minor formatting fix

date:        Fri Jun 08 12:57:11 2012 -0700
* Bug 17335: Add much more technical detail to setValueCurveAtTime()

date:        Wed Jun 06 16:34:43 2012 -0700
*Add much more detail about parameter automation, including an example

date:        Mon Jun 04 17:25:08 2012 -0700
* ISSUE-85: OscillatorNode folding considerations

date:        Mon Jun 04 17:02:20 2012 -0700
* ISSUE-45: AudioGain scale underdefined

date:        Mon Jun 04 16:40:43 2012 -0700
* ISSUE-41: AudioNode as input to AudioParam underdefined

date:        Mon Jun 04 16:14:48 2012 -0700
* ISSUE-20: Relationship to currentTime

date:        Mon Jun 04 15:48:49 2012 -0700
* ISSUE-94: Dynamic Lifetime

date:        Mon Jun 04 13:59:31 2012 -0700
* ISSUE-42: add more detail about AudioParam sampling and block processing

date:        Mon Jun 04 12:28:48 2012 -0700
* fix typo - minor edits

date:        Thu May 24 18:01:20 2012 -0700
* ISSUE-69: add implementors guide for linear convolution

date:        Thu May 24 17:35:45 2012 -0700
* ISSUE-49: better define AudioBuffer audio data access

date:        Thu May 24 17:15:29 2012 -0700
* fix small typo

date:        Thu May 24 17:13:34 2012 -0700
* ISSUE-24: define circular routing behavior

date:        Thu May 24 16:35:24 2012 -0700
* ISSUE-42: specify a-rate or k-rate for each AudioParam

date:        Fri May 18 17:01:36 2012 -0700
* ISSUE-53: noteOn and noteOff interaction

date:        Fri May 18 16:33:29 2012 -0700
* ISSUE-34: Remove .name attribute from AudioParam

date:        Fri May 18 16:27:19 2012 -0700
* ISSUE-33: Add maxNumberOfChannels attribute to AudioDestinationNode

date:        Fri May 18 15:50:08 2012 -0700
* ISSUE-19: added more info about AudioBuffer - IEEE 32-bit

date:        Fri May 18 15:37:27 2012 -0700
* ISSUE-29: remove reference to webkitAudioContext

date:        Fri Apr 27 12:36:54 2012 -0700
* fix two small typos reported by James Wei

date:        Tue Apr 24 12:27:11 2012 -0700
* small cleanup to ChannelSplitterNode and ChannelMergerNode

date:        Tue Apr 17 11:35:56 2012 -0700
* small fix to createWaveTable()

date:        Tue Apr 13 2012
* Cleanup AudioNode connect() and disconnect() method descriptions.
* Add AudioNode connect() to AudioParam method.

date:        Tue Apr 13 2012
* Add OscillatorNode and WaveTable
* Define default values for optional arguments in createJavaScriptNode(), createChannelSplitter(), createChannelMerger()
* Define default filter type for BiquadFilterNode as LOWPASS

date:        Tue Apr 11 2012
* add AudioContext .activeSourceCount attribute
* createBuffer() methods can throw exceptions
* add AudioContext method createMediaElementSource()
* update AudioContext methods createJavaScriptNode() (clean up description of parameters)
* update AudioContext method createChannelSplitter() (add numberOfOutputs parameter)
* update AudioContext method createChannelMerger() (add numberOfInputs parameter)
* update description of out-of-bounds AudioParam values (exception will not be thrown)
* remove AudioBuffer .gain attribute
* remove AudioBufferSourceNode .gain attribute
* remove AudioListener .gain attribute
* add AudioBufferSourceNode .playbackState attribute and state constants
* AnalyserNode no longer requires its output be connected to anything
* update ChannelMergerNode section describing numberOfOutputs (defaults to 6 but settable in constructor)
* update ChannelSplitterNode section describing numberOfInputs (defaults to 6 but settable in constructor)
* add note in Spatialization sections about potential to get arbitrary convolution matrixing

date:        Tue Apr 10 2012
* Rebased editor's draft document based on edits from Thierry Michel (from 2nd public working draft).

date:        Tue Mar 13 12:13:41 2012 -0100
*  fixed all the HTML errors
*  added ids to all Headings
*  added alt attribute to all img
*  fix broken anchors
*  added a new status of this document section
*  added mandatory spec headers
*  generated a new table of content
*  added a Reference section
*  added an Acknowledgments section
*  added a Web Audio API Change Log 

date:        Fri Mar 09 15:12:42 2012 -0800
* add optional maxDelayTime argument to createDelay()
* add more detail about playback state to AudioBufferSourceNode
* upgrade noteOn(), noteGrainOn(), noteOff() times to double from float

date:        Mon Feb 06 16:52:39 2012 -0800
* Cleanup ScriptProcessorNode section
* Add distance model constants for PannerNode according to the OpenAL spec
* Add .normalize attribute to ConvolverNode
* Add getFrequencyResponse() method to BiquadFilterNode
* Tighten up the up-mix equations

date:        Fri Nov 04 15:40:58 2011 -0700
summary:     Add more technical detail to BiquadFilterNode description (contributed by Raymond Toy)

date:        Sat Oct 15 19:08:15 2011 -0700
summary:     small edits to the introduction

date:        Sat Oct 15 19:00:15 2011 -0700
summary:     initial commit

date:        Tue Sep 13 12:49:11 2011 -0700
summary:     add convolution reverb design document

date:        Mon Aug 29 17:05:58 2011 -0700
summary:     document the decodeAudioData() method

date:        Mon Aug 22 14:36:33 2011 -0700
summary:     fix broken MediaElementAudioSourceNode link

date:        Mon Aug 22 14:33:57 2011 -0700
summary:     refine section describing integration with HTMLMediaElement

date:        Mon Aug 01 12:05:53 2011 -0700
summary:     add Privacy section

date:        Mon Jul 18 17:53:50 2011 -0700
summary:     small update - tweak musical applications thumbnail images

date:        Mon Jul 18 17:23:00 2011 -0700
summary:     initial commit of Web Audio API specification</pre>
</div>
</body>
</html>