source: gs3-extensions/web-audio/trunk/js-mad/sink.js-master/tests/proxy.html@ 28388

Last change on this file since 28388 was 28388, checked in by davidb, 11 years ago

Set of JS, CSS, PNG etc web resources to support a mixture of audio player/document display capabilities

File size: 899 bytes
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3 <head>
4 <script src="../../script/require.js"></script>
5 <script src="../sink.js"></script>
6 <script>
7(function(){
8
9var bufferSize = 4096,
10 iterations = 0,
11 maxIterations = 10,
12 test = null,
13 dev, proxy;
14
15window.onload = function(){
16 dev = Sink();
17 proxy = dev.createProxy()
18 proxy.on('audioprocess', function callback(buffer){
19 if (test !== null) {
20 dev.kill();
21 return;
22 }
23
24 if (buffer.length === bufferSize) {
25 if (iterations++ > 10) {
26 test = true;
27 }
28 } else {
29 test = false;
30 }
31
32 test !== null && console.error(test ? 'Test succesful' : 'Test failed');
33
34 for (var i=0; i<buffer.length; i++){
35 buffer[i] = (Math.random() - 0.5) * 0.5;
36 }
37 });
38
39 dev.on('error', function(e){
40 console.error(e);
41 });
42};
43
44}());
45
46 </script>
47 </head>
48 <body>
49 </body>
50</html>
Note: See TracBrowser for help on using the repository browser.