-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinnercircle.html
95 lines (72 loc) · 2.37 KB
/
innercircle.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<!-- page content -->
<canvas id="my-inner" width="300" height="300" ></canvas>
<canvas id="my-inner2" width="300" height="300" ></canvas>
<a href="/chakra-shower/innercircle480.html">link 480</a>
<a href="url">link text</a>
<a href="url">link text</a>
<a href="url">link text</a>
<canvas id="my-inner3" width="300" height="300" ></canvas>
<canvas id="my-inner4" width="300" height="300" ></canvas>
</body>
<script>
const canvas = document.getElementById('my-inner');
const canvasCtx = canvas.getContext('2d');
const WIDTH = 300;
const HEIGHT = 300;
var audioCtx = new(window.AudioContext || window.webkitAudioContext());
// create Oscillator node
const oscillator = audioCtx.createOscillator();
oscillator.type = 'sinus';
oscillator.frequency.setValueAtTime(448, audioCtx.currentTime); // value in hertz
oscillator.connect(audioCtx.destination);
let osc = audioCtx.createOscillator();
osc.type = 'sinus';
osc.frequency.value = 432;
let amp = audioCtx.createGain();
amp.gain.value = 1;
let lfo = audioCtx.createOscillator();
lfo.type = 'sinus';
lfo.frequency.value = 0.1;
lfo.connect(amp.gain);
osc.connect(amp).connect(audioCtx.destination);
lfo.start();
osc.start();
var analyser = audioCtx.createAnalyser();
source = lfo;
source.connect(analyser);
analyser.fftSize = 2048;
var bufferLength = analyser.frequencyBinCount;
var dataArray = new Uint8Array(bufferLength);
canvasCtx.clearRect(0, 0, WIDTH, HEIGHT);
function draw() {
var drawVisual = requestAnimationFrame(draw);
analyser.getByteTimeDomainData(dataArray);
canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
canvasCtx.lineWidth = 2;
canvasCtx.strokeStyle = 'rgb(100, 0, 0)';
canvasCtx.beginPath();
var sliceWidth = WIDTH * 20.0 / bufferLength;
var x = 0;
var max_value = 0;
for (var i = 0; i < bufferLength; i++) {
if (dataArray[i] > max_value) {
max_value = dataArray[i];
}
x += sliceWidth;
}
canvasCtx.arc(WIDTH / 2, HEIGHT / 2, Math.abs(Math.floor(((max_value / 255) * (HEIGHT-3) / 2))), 0, 2*Math.PI);
// canvasCtx.fillStyle = 'rgb('+ Math.min(255,max_value) + ',0, 0)';
canvasCtx.fillStyle = 'hsl(0, 100%, '+((Math.min(255,max_value))*55/255)+'%)';
/* canvasCtx.lineTo(canvas.width, canvas.height / 2) ;*/
canvasCtx.stroke();
}
draw();
</script>
</html>