-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
100 lines (84 loc) · 2.65 KB
/
index.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
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
<html>
<head>
<title>wahsp session</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-json.js"></script>
<script type="text/javascript" src="js/kansas-comet.js"></script>
</head>
<body>
<div id="no-debug-log"></div>
<script type="text/javascript">
// You only really need one audio context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var sounds = [];
function Value(params) {
return function(u) {
$.kc.reply(u,params.value);
}
}
function DefaultValue(params) {
return function(u) {
$.kc.reply(u,params.defaultValue);
}
}
function MaxValue(params) {
return function(u) {
$.kc.reply(u,params.maxValue);
}
}
function MinValue(params) {
return function(u) {
$.kc.reply(u,params.minValue);
}
}
function GetCurrentTime() {
return function(u) {
$.kc.reply(u,audioCtx.currentTime);
}
}
// create a gain node and store it in sounds[]
function CreateGain(val) {
return function(u) {
var gainNode = audioCtx.createGain();
gainNode.gain.value = val;
var count = sounds.push(gainNode);
// send back to wahsp
$.kc.reply(u,[count - 1,"AudioParam Gain " + (count - 1).toString(),
gainNode.numberOfInputs,
gainNode.numberOfOutputs, gainNode.channelCount,
gainNode.channelCountMode, gainNode.channelInterpretation
]);
}
}
// create an oscillator node and store it in sounds[]
function CreateOscillator(freq,det,osctype) {
return function(u) {
var osc = audioCtx.createOscillator();
osc.frequency.value = freq;
osc.detune.value = det;
osc.type = osctype;
var count = sounds.push(osc);
var freqParam = "AudioParam Frequency " + (count - 1).toString();
var detParam = "AudioParam Detune " + (count - 1).toString();
// send back to wahsp
$.kc.reply(u,[count - 1, freqParam, detParam ,osc.type,
osc.numberOfInputs, osc.numberOfOutputs, osc.channelCount,
osc.channelCountMode, osc.channelInterpretation
]);
}
}
$(document).ready(function() {
$.kc.connect("/example");
/*
$("button").button();
$( "#slider" ).slider({
range: "min",
value: 0,
min: 0,
max: 25
});
*/
});
</script>
</body>
</html>