Compare commits

..

2 Commits

Author SHA1 Message Date
admin 1864a6a812 Add hypermodern date dashboard 2025-11-17 14:50:48 +01:00
admin f8eb38e3bf Merge pull request #1 from metacube2/codex/create-php-website-with-mouse-synthesizer
Add MausSynth Web Audio playground
2025-11-10 20:27:32 +01:00
+260 -275
View File
@@ -1,338 +1,323 @@
<?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>
<html lang="de">
<head>
<meta charset="UTF-8">
<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>
:root {
--bg: radial-gradient(circle at center, #1f014d 0%, #05010d 100%);
--accent: #ff2bd7;
--glow: rgba(255, 43, 215, 0.35);
--text: #f7f3ff;
color-scheme: dark;
--bg: radial-gradient(circle at 20% 20%, #1d1646 0%, #05000f 60%, #020203 100%);
--card: rgba(13, 6, 30, 0.8);
--stroke: rgba(255, 255, 255, 0.12);
--glow: #74f9ff;
--accent: #ff43c1;
}
* {
box-sizing: border-box;
cursor: none;
}
body {
margin: 0;
font-family: 'Orbitron', 'Segoe UI', sans-serif;
color: var(--text);
font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
min-height: 100vh;
background: var(--bg);
height: 100vh;
overflow: hidden;
color: #f5f5ff;
padding: clamp(1rem, 3vw, 4rem);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2rem;
}
h1 {
font-weight: 600;
letter-spacing: 0.2em;
header h1 {
font-size: clamp(2.2rem, 4vw, 3.8rem);
margin: 0 0 0.3rem;
text-transform: uppercase;
margin-bottom: 0.5rem;
text-shadow: 0 0 8px var(--accent);
letter-spacing: 0.1em;
}
p.description {
header p {
margin: 0;
opacity: 0.7;
letter-spacing: 0.08em;
text-align: center;
max-width: 420px;
max-width: 520px;
color: rgba(255, 255, 255, 0.75);
font-size: 1rem;
}
.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;
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;
}
canvas#visualizer {
width: 100%;
height: 100%;
display: block;
}
.cursor {
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 80px;
margin-top: -40px;
margin-left: -40px;
border-radius: 50%;
inset: 0;
background: radial-gradient(circle at top right, rgba(255,67,193,0.35), transparent 45%);
opacity: 0.5;
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 {
position: absolute;
right: 16px;
bottom: 16px;
padding: 12px 16px;
background: rgba(10, 5, 25, 0.8);
border-radius: 12px;
font-size: 0.85rem;
letter-spacing: 0.05em;
border: 1px solid rgba(255, 255, 255, 0.1);
.card h2 {
margin: 0 0 0.8rem;
font-size: 1rem;
letter-spacing: 0.3em;
font-weight: 600;
color: var(--glow);
}
.hud span.label {
color: rgba(255,255,255,0.6);
margin-right: 8px;
.primary-time {
font-size: clamp(3rem, 8vw, 4.5rem);
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;
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) {
* {
cursor: default;
}
.cursor {
display: none;
body {
padding: 1.2rem;
}
}
</style>
</head>
<body>
<h1><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></h1>
<p class="description">Schiebe deine Maus über das Klangfeld, um Frequenz, Filter und verrückte Modulation zu steuern. Klicke, um Beats zu triggern.</p>
<header>
<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">
<canvas id="visualizer"></canvas>
<div class="cursor" id="cursor"></div>
<div class="hud" id="hud">
<div><span class="label">Freq</span><span id="freqReadout">-- Hz</span></div>
<div><span class="label">Reso</span><span id="resoReadout">--</span></div>
<div><span class="label">Noise</span><span id="noiseReadout">--</span></div>
<section class="grid">
<article class="card">
<h2>JETZT</h2>
<div class="primary-time" id="clock" aria-live="polite"><?= htmlspecialchars($now->format('H:i:s'), ENT_QUOTES, 'UTF-8'); ?></div>
<div class="primary-date">Tag <?= $dayOfYear; ?> · Woche <?= $weekOfYear; ?> · ISO <?= htmlspecialchars($now->format(DateTimeInterface::ATOM), ENT_QUOTES, 'UTF-8'); ?></div>
<div class="nano-clock" id="nano">µ<?= $now->format('u'); ?></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>
</article>
<p class="hint">Tipp: Halte die Maustaste gedrückt, bewege dich in Kreisen &ndash; 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>
const stage = document.getElementById('stage');
const cursor = document.getElementById('cursor');
const canvas = document.getElementById('visualizer');
const ctx = canvas.getContext('2d');
const freqReadout = document.getElementById('freqReadout');
const resoReadout = document.getElementById('resoReadout');
const noiseReadout = document.getElementById('noiseReadout');
<article class="card">
<h2>TEMPORAL-LINSE</h2>
<ul class="timeline">
<?php foreach ($timeline as $moment): ?>
<li>
<span><?= htmlspecialchars($moment['label'], ENT_QUOTES, 'UTF-8'); ?></span>
<strong><?= htmlspecialchars($moment['time'], ENT_QUOTES, 'UTF-8'); ?></strong>
<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;
let masterGain;
let filter;
let lfo;
let lfoGain;
let noise;
let noiseGain;
let compressor;
let isPressed = false;
let analyser;
let bufferLength;
let dataArray;
<footer>
Synchronisiert mit Serverzeit · Hypermodernität trifft Präzision auf <?= htmlspecialchars($now->format('d.m.Y'), ENT_QUOTES, 'UTF-8'); ?>.
</footer>
function setupAudio() {
if (audioCtx) return;
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
<script>
const serverMillis = <?= json_encode($startMillis, JSON_THROW_ON_ERROR); ?>;
const clientBoot = Date.now();
const drift = serverMillis - clientBoot;
const clock = document.getElementById('clock');
const nano = document.getElementById('nano');
const osc = audioCtx.createOscillator();
osc.type = 'sawtooth';
filter = audioCtx.createBiquadFilter();
filter.type = 'lowpass';
filter.frequency.value = 200;
filter.Q.value = 12;
lfo = audioCtx.createOscillator();
lfo.type = 'sine';
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 pad(value, length = 2) {
return String(value).padStart(length, '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 tick() {
const precise = new Date(Date.now() + drift);
const hours = pad(precise.getHours());
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);
}
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;
const resumePromise = audioCtx.state === 'suspended'
? audioCtx.resume()
: Promise.resolve();
resumePromise
.then(() => {
masterGain.gain.cancelScheduledValues(audioCtx.currentTime);
masterGain.gain.setTargetAtTime(0.7, audioCtx.currentTime, 0.02);
lfoGain.gain.setTargetAtTime(900, audioCtx.currentTime, 0.08);
})
.catch((error) => {
console.error('Failed to resume AudioContext', error);
});
}
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>
tick();
</script>
</body>
</html>