Spaces:
Running
Running
File size: 28,480 Bytes
fbba045 |
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vintage Analog Synth</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
synth: {
dark: '#1a1a2e',
panel: '#2d2d44',
knob: '#4a4a6a',
highlight: '#ff6b6b',
wood: '#8b4513',
metal: '#a9a9a9',
label: '#d1d1e9'
}
},
fontFamily: {
'orbitron': ['Orbitron', 'sans-serif'],
'audiowide': ['Audiowide', 'cursive']
}
}
}
}
</script>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Audiowide&display=swap" rel="stylesheet">
<style>
@keyframes glow {
0% { box-shadow: 0 0 5px #ff6b6b; }
50% { box-shadow: 0 0 20px #ff6b6b; }
100% { box-shadow: 0 0 5px #ff6b6b; }
}
.knob {
position: relative;
width: 60px;
height: 60px;
border-radius: 50%;
background: linear-gradient(135deg, #4a4a6a 0%, #2d2d44 100%);
box-shadow:
inset 0 0 10px rgba(0, 0, 0, 0.5),
0 5px 15px rgba(0, 0, 0, 0.5);
cursor: pointer;
transition: transform 0.1s;
}
.knob::before {
content: '';
position: absolute;
top: 5px;
left: 50%;
transform: translateX(-50%);
width: 6px;
height: 20px;
background: #ff6b6b;
border-radius: 3px;
}
.knob-label {
position: absolute;
bottom: -25px;
left: 0;
width: 100%;
text-align: center;
font-size: 0.75rem;
color: #d1d1e9;
}
.wood-panel {
background: linear-gradient(
to bottom,
#8b4513 0%,
#5d2e0a 20%,
#8b4513 40%,
#5d2e0a 60%,
#8b4513 80%,
#5d2e0a 100%
);
border: 2px solid #5d2e0a;
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}
.metal-frame {
background: linear-gradient(135deg, #c0c0c0 0%, #a9a9a9 100%);
border: 1px solid #888;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.key-white {
width: 40px;
height: 180px;
background: linear-gradient(to bottom, #fff 0%, #f0f0f0 100%);
border: 1px solid #ccc;
border-radius: 0 0 5px 5px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
position: relative;
z-index: 1;
}
.key-black {
width: 28px;
height: 120px;
background: linear-gradient(to bottom, #000 0%, #333 100%);
border: 1px solid #000;
border-radius: 0 0 4px 4px;
position: absolute;
z-index: 2;
margin-left: -14px;
}
.key-white.active {
background: linear-gradient(to bottom, #ffd700 0%, #ffb700 100%);
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}
.key-black.active {
background: linear-gradient(to bottom, #ff8c00 0%, #ff6b00 100%);
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}
.led {
width: 12px;
height: 12px;
border-radius: 50%;
background: #444;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}
.led.active {
background: #ff6b6b;
box-shadow: 0 0 10px #ff6b6b;
animation: glow 1.5s infinite;
}
.vintage-label {
font-family: 'Audiowide', cursive;
color: #d1d1e9;
text-shadow: 0 0 5px rgba(255, 107, 107, 0.5);
letter-spacing: 1px;
}
.panel-label {
font-family: 'Audiowide', cursive;
color: #ff6b6b;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 0.9rem;
}
.synth-container {
perspective: 1000px;
}
.synth-body {
transform: rotateX(5deg);
transform-style: preserve-3d;
}
.knob-container {
transform-style: preserve-3d;
}
.knob-shadow {
position: absolute;
bottom: -5px;
left: 5px;
width: 50px;
height: 10px;
background: rgba(0, 0, 0, 0.3);
border-radius: 50%;
filter: blur(5px);
z-index: -1;
}
.lcd-display {
background: linear-gradient(135deg, #0a3f0a 0%, #082908 100%);
border: 2px solid #0f5c0f;
color: #7fff7f;
font-family: 'Audiowide', cursive;
text-shadow: 0 0 5px #7fff7f;
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}
.lcd-text {
animation: flicker 0.1s infinite alternate;
}
@keyframes flicker {
0% { opacity: 0.9; }
100% { opacity: 1; }
}
</style>
</head>
<body class="bg-synth-dark min-h-screen flex flex-col items-center justify-center p-4 font-orbitron">
<div class="synth-container w-full max-w-4xl">
<div class="synth-body bg-synth-panel rounded-xl p-6 shadow-2xl">
<!-- Header -->
<div class="text-center mb-6">
<h1 class="vintage-label text-3xl md:text-4xl mb-2">ANALOG SYNTHESIZER</h1>
<div class="lcd-display rounded-lg p-3 mx-auto max-w-md">
<div class="lcd-text text-center text-lg">MODEL: V-1978</div>
</div>
</div>
<!-- Main Controls -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<!-- Oscillator Section -->
<div class="bg-synth-dark rounded-lg p-4 wood-panel">
<div class="panel-label text-center mb-3">OSCILLATOR</div>
<div class="grid grid-cols-3 gap-4">
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="osc1-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">WAVE</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="osc2-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">OCTAVE</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="detune-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">DETUNE</div>
</div>
</div>
<div class="flex justify-around mt-4">
<div class="flex flex-col items-center">
<div class="led" id="sine-led"></div>
<span class="text-xs mt-1 text-synth-label">SINE</span>
</div>
<div class="flex flex-col items-center">
<div class="led active" id="saw-led"></div>
<span class="text-xs mt-1 text-synth-label">SAW</span>
</div>
<div class="flex flex-col items-center">
<div class="led" id="square-led"></div>
<span class="text-xs mt-1 text-synth-label">SQUARE</span>
</div>
<div class="flex flex-col items-center">
<div class="led" id="triangle-led"></div>
<span class="text-xs mt-1 text-synth-label">TRI</span>
</div>
</div>
</div>
<!-- Filter Section -->
<div class="bg-synth-dark rounded-lg p-4 wood-panel">
<div class="panel-label text-center mb-3">FILTER</div>
<div class="grid grid-cols-3 gap-4">
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="cutoff-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">CUTOFF</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="resonance-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">RESONANCE</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="env-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">ENV AMT</div>
</div>
</div>
<div class="flex justify-around mt-4">
<div class="flex flex-col items-center">
<div class="led active" id="lowpass-led"></div>
<span class="text-xs mt-1 text-synth-label">LOW</span>
</div>
<div class="flex flex-col items-center">
<div class="led" id="highpass-led"></div>
<span class="text-xs mt-1 text-synth-label">HIGH</span>
</div>
<div class="flex flex-col items-center">
<div class="led" id="bandpass-led"></div>
<span class="text-xs mt-1 text-synth-label">BAND</span>
</div>
</div>
</div>
<!-- Envelope Section -->
<div class="bg-synth-dark rounded-lg p-4 wood-panel">
<div class="panel-label text-center mb-3">ENVELOPE</div>
<div class="grid grid-cols-4 gap-3">
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="attack-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">ATTACK</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="decay-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">DECAY</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="sustain-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">SUSTAIN</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="release-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">RELEASE</div>
</div>
</div>
<div class="mt-4 flex justify-center">
<div class="bg-synth-panel rounded p-2 w-full">
<div class="h-2 bg-gray-800 rounded-full overflow-hidden">
<div class="h-full bg-synth-highlight rounded-full w-3/4"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Modulation and Effects -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div class="bg-synth-dark rounded-lg p-4 wood-panel">
<div class="panel-label text-center mb-3">MODULATION</div>
<div class="grid grid-cols-3 gap-4">
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="lfo-rate-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">RATE</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="lfo-amount-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">AMOUNT</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="lfo-target-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">TARGET</div>
</div>
</div>
</div>
<div class="bg-synth-dark rounded-lg p-4 wood-panel">
<div class="panel-label text-center mb-3">EFFECTS</div>
<div class="grid grid-cols-3 gap-4">
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="delay-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">DELAY</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="reverb-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">REVERB</div>
</div>
<div class="knob-container flex flex-col items-center">
<div class="knob relative" id="distortion-knob">
<div class="knob-shadow"></div>
</div>
<div class="knob-label">DRIVE</div>
</div>
</div>
</div>
</div>
<!-- Keyboard -->
<div class="bg-synth-dark rounded-lg p-4 wood-panel mb-6">
<div class="panel-label text-center mb-3">KEYBOARD</div>
<div class="relative h-48 flex justify-center">
<!-- White Keys -->
<div class="flex relative">
<div class="key-white" data-note="C" data-frequency="261.63"></div>
<div class="key-white" data-note="D" data-frequency="293.66"></div>
<div class="key-white" data-note="E" data-frequency="329.63"></div>
<div class="key-white" data-note="F" data-frequency="349.23"></div>
<div class="key-white" data-note="G" data-frequency="392.00"></div>
<div class="key-white" data-note="A" data-frequency="440.00"></div>
<div class="key-white" data-note="B" data-frequency="493.88"></div>
<div class="key-white" data-note="C2" data-frequency="523.25"></div>
<!-- Black Keys -->
<div class="key-black" style="left: 30px;" data-note="C#" data-frequency="277.18"></div>
<div class="key-black" style="left: 70px;" data-note="D#" data-frequency="311.13"></div>
<div class="key-black" style="left: 150px;" data-note="F#" data-frequency="369.99"></div>
<div class="key-black" style="left: 190px;" data-note="G#" data-frequency="415.30"></div>
<div class="key-black" style="left: 230px;" data-note="A#" data-frequency="466.16"></div>
</div>
</div>
</div>
<!-- Footer -->
<div class="flex justify-between items-center">
<div class="flex items-center">
<div class="led active mr-2"></div>
<span class="text-sm text-synth-label">POWER ON</span>
</div>
<div class="text-sm text-synth-label">
<i class="fas fa-copyright mr-1"></i> 1978 ANALOG SYSTEMS
</div>
<div class="flex">
<button class="metal-frame px-3 py-1 rounded text-synth-label mr-2 hover:bg-synth-highlight hover:text-white transition">
PRESETS
</button>
<button class="metal-frame px-3 py-1 rounded text-synth-label hover:bg-synth-highlight hover:text-white transition">
RECORD
</button>
</div>
</div>
</div>
</div>
<script>
// Initialize Web Audio API
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
let oscillator = null;
let gainNode = null;
let filter = null;
// Initialize synth parameters
const synthParams = {
waveform: 'sawtooth',
octave: 0,
detune: 0,
cutoff: 1000,
resonance: 1,
attack: 0.1,
decay: 0.3,
sustain: 0.7,
release: 0.5
};
// Note frequencies
const noteFrequencies = {
'C': 261.63,
'C#': 277.18,
'D': 293.66,
'D#': 311.13,
'E': 329.63,
'F': 349.23,
'F#': 369.99,
'G': 392.00,
'G#': 415.30,
'A': 440.00,
'A#': 466.16,
'B': 493.88,
'C2': 523.25
};
// Initialize knobs
function initKnobs() {
const knobs = document.querySelectorAll('.knob');
knobs.forEach(knob => {
let isDragging = false;
let startY = 0;
let startRotation = 0;
let currentRotation = 0;
knob.addEventListener('mousedown', (e) => {
isDragging = true;
startY = e.clientY;
startRotation = currentRotation;
knob.style.cursor = 'grabbing';
});
document.addEventListener('mousemove', (e) => {
if (isDragging) {
const deltaY = startY - e.clientY;
currentRotation = Math.min(135, Math.max(-135, startRotation + deltaY));
knob.style.transform = `rotate(${currentRotation}deg)`;
// Simulate sound when adjusting knobs
playKnobSound();
}
});
document.addEventListener('mouseup', () => {
if (isDragging) {
isDragging = false;
knob.style.cursor = 'pointer';
}
});
knob.addEventListener('touchstart', (e) => {
isDragging = true;
startY = e.touches[0].clientY;
startRotation = currentRotation;
});
document.addEventListener('touchmove', (e) => {
if (isDragging) {
const deltaY = startY - e.touches[0].clientY;
currentRotation = Math.min(135, Math.max(-135, startRotation + deltaY));
knob.style.transform = `rotate(${currentRotation}deg)`;
playKnobSound();
}
});
document.addEventListener('touchend', () => {
isDragging = false;
});
});
}
// Play a sound when turning knobs
function playKnobSound() {
if (oscillator) {
oscillator.stop();
}
oscillator = audioContext.createOscillator();
gainNode = audioContext.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = 200;
gainNode.gain.value = 0.1;
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.1);
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start();
oscillator.stop(audioContext.currentTime + 0.1);
}
// Play a note
function playNote(noteElement) {
if (oscillator) {
oscillator.stop();
}
oscillator = audioContext.createOscillator();
gainNode = audioContext.createGain();
filter = audioContext.createBiquadFilter();
// Get frequency from data attribute
const frequency = parseFloat(noteElement.dataset.frequency) * Math.pow(2, synthParams.octave);
// Set oscillator parameters
oscillator.type = synthParams.waveform;
oscillator.frequency.value = frequency;
oscillator.detune.value = synthParams.detune;
// Set filter parameters
filter.type = 'lowpass';
filter.frequency.value = synthParams.cutoff;
filter.Q.value = synthParams.resonance;
// Set envelope parameters
const now = audioContext.currentTime;
gainNode.gain.setValueAtTime(0, now);
gainNode.gain.linearRampToValueAtTime(1, now + synthParams.attack);
gainNode.gain.linearRampToValueAtTime(synthParams.sustain, now + synthParams.attack + synthParams.decay);
// Connect nodes
oscillator.connect(filter);
filter.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start();
}
// Release note
function releaseNote() {
const now = audioContext.currentTime;
gainNode.gain.cancelScheduledValues(now);
gainNode.gain.setValueAtTime(gainNode.gain.value, now);
gainNode.gain.linearRampToValueAtTime(0, now + synthParams.release);
setTimeout(() => {
if (oscillator) {
oscillator.stop();
}
}, synthParams.release * 1000);
}
// Initialize keyboard
function initKeyboard() {
const keys = document.querySelectorAll('.key-white, .key-black');
keys.forEach(key => {
key.addEventListener('mousedown', () => {
key.classList.add('active');
playNote(key);
});
key.addEventListener('mouseup', () => {
key.classList.remove('active');
releaseNote();
});
key.addEventListener('mouseleave', () => {
if (key.classList.contains('active')) {
key.classList.remove('active');
releaseNote();
}
});
// Touch events for mobile
key.addEventListener('touchstart', (e) => {
e.preventDefault();
key.classList.add('active');
playNote(key);
});
key.addEventListener('touchend', () => {
key.classList.remove('active');
releaseNote();
});
});
}
// Initialize waveform LEDs
function initWaveformLEDs() {
const leds = document.querySelectorAll('#sine-led, #saw-led, #square-led, #triangle-led');
leds.forEach(led => {
led.addEventListener('click', () => {
// Remove active class from all
leds.forEach(l => l.classList.remove('active'));
// Add active to clicked
led.classList.add('active');
// Update waveform
if (led.id === 'sine-led') synthParams.waveform = 'sine';
if (led.id === 'saw-led') synthParams.waveform = 'sawtooth';
if (led.id === 'square-led') synthParams.waveform = 'square';
if (led.id === 'triangle-led') synthParams.waveform = 'triangle';
playKnobSound();
});
});
}
// Initialize when page loads
document.addEventListener('DOMContentLoaded', () => {
initKnobs();
initKeyboard();
initWaveformLEDs();
// Add slight rotation to knobs for visual effect
const knobs = document.querySelectorAll('.knob');
knobs.forEach((knob, i) => {
const rotation = -90 + (i * 20);
knob.style.transform = `rotate(${rotation}deg)`;
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Tingchenliang/analog-synth" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |