import React, { useState, useEffect, useRef, useCallback } from 'react'; const App = () => { const [isActive, setIsActive] = useState(false); const [glitchLevel, setGlitchLevel] = useState(50); const [bpm, setBpm] = useState(92); const [currentStep, setCurrentStep] = useState(-1); const audioCtx = useRef(null); const gainNode = useRef(null); const sequencerRef = useRef(null); const canvasRef = useRef(null); // Notas de la escala Do Menor Pentatónica para asegurar que sea "pegadiza" const SCALE = [130.81, 155.56, 174.61, 196.00, 233.08, 261.63, 311.13, 349.23, 392.00, 466.16, 523.25]; // Inicializar Audio const initAudio = () => { if (!audioCtx.current) { audioCtx.current = new (window.AudioContext || window.webkitAudioContext)(); gainNode.current = audioCtx.current.createGain(); gainNode.current.connect(audioCtx.current.destination); gainNode.current.gain.value = 0.4; } if (audioCtx.current.state === 'suspended') { audioCtx.current.resume(); } }; const playTone = (freq, time, duration = 0.2, type = 'sine') => { if (!audioCtx.current) return; const osc = audioCtx.current.createOscillator(); const g = audioCtx.current.createGain(); osc.type = type; osc.frequency.setValueAtTime(freq, time); g.gain.setValueAtTime(0, time); g.gain.linearRampToValueAtTime(0.3, time + 0.01); g.gain.exponentialRampToValueAtTime(0.0001, time + duration); osc.connect(g); g.connect(gainNode.current); osc.start(time); osc.stop(time + duration); }; // Lógica del secuenciador generativo const runSequence = useCallback(() => { let step = 0; const interval = 60 / bpm / 4; // 16th notes sequencerRef.current = setInterval(() => { const time = audioCtx.current.currentTime; // Kick (Trip Hop style) if (step === 0 || step === 6 || step === 10) { playTone(55, time, 0.3, 'triangle'); } // Snare/Snap if (step === 4 || step === 12) { playTone(180, time, 0.1, 'square'); } // Melodía Generativa if (Math.random() > 0.6) { const randomNote = SCALE[Math.floor(Math.random() * SCALE.length)]; playTone(randomNote, time, 0.4, 'sine'); // Un armónico para el sonido "limpio" playTone(randomNote * 2, time, 0.2, 'sine'); } setCurrentStep(step); step = (step + 1) % 16; }, interval * 1000); }, [bpm]); const toggleApp = () => { if (!isActive) { initAudio(); runSequence(); } else { if (sequencerRef.current) clearInterval(sequencerRef.current); setCurrentStep(-1); } setIsActive(!isActive); }; // Canvas para efecto visual tipo "Calls" useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext('2d'); let animationFrame; const render = () => { const w = canvas.width = window.innerWidth; const h = canvas.height = window.innerHeight; ctx.fillStyle = '#050505'; ctx.fillRect(0, 0, w, h); // Líneas centrales (vibración) ctx.beginPath(); ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 1; const segments = 100; const centerY = h / 2; for (let i = 0; i < segments; i++) { const x = (w / segments) * i; const noise = isActive ? (Math.random() - 0.5) * glitchLevel : 2; const y = centerY + Math.sin(i * 0.2 + Date.now() * 0.01) * noise; if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y); } ctx.stroke(); // Efecto Glitch visual aleatorio if (isActive && Math.random() > 0.95) { ctx.fillStyle = `rgba(255, 255, 255, ${Math.random() * 0.2})`; ctx.fillRect(0, Math.random() * h, w, Math.random() * 10); } animationFrame = requestAnimationFrame(render); }; render(); return () => cancelAnimationFrame(animationFrame); }, [isActive, glitchLevel]); return (
{/* Glitch Overlay */}
{/* Interfaz Principal */}

{isActive ? 'F_RAG_MENTA' : 'STOP_PED'}

Generative Trip-Hop Engine

{/* Simulación de aberración cromática */}
{isActive ? 'F_RAG_MENTA' : 'STOP_PED'}
setGlitchLevel(parseInt(e.target.value))} className="w-full accent-white bg-gray-800 h-1 appearance-none cursor-crosshair" />
setBpm(parseInt(e.target.value))} className="w-full accent-white bg-gray-800 h-1 appearance-none cursor-crosshair" />
{[...Array(16)].map((_, i) => (
))}
Status {isActive ? 'SYNC_ACTIVE' : 'IDLE'}

Source: Unknown

Freq: 44.1kHz

"Everything is broken, yet the harmony remains."

Auth: Admin_009

© 2026 Fragmenta Labs

); }; export default App;