364 lines
No EOL
12 KiB
PHP
364 lines
No EOL
12 KiB
PHP
<?php
|
|
// DATEI: ./test/index.php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
// 1. Projekt identifizieren und schützen
|
|
$current_project = 'test';
|
|
require_once __DIR__ . '/../auth.php';
|
|
|
|
// 2. Nutzerdaten abrufen
|
|
$loggedInUser = isset($_SESSION['user_email']) ? $_SESSION['user_email'] : 'Gast';
|
|
$isAdmin = !empty($_SESSION['is_admin']);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Web Audio Synth | Test-Modul</title>
|
|
<style>
|
|
:root {
|
|
--primary: #06b6d4;
|
|
--secondary: #10b981;
|
|
--bg: #020617;
|
|
--surface: #0b1120;
|
|
--card-border: #1e293b;
|
|
--text: #f8fafc;
|
|
--muted: #94a3b8;
|
|
--accent: #d946ef;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
background-color: var(--bg);
|
|
color: var(--text);
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
overflow-x: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
/* Top Bar */
|
|
.top-nav {
|
|
position: fixed;
|
|
top: 16px;
|
|
left: 20px;
|
|
right: 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
z-index: 50;
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.nav-links {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
}
|
|
|
|
.top-nav a {
|
|
color: var(--muted);
|
|
text-decoration: none;
|
|
padding: 8px 14px;
|
|
background: rgba(11, 17, 32, 0.85);
|
|
border: 1px solid var(--card-border);
|
|
border-radius: 10px;
|
|
backdrop-filter: blur(8px);
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.top-nav a:hover {
|
|
color: var(--primary);
|
|
border-color: rgba(6, 182, 212, 0.4);
|
|
}
|
|
|
|
.top-nav a.admin-link {
|
|
color: var(--primary);
|
|
border-color: rgba(6, 182, 212, 0.3);
|
|
background: rgba(6, 182, 212, 0.08);
|
|
}
|
|
|
|
.top-nav a.admin-link:hover {
|
|
background: rgba(6, 182, 212, 0.18);
|
|
}
|
|
|
|
/* Container */
|
|
.container {
|
|
background: var(--surface);
|
|
border: 1px solid var(--card-border);
|
|
padding: 40px;
|
|
max-width: 540px;
|
|
width: 100%;
|
|
border-radius: 28px;
|
|
box-shadow: 0 0 50px rgba(6, 182, 212, 0.08);
|
|
position: relative;
|
|
text-align: center;
|
|
}
|
|
|
|
.container::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 2px;
|
|
background: linear-gradient(90deg, transparent, var(--primary), transparent);
|
|
border-radius: 28px 28px 0 0;
|
|
}
|
|
|
|
.header {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.badge {
|
|
display: inline-block;
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 10px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.15em;
|
|
color: var(--primary);
|
|
background: rgba(6, 182, 212, 0.1);
|
|
border: 1px solid rgba(6, 182, 212, 0.25);
|
|
padding: 4px 10px;
|
|
border-radius: 9999px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
h1 {
|
|
color: var(--text);
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 1.6rem;
|
|
font-weight: 800;
|
|
letter-spacing: -0.02em;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.user-info {
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 11px;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.main-content {
|
|
margin: 28px 0;
|
|
}
|
|
|
|
.description {
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
line-height: 1.6;
|
|
margin-bottom: 28px;
|
|
}
|
|
|
|
/* Sound Button */
|
|
#whoopee-cushion {
|
|
width: 140px;
|
|
height: 140px;
|
|
background: radial-gradient(circle, #f43f5e 0%, #be123c 100%);
|
|
border-radius: 50%;
|
|
border: 4px solid #e11d48;
|
|
cursor: pointer;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 11px;
|
|
font-weight: bold;
|
|
color: white;
|
|
text-align: center;
|
|
margin: 0 auto;
|
|
position: relative;
|
|
user-select: none;
|
|
transition: transform 0.08s, box-shadow 0.08s;
|
|
box-shadow: 0 10px 0 #881337, 0 15px 25px rgba(244, 63, 94, 0.3);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
#whoopee-cushion:active {
|
|
transform: translateY(8px) scale(0.95);
|
|
box-shadow: 0 2px 0 #881337, 0 5px 15px rgba(244, 63, 94, 0.2);
|
|
}
|
|
|
|
.fart-cloud {
|
|
position: absolute;
|
|
background: rgba(16, 185, 129, 0.4);
|
|
border-radius: 50%;
|
|
pointer-events: none;
|
|
z-index: 10;
|
|
animation: float-up 1.2s ease-out forwards;
|
|
filter: blur(8px);
|
|
}
|
|
|
|
@keyframes float-up {
|
|
0% { transform: translateY(0) scale(0.6); opacity: 0.7; }
|
|
100% { transform: translateY(-130px) scale(3.5); opacity: 0; }
|
|
}
|
|
|
|
.status-msg {
|
|
margin-top: 20px;
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 11px;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.shake {
|
|
animation: shake 0.35s cubic-bezier(.36,.07,.19,.97) both;
|
|
}
|
|
|
|
@keyframes shake {
|
|
10%, 90% { transform: translate3d(-2px, 0, 0); }
|
|
20%, 80% { transform: translate3d(3px, 0, 0); }
|
|
30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
|
|
40%, 60% { transform: translate3d(4px, 0, 0); }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Top Navigation -->
|
|
<nav class="top-nav">
|
|
<div class="nav-links">
|
|
<a href="/">← Website</a>
|
|
<?php if ($isAdmin): ?>
|
|
<a href="/admin" class="admin-link">Admin Dashboard</a>
|
|
<a href="/admin/users" class="admin-link">Benutzerverwaltung</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="nav-links">
|
|
<a href="/login/logout" style="color: #f43f5e;">Logout</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container" id="app-container">
|
|
<header class="header">
|
|
<span class="badge">Web Audio API / Test-Modul</span>
|
|
<h1>Web Audio Synth</h1>
|
|
<div class="user-info">
|
|
Angemeldet: <span><?php echo htmlspecialchars($loggedInUser); ?></span>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="main-content">
|
|
<p class="description">
|
|
Interaktiver Audiotest zur dynamischen Klangsynthese mit Oszillatoren, Rauschgeneratoren und Filtern über die HTML5 Web Audio API.
|
|
</p>
|
|
|
|
<div class="synth-section">
|
|
<div id="whoopee-cushion" role="button" tabindex="0">TRIGGER</div>
|
|
<p id="status-msg" class="status-msg">Klicke auf den Button, um den Soundtest zu starten.</p>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
const cushion = document.getElementById('whoopee-cushion');
|
|
const container = document.getElementById('app-container');
|
|
const statusMsg = document.getElementById('status-msg');
|
|
|
|
function playOrganicFart() {
|
|
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
const audioCtx = new AudioCtx();
|
|
if (audioCtx.state === 'suspended') audioCtx.resume();
|
|
|
|
const duration = 0.4 + Math.random() * 0.4;
|
|
const mainGain = audioCtx.createGain();
|
|
|
|
const osc = audioCtx.createOscillator();
|
|
const oscGain = audioCtx.createGain();
|
|
osc.type = 'sawtooth';
|
|
osc.frequency.setValueAtTime(45 + Math.random() * 20, audioCtx.currentTime);
|
|
osc.frequency.exponentialRampToValueAtTime(20, audioCtx.currentTime + duration);
|
|
|
|
const lfo = audioCtx.createOscillator();
|
|
const lfoGain = audioCtx.createGain();
|
|
lfo.type = 'square';
|
|
lfo.frequency.setValueAtTime(14 + Math.random() * 8, audioCtx.currentTime);
|
|
lfoGain.gain.setValueAtTime(0.8, audioCtx.currentTime);
|
|
lfo.connect(lfoGain);
|
|
lfoGain.connect(oscGain.gain);
|
|
|
|
const bufferSize = audioCtx.sampleRate * duration;
|
|
const noiseBuffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
|
|
const noiseData = noiseBuffer.getChannelData(0);
|
|
for (let i = 0; i < bufferSize; i++) {
|
|
noiseData[i] = Math.random() * 2 - 1;
|
|
}
|
|
const noise = audioCtx.createBufferSource();
|
|
noise.buffer = noiseBuffer;
|
|
const noiseFilter = audioCtx.createBiquadFilter();
|
|
noiseFilter.type = 'bandpass';
|
|
noiseFilter.frequency.setValueAtTime(400, audioCtx.currentTime);
|
|
|
|
const lowPass = audioCtx.createBiquadFilter();
|
|
lowPass.type = 'lowpass';
|
|
lowPass.frequency.setValueAtTime(450, audioCtx.currentTime);
|
|
lowPass.frequency.exponentialRampToValueAtTime(80, audioCtx.currentTime + duration);
|
|
|
|
mainGain.gain.setValueAtTime(0, audioCtx.currentTime);
|
|
mainGain.gain.linearRampToValueAtTime(0.5, audioCtx.currentTime + 0.05);
|
|
mainGain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + duration);
|
|
|
|
osc.connect(oscGain);
|
|
oscGain.connect(lowPass);
|
|
noise.connect(noiseFilter);
|
|
noiseFilter.connect(lowPass);
|
|
lowPass.connect(mainGain);
|
|
mainGain.connect(audioCtx.destination);
|
|
|
|
osc.start();
|
|
lfo.start();
|
|
noise.start();
|
|
|
|
osc.stop(audioCtx.currentTime + duration);
|
|
lfo.stop(audioCtx.currentTime + duration);
|
|
noise.stop(audioCtx.currentTime + duration);
|
|
|
|
statusMsg.textContent = "Audio-Synthese aktiv. Interaktionstest bestanden.";
|
|
statusMsg.style.color = "#10b981";
|
|
}
|
|
|
|
function createCloud() {
|
|
const cloud = document.createElement('div');
|
|
cloud.classList.add('fart-cloud');
|
|
const size = Math.random() * 50 + 20;
|
|
cloud.style.width = size + 'px';
|
|
cloud.style.height = size + 'px';
|
|
const rect = cushion.getBoundingClientRect();
|
|
cloud.style.left = (rect.left + rect.width / 2 - size / 2 + (Math.random() * 80 - 40)) + 'px';
|
|
cloud.style.top = (rect.top + rect.height / 2 - size / 2) + 'px';
|
|
document.body.appendChild(cloud);
|
|
setTimeout(() => cloud.remove(), 1200);
|
|
}
|
|
|
|
cushion.addEventListener('click', () => {
|
|
playOrganicFart();
|
|
container.classList.add('shake');
|
|
setTimeout(() => container.classList.remove('shake'), 350);
|
|
for(let i = 0; i < 8; i++) {
|
|
setTimeout(createCloud, i * 80);
|
|
}
|
|
});
|
|
|
|
cushion.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
e.preventDefault();
|
|
cushion.click();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|