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:
969 bytes
|
Line | |
---|
1 | <!DOCTYPE html>
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <script src="../sink.js"></script>
|
---|
5 | <script>
|
---|
6 | (function(){
|
---|
7 |
|
---|
8 | var sampleRate, phase = 0, lfo = 0, lfo2 = 0;
|
---|
9 |
|
---|
10 | window.onload = function(){
|
---|
11 | Sink.singleton().on('audioprocess', function(buffer, channelCount){
|
---|
12 | var i, n;
|
---|
13 | for (i=0; i<buffer.length; i+=channelCount){
|
---|
14 | phase = (phase + 440 / sampleRate / 2) % 1;
|
---|
15 | for (n=0; n<channelCount; n++){
|
---|
16 | buffer[i+n] += Math.sin(phase * Math.PI * 2) * 0.5;
|
---|
17 | }
|
---|
18 | }
|
---|
19 | });
|
---|
20 |
|
---|
21 | Sink.singleton().on('audioprocess', function(buffer, channelCount){
|
---|
22 | var i, n;
|
---|
23 | for (i=0; i<buffer.length; i+=channelCount){
|
---|
24 | lfo2 = (lfo2 + 0.1 / sampleRate / 2) % 1;
|
---|
25 | lfo = (lfo + (Math.sin(lfo2 * Math.PI * 2) + 2) * 111 / sampleRate / 2) % 1;
|
---|
26 | for (n=0; n<channelCount; n++){
|
---|
27 | buffer[i+n] *= Math.sin(lfo * Math.PI * 2);
|
---|
28 | }
|
---|
29 | }
|
---|
30 | });
|
---|
31 |
|
---|
32 | sampleRate = Sink.singleton().sampleRate;
|
---|
33 |
|
---|
34 | Sink.singleton().on('error', function(e){
|
---|
35 | console.error(e);
|
---|
36 | });
|
---|
37 | };
|
---|
38 |
|
---|
39 | }());
|
---|
40 |
|
---|
41 | </script>
|
---|
42 | </head>
|
---|
43 | <body>
|
---|
44 | </body>
|
---|
45 | </html>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.