Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1864a6a812 | |||
| f8eb38e3bf |
@@ -1,327 +1,323 @@
|
|||||||
<?php
|
<?php
|
||||||
$title = "MausSynth Lab";
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/Berlin');
|
||||||
|
|
||||||
|
$now = new DateTimeImmutable('now');
|
||||||
|
$dayOfYear = (int) $now->format('z') + 1;
|
||||||
|
$weekOfYear = (int) $now->format('W');
|
||||||
|
$swatchBeats = (int) floor((($now->getTimestamp() % 86400) / 86.4));
|
||||||
|
$moonPhase = (int) floor((($now->getTimestamp() / 2551443) - floor($now->getTimestamp() / 2551443)) * 100);
|
||||||
|
|
||||||
|
$worldCities = [
|
||||||
|
['label' => 'Berlin', 'zone' => 'Europe/Berlin'],
|
||||||
|
['label' => 'Tokyo', 'zone' => 'Asia/Tokyo'],
|
||||||
|
['label' => 'San Francisco', 'zone' => 'America/Los_Angeles'],
|
||||||
|
['label' => 'São Paulo', 'zone' => 'America/Sao_Paulo'],
|
||||||
|
['label' => 'Kapstadt', 'zone' => 'Africa/Johannesburg'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$worldTimes = array_map(
|
||||||
|
static function (array $city): array {
|
||||||
|
$dt = new DateTimeImmutable('now', new DateTimeZone($city['zone']));
|
||||||
|
return [
|
||||||
|
'label' => $city['label'],
|
||||||
|
'time' => $dt->format('H:i'),
|
||||||
|
'date' => $dt->format('d.m.Y'),
|
||||||
|
'weekday' => $dt->format('l'),
|
||||||
|
'offset' => $dt->format('P'),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
$worldCities
|
||||||
|
);
|
||||||
|
|
||||||
|
$timeline = [];
|
||||||
|
for ($i = 1; $i <= 5; $i++) {
|
||||||
|
$future = $now->modify('+' . $i * 37 . ' minutes');
|
||||||
|
$timeline[] = [
|
||||||
|
'label' => "+" . $i * 37 . " min",
|
||||||
|
'time' => $future->format('H:i'),
|
||||||
|
'micro' => $future->format('s.u'),
|
||||||
|
'iso' => $future->format(DateTimeInterface::ATOM),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$startMillis = (int) round(((float) $now->format('U.u')) * 1000);
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></title>
|
<title>Hypermodern Temporal Hub</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=IBM+Plex+Mono:wght@400;600&display=swap" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--bg: radial-gradient(circle at center, #1f014d 0%, #05010d 100%);
|
color-scheme: dark;
|
||||||
--accent: #ff2bd7;
|
--bg: radial-gradient(circle at 20% 20%, #1d1646 0%, #05000f 60%, #020203 100%);
|
||||||
--glow: rgba(255, 43, 215, 0.35);
|
--card: rgba(13, 6, 30, 0.8);
|
||||||
--text: #f7f3ff;
|
--stroke: rgba(255, 255, 255, 0.12);
|
||||||
|
--glow: #74f9ff;
|
||||||
|
--accent: #ff43c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
cursor: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Orbitron', 'Segoe UI', sans-serif;
|
font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
|
||||||
color: var(--text);
|
min-height: 100vh;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
height: 100vh;
|
color: #f5f5ff;
|
||||||
overflow: hidden;
|
padding: clamp(1rem, 3vw, 4rem);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
gap: 2rem;
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
header h1 {
|
||||||
font-weight: 600;
|
font-size: clamp(2.2rem, 4vw, 3.8rem);
|
||||||
letter-spacing: 0.2em;
|
margin: 0 0 0.3rem;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin-bottom: 0.5rem;
|
letter-spacing: 0.1em;
|
||||||
text-shadow: 0 0 8px var(--accent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.description {
|
header p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
opacity: 0.7;
|
max-width: 520px;
|
||||||
letter-spacing: 0.08em;
|
color: rgba(255, 255, 255, 0.75);
|
||||||
text-align: center;
|
font-size: 1rem;
|
||||||
max-width: 420px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.stage {
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||||
|
gap: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: var(--card);
|
||||||
|
border: 1px solid var(--stroke);
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 1.5rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: min(90vw, 900px);
|
|
||||||
height: min(70vh, 520px);
|
|
||||||
border-radius: 24px;
|
|
||||||
border: 2px solid rgba(255, 255, 255, 0.15);
|
|
||||||
background: rgba(10, 5, 25, 0.7);
|
|
||||||
backdrop-filter: blur(6px);
|
|
||||||
box-shadow: 0 0 30px rgba(5, 0, 20, 0.7);
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas#visualizer {
|
.card::before {
|
||||||
width: 100%;
|
content: '';
|
||||||
height: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cursor {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
inset: 0;
|
||||||
left: 0;
|
background: radial-gradient(circle at top right, rgba(255,67,193,0.35), transparent 45%);
|
||||||
width: 80px;
|
opacity: 0.5;
|
||||||
height: 80px;
|
|
||||||
margin-top: -40px;
|
|
||||||
margin-left: -40px;
|
|
||||||
border-radius: 50%;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
border: 2px solid var(--accent);
|
|
||||||
box-shadow: 0 0 30px var(--accent), inset 0 0 20px var(--glow);
|
|
||||||
mix-blend-mode: screen;
|
|
||||||
transition: transform 0.1s ease-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hud {
|
.card h2 {
|
||||||
position: absolute;
|
margin: 0 0 0.8rem;
|
||||||
right: 16px;
|
font-size: 1rem;
|
||||||
bottom: 16px;
|
letter-spacing: 0.3em;
|
||||||
padding: 12px 16px;
|
font-weight: 600;
|
||||||
background: rgba(10, 5, 25, 0.8);
|
color: var(--glow);
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hud span.label {
|
.primary-time {
|
||||||
color: rgba(255,255,255,0.6);
|
font-size: clamp(3rem, 8vw, 4.5rem);
|
||||||
margin-right: 8px;
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hint {
|
.primary-date {
|
||||||
|
font-family: 'IBM Plex Mono', monospace;
|
||||||
|
color: rgba(255,255,255,0.8);
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metrics {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 1rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
font-size: 0.9rem;
|
}
|
||||||
letter-spacing: 0.05em;
|
|
||||||
opacity: 0.75;
|
.metric {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric span {
|
||||||
|
display: block;
|
||||||
|
font-family: 'IBM Plex Mono', monospace;
|
||||||
|
color: rgba(255,255,255,0.6);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric strong {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.timeline {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.timeline li {
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
border: 1px solid rgba(255,255,255,0.1);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 0.9rem;
|
||||||
|
font-family: 'IBM Plex Mono', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.timeline li span {
|
||||||
|
display: block;
|
||||||
|
color: rgba(255,255,255,0.6);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.worldtime {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.city {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-family: 'IBM Plex Mono', monospace;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.1);
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.city:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.city strong {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.city span {
|
||||||
|
color: rgba(255,255,255,0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nano-clock {
|
||||||
|
font-family: 'IBM Plex Mono', monospace;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
margin-top: 0.8rem;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: rgba(255,255,255,0.55);
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
* {
|
body {
|
||||||
cursor: default;
|
padding: 1.2rem;
|
||||||
}
|
|
||||||
|
|
||||||
.cursor {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></h1>
|
<header>
|
||||||
<p class="description">Schiebe deine Maus über das Klangfeld, um Frequenz, Filter und verrückte Modulation zu steuern. Klicke, um Beats zu triggern.</p>
|
<h1>Hypermodern Temporal Hub</h1>
|
||||||
|
<p>Ein futuristisches Datums-Dashboard, das terrestrische, kosmische und spekulative Zeitsysteme in einem einzigen, vibrierenden Interface verschmilzt.</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
<div class="stage" id="stage">
|
<section class="grid">
|
||||||
<canvas id="visualizer"></canvas>
|
<article class="card">
|
||||||
<div class="cursor" id="cursor"></div>
|
<h2>JETZT</h2>
|
||||||
<div class="hud" id="hud">
|
<div class="primary-time" id="clock" aria-live="polite"><?= htmlspecialchars($now->format('H:i:s'), ENT_QUOTES, 'UTF-8'); ?></div>
|
||||||
<div><span class="label">Freq</span><span id="freqReadout">-- Hz</span></div>
|
<div class="primary-date">Tag <?= $dayOfYear; ?> · Woche <?= $weekOfYear; ?> · ISO <?= htmlspecialchars($now->format(DateTimeInterface::ATOM), ENT_QUOTES, 'UTF-8'); ?></div>
|
||||||
<div><span class="label">Reso</span><span id="resoReadout">--</span></div>
|
<div class="nano-clock" id="nano">µ<?= $now->format('u'); ?></div>
|
||||||
<div><span class="label">Noise</span><span id="noiseReadout">--</span></div>
|
<div class="metrics">
|
||||||
|
<div class="metric">
|
||||||
|
<span>Swatch Beats</span>
|
||||||
|
<strong>@<?= str_pad((string) $swatchBeats, 3, '0', STR_PAD_LEFT); ?></strong>
|
||||||
|
</div>
|
||||||
|
<div class="metric">
|
||||||
|
<span>Gravitationsphase</span>
|
||||||
|
<strong><?= $moonPhase; ?>%</strong>
|
||||||
|
</div>
|
||||||
|
<div class="metric">
|
||||||
|
<span>Unix-Epoche</span>
|
||||||
|
<strong><?= number_format($now->getTimestamp(), 0, ',', '.'); ?></strong>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</article>
|
||||||
|
|
||||||
<p class="hint">Tipp: Halte die Maustaste gedrückt, bewege dich in Kreisen – und genieße den abgefahrenen Klangteppich!</p>
|
<article class="card">
|
||||||
|
<h2>WELTWELLEN</h2>
|
||||||
|
<div class="worldtime">
|
||||||
|
<?php foreach ($worldTimes as $city): ?>
|
||||||
|
<div class="city">
|
||||||
|
<div>
|
||||||
|
<strong><?= htmlspecialchars($city['label'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
||||||
|
<span><?= htmlspecialchars($city['weekday'], ENT_QUOTES, 'UTF-8'); ?> · <?= htmlspecialchars($city['date'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong><?= htmlspecialchars($city['time'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
||||||
|
<span><?= htmlspecialchars($city['offset'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
<script>
|
<article class="card">
|
||||||
const stage = document.getElementById('stage');
|
<h2>TEMPORAL-LINSE</h2>
|
||||||
const cursor = document.getElementById('cursor');
|
<ul class="timeline">
|
||||||
const canvas = document.getElementById('visualizer');
|
<?php foreach ($timeline as $moment): ?>
|
||||||
const ctx = canvas.getContext('2d');
|
<li>
|
||||||
const freqReadout = document.getElementById('freqReadout');
|
<span><?= htmlspecialchars($moment['label'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
const resoReadout = document.getElementById('resoReadout');
|
<strong><?= htmlspecialchars($moment['time'], ENT_QUOTES, 'UTF-8'); ?></strong>
|
||||||
const noiseReadout = document.getElementById('noiseReadout');
|
<span><?= htmlspecialchars($moment['micro'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
<span><?= htmlspecialchars($moment['iso'], ENT_QUOTES, 'UTF-8'); ?></span>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
let audioCtx;
|
<footer>
|
||||||
let masterGain;
|
Synchronisiert mit Serverzeit · Hypermodernität trifft Präzision auf <?= htmlspecialchars($now->format('d.m.Y'), ENT_QUOTES, 'UTF-8'); ?>.
|
||||||
let filter;
|
</footer>
|
||||||
let lfo;
|
|
||||||
let lfoGain;
|
|
||||||
let noise;
|
|
||||||
let noiseGain;
|
|
||||||
let compressor;
|
|
||||||
let isPressed = false;
|
|
||||||
let analyser;
|
|
||||||
let bufferLength;
|
|
||||||
let dataArray;
|
|
||||||
|
|
||||||
function setupAudio() {
|
<script>
|
||||||
if (audioCtx) return;
|
const serverMillis = <?= json_encode($startMillis, JSON_THROW_ON_ERROR); ?>;
|
||||||
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
const clientBoot = Date.now();
|
||||||
|
const drift = serverMillis - clientBoot;
|
||||||
|
const clock = document.getElementById('clock');
|
||||||
|
const nano = document.getElementById('nano');
|
||||||
|
|
||||||
const osc = audioCtx.createOscillator();
|
function pad(value, length = 2) {
|
||||||
osc.type = 'sawtooth';
|
return String(value).padStart(length, '0');
|
||||||
|
}
|
||||||
|
|
||||||
filter = audioCtx.createBiquadFilter();
|
function tick() {
|
||||||
filter.type = 'lowpass';
|
const precise = new Date(Date.now() + drift);
|
||||||
filter.frequency.value = 200;
|
const hours = pad(precise.getHours());
|
||||||
filter.Q.value = 12;
|
const minutes = pad(precise.getMinutes());
|
||||||
|
const seconds = pad(precise.getSeconds());
|
||||||
|
const millis = precise.getMilliseconds();
|
||||||
|
clock.textContent = `${hours}:${minutes}:${seconds}`;
|
||||||
|
nano.textContent = `µ${pad(millis, 3)}${String(Math.floor((millis / 1000) * 1000)).padStart(3, '0')}`;
|
||||||
|
requestAnimationFrame(tick);
|
||||||
|
}
|
||||||
|
|
||||||
lfo = audioCtx.createOscillator();
|
tick();
|
||||||
lfo.type = 'sine';
|
</script>
|
||||||
lfo.frequency.value = 4;
|
|
||||||
|
|
||||||
lfoGain = audioCtx.createGain();
|
|
||||||
lfoGain.gain.value = 1200;
|
|
||||||
|
|
||||||
noise = createNoiseSource();
|
|
||||||
noiseGain = audioCtx.createGain();
|
|
||||||
noiseGain.gain.value = 0.05;
|
|
||||||
|
|
||||||
masterGain = audioCtx.createGain();
|
|
||||||
masterGain.gain.value = 0.0;
|
|
||||||
|
|
||||||
compressor = audioCtx.createDynamicsCompressor();
|
|
||||||
compressor.threshold.value = -24;
|
|
||||||
compressor.ratio.value = 12;
|
|
||||||
compressor.attack.value = 0.005;
|
|
||||||
compressor.release.value = 0.2;
|
|
||||||
|
|
||||||
analyser = audioCtx.createAnalyser();
|
|
||||||
analyser.fftSize = 1024;
|
|
||||||
bufferLength = analyser.frequencyBinCount;
|
|
||||||
dataArray = new Uint8Array(bufferLength);
|
|
||||||
|
|
||||||
osc.connect(filter);
|
|
||||||
filter.connect(masterGain);
|
|
||||||
|
|
||||||
lfo.connect(lfoGain);
|
|
||||||
lfoGain.connect(filter.frequency);
|
|
||||||
|
|
||||||
noise.connect(noiseGain).connect(masterGain);
|
|
||||||
|
|
||||||
masterGain.connect(compressor).connect(audioCtx.destination);
|
|
||||||
masterGain.connect(analyser);
|
|
||||||
|
|
||||||
osc.start();
|
|
||||||
lfo.start();
|
|
||||||
noise.start(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNoiseSource() {
|
|
||||||
const rate = audioCtx.sampleRate;
|
|
||||||
const bufferSize = rate * 2;
|
|
||||||
const buffer = audioCtx.createBuffer(1, bufferSize, rate);
|
|
||||||
const output = buffer.getChannelData(0);
|
|
||||||
for (let i = 0; i < bufferSize; i++) {
|
|
||||||
output[i] = Math.random() * 2 - 1;
|
|
||||||
}
|
|
||||||
const noiseSource = audioCtx.createBufferSource();
|
|
||||||
noiseSource.buffer = buffer;
|
|
||||||
noiseSource.loop = true;
|
|
||||||
return noiseSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resizeCanvas() {
|
|
||||||
canvas.width = stage.clientWidth;
|
|
||||||
canvas.height = stage.clientHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateAudio(x, y) {
|
|
||||||
if (!audioCtx) return;
|
|
||||||
const rect = stage.getBoundingClientRect();
|
|
||||||
const normX = (x - rect.left) / rect.width;
|
|
||||||
const normY = (y - rect.top) / rect.height;
|
|
||||||
|
|
||||||
const minFreq = 80;
|
|
||||||
const maxFreq = 1200;
|
|
||||||
const freq = minFreq * Math.pow(maxFreq / minFreq, normX);
|
|
||||||
filter.frequency.setTargetAtTime(freq, audioCtx.currentTime, 0.02);
|
|
||||||
|
|
||||||
const q = 4 + normY * 20;
|
|
||||||
filter.Q.setTargetAtTime(q, audioCtx.currentTime, 0.02);
|
|
||||||
|
|
||||||
const noiseLevel = normY * 0.3;
|
|
||||||
noiseGain.gain.setTargetAtTime(noiseLevel, audioCtx.currentTime, 0.05);
|
|
||||||
|
|
||||||
const lfoSpeed = 0.5 + normX * 8;
|
|
||||||
lfo.frequency.setTargetAtTime(lfoSpeed, audioCtx.currentTime, 0.05);
|
|
||||||
|
|
||||||
freqReadout.textContent = `${freq.toFixed(1)} Hz`;
|
|
||||||
resoReadout.textContent = q.toFixed(2);
|
|
||||||
noiseReadout.textContent = noiseLevel.toFixed(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
function animate() {
|
|
||||||
requestAnimationFrame(animate);
|
|
||||||
if (!analyser) return;
|
|
||||||
analyser.getByteFrequencyData(dataArray);
|
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
||||||
|
|
||||||
const barWidth = (canvas.width / bufferLength) * 2.5;
|
|
||||||
let x = 0;
|
|
||||||
for (let i = 0; i < bufferLength; i++) {
|
|
||||||
const barHeight = dataArray[i] / 255 * canvas.height;
|
|
||||||
const hue = (i / bufferLength) * 360;
|
|
||||||
ctx.fillStyle = `hsla(${hue}, 90%, 60%, 0.6)`;
|
|
||||||
ctx.fillRect(x, canvas.height - barHeight, barWidth, barHeight);
|
|
||||||
x += barWidth + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pointerMove(event) {
|
|
||||||
const x = event.clientX;
|
|
||||||
const y = event.clientY;
|
|
||||||
cursor.style.transform = `translate(${x}px, ${y}px) scale(${isPressed ? 1.2 : 1})`;
|
|
||||||
updateAudio(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pointerDown() {
|
|
||||||
isPressed = true;
|
|
||||||
if (!audioCtx) {
|
|
||||||
setupAudio();
|
|
||||||
}
|
|
||||||
if (!audioCtx) return;
|
|
||||||
masterGain.gain.cancelScheduledValues(audioCtx.currentTime);
|
|
||||||
masterGain.gain.setTargetAtTime(0.7, audioCtx.currentTime, 0.02);
|
|
||||||
lfoGain.gain.setTargetAtTime(900, audioCtx.currentTime, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pointerUp() {
|
|
||||||
isPressed = false;
|
|
||||||
if (!audioCtx) return;
|
|
||||||
masterGain.gain.setTargetAtTime(0.0, audioCtx.currentTime, 0.05);
|
|
||||||
lfoGain.gain.setTargetAtTime(200, audioCtx.currentTime, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
stage.addEventListener('pointermove', pointerMove);
|
|
||||||
stage.addEventListener('pointerdown', pointerDown);
|
|
||||||
window.addEventListener('pointerup', pointerUp);
|
|
||||||
|
|
||||||
window.addEventListener('resize', resizeCanvas);
|
|
||||||
resizeCanvas();
|
|
||||||
animate();
|
|
||||||
|
|
||||||
document.addEventListener('keydown', (event) => {
|
|
||||||
if (!audioCtx) return;
|
|
||||||
if (event.code === 'Space') {
|
|
||||||
const now = audioCtx.currentTime;
|
|
||||||
const burst = audioCtx.createOscillator();
|
|
||||||
burst.type = 'square';
|
|
||||||
burst.frequency.value = filter.frequency.value * 0.5;
|
|
||||||
|
|
||||||
const burstGain = audioCtx.createGain();
|
|
||||||
burstGain.gain.value = 0;
|
|
||||||
burst.connect(burstGain).connect(masterGain);
|
|
||||||
|
|
||||||
burst.start(now);
|
|
||||||
burstGain.gain.setValueAtTime(0, now);
|
|
||||||
burstGain.gain.linearRampToValueAtTime(0.8, now + 0.05);
|
|
||||||
burstGain.gain.exponentialRampToValueAtTime(0.001, now + 0.5);
|
|
||||||
burst.stop(now + 0.6);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user