-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.html
47 lines (34 loc) · 1.23 KB
/
example.html
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
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.11.0.min.js"></script>
<script src='lib/frequenciesextractor.js'></script>
<script src='lib/notesfrequencies.js'></script>
<script src='tuner.js'></script>
<title>tuner.js example</title>
</head>
<body>
<script>
// NOTE: In Chrome this doesn't work accessing the file directly, you need a server.
window.AudioContext = window.AudioContext ||
window.webkitAudioContext;
navigator.getMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
var audioContext = new AudioContext();
var gotStreamCallback = function gotStreamCallbackFunction(mediaStream) {
var microphoneSource = audioContext.createMediaStreamSource(mediaStream);
var tuner = new Tuner(microphoneSource, audioContext.destination, audioContext);
tuner.start(function(note) {
$('#note').text(note);
});
};
var errorCallback = function errorCallbackFunction(error) {
console.log(error);
};
navigator.getMedia({audio: true}, gotStreamCallback, errorCallback);
</script>
Note: <p id="note"> </p>
</body>
</html>