-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (56 loc) · 1.95 KB
/
Copy pathscript.js
File metadata and controls
72 lines (56 loc) · 1.95 KB
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
(function(){
"use strict";
var loop1, loop2, loop3, loop4;
loop1 = document.getElementById("loop1");
loop2 = document.getElementById("loop2");
loop3 = document.getElementById("loop3");
loop4 = document.getElementById("loop4");
var audioBuffer;
var sourceNode;
var javascriptNode;
var analyser;
var analyser2;
var particlePoint;
var mediaStreamSource;
var context;
try {
// Fix up for prefixing
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
}
catch(e) {
alert('Web Audio API is not supported in this browser');
}
setupAudioNodes();
function setupAudioNodes() {
// setup a javascript node
javascriptNode = context.createJavaScriptNode(256, 0, 1);
// connect to destination, else it isn't called
javascriptNode.connect(context.destination);
// setup a analyzer
analyser = context.createAnalyser();
// analyser.smoothingTimeConstant = 0.3;
analyser.fftSize = 1024;
// create a buffer source node
sourceNode = context.createBufferSource();
sourceNode.connect(analyser);
analyser.connect(javascriptNode);
// and connect to destination
sourceNode.connect(context.destination);
}
// success callback when requesting audio input stream
function gotStream(stream) {
// Create an AudioNode from the stream.
mediaStreamSource = context.createMediaStreamSource(stream);
// Connect it to the destination to hear yourself (or any other node for processing!)
// mediaStreamSource.connect(context.destination );
mediaStreamSource.connect(analyser);
process();
}
navigator.webkitGetUserMedia( {audio:true}, gotStream );
function process(){
javascriptNode.onaudioprocess = window.audioProcess = function() {
console.log("hi")
}
}
}())