-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
150 lines (115 loc) · 3.77 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<html>
<head>
<meta charset="UTF-8">
<title>Minor Blues Pentatonic Just Intonation Keyboard</title>
<style>
body {
font-family: Georgia, serif;
margin: 0;
height: 100vh;
}
#tonality-input {width: 6em;}
#output-volume {
position: absolute;
bottom: 0px;
left: 0px;
transform: rotate(-90deg);
width: 50vh;
transform-origin: 0px 0px 0px;
}
#canvas {
width: 100vw;
height: 100vh;
background: rgb( 38, 50, 56 );
}
#frequency-pad {
position: absolute;
bottom: 0;
right: 0;
}
#frequency-pad sup {margin-right: -1ex;}
#frequency-pad td {
color: rgb( 128, 203, 196 );
width: 2em;
height: 3em;
padding: 0.6em;
text-align: center;
}
#frequency-pad tr:nth-child(2), #frequency-pad tr:nth-last-child(2) {opacity: .5;}
#frequency-pad td:nth-child(2), #frequency-pad td:nth-last-child(2) {opacity: .5;}
</style>
</head>
<body>
<table id="frequency-pad"></table>
<canvas id="canvas" width="100vw"></canvas>
<input type="range" id="output-volume"/>
<script>
const context = new (window.AudioContext || window.webkitAudioContext)();
context.masterOut = context.createGain();
context.masterOut.gain.value = 1.3;
context.masterOut.connect(context.destination);
</script>
<script type="text/javascript" src="keyboard.js"></script>
<script type="text/javascript" src="key.js"></script>
<script type="text/javascript" src="organ.js"></script>
<script type="text/javascript" src="ui.js"></script>
<script type="text/javascript" src="spectrogram.js"></script>
<script type="text/javascript" src="leslie-speaker.js"></script>
<script type="text/javascript" src="reverb.js"></script>
<script type="text/javascript" src="simple-key.js"></script>
<script type="text/javascript" src="simple-leslie-speaker.js"></script>
<script>
function initSimple() {
Organ.init();
Organ.setScale(minorBluesScale_Just2);
SimpleLeslie.init();
const gain = context.createGain();
gain.gain.value = .3;
const dummy = context.createOscillator();
dummy.frequency.value = 0;
dummy.connect(context.masterOut);
dummy.start();
Organ.output.connect(SimpleLeslie.input);
SimpleLeslie.output.connect(gain);
gain.connect(context.masterOut);
UI.setBaseNoteIndex(12);
}
function initFull() {
const analyserNode = context.createAnalyser();
window.analyserNode = analyserNode;
analyserNode.fftSize = Math.pow(2, 11); // 10-15
analyserNode.smoothingTimeConstant = .0//01;//0.0001;
const canvas = document.getElementById("canvas");
canvas.height = canvas.clientHeight;
canvas.width = canvas.clientWidth;
window.spectrogram = new Spectrogram(analyserNode, canvas);
/*
navigator.getUserMedia_ = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
navigator.getUserMedia_({audio: true}, function(stream) {
context.masterIn = context.createMediaStreamSource(stream);
context.masterIn.connect(analyserNode);
}, e => console.log(e));
*/
const dummyOscillator = context.createOscillator();
dummyOscillator.frequency.value = 0;
dummyOscillator.start();
dummyOscillator.connect(analyserNode);
context.masterOut.connect(analyserNode);
Organ.init();
Organ.setScale(minorBluesScale_Just2);
LeslieSpeaker.init();
const reverb = new SimpleReverb(context, {seconds: .25, decay: 1, reverse: 0});
Organ.output.connect(LeslieSpeaker.input);
LeslieSpeaker.output.connect(reverb.input);
LeslieSpeaker.output.connect(context.masterOut);
reverb.connect(context.masterOut)
//Organ.output.connect(reverb.input);
//LeslieSpeaker.output.connect(context.masterOut);
//reverb.output.connect(context.masterOut);
UI.setBaseNoteIndex(12);
}
window.fastMode = /\?fast/.test(location);
window.fastMode ? initSimple() : initFull();
</script>
</body>
</html>