document.addEventListener("DOMContentLoaded", function () { // Crear un contexto de audio const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); // Array de notas en frecuencia (C4 a C6) const notes = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25, 587.33, 659.25, 698.46, 783.99, 880.00, 987.77]; // Función para reproducir una nota function playNote(frequency) { const oscillator = audioCtx.createOscillator(); const gainNode = audioCtx.createGain(); oscillator.type = "sine"; // Puedes probar "square", "sawtooth" o "triangle" oscillator.frequency.setValueAtTime(frequency, audioCtx.currentTime); gainNode.gain.setValueAtTime(0.3, audioCtx.currentTime); oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); oscillator.start(); setTimeout(() => { oscillator.stop(); }, 200); // Duración de la nota (200ms) } // Detectar el movimiento del ratón document.addEventListener("mousemove", function (event) { const width = window.innerWidth; const xPos = event.clientX; // Escalar la posición del mouse a un índice de la lista de notas const index = Math.floor((xPos / width) * notes.length); const note = notes[Math.min(index, notes.length - 1)]; // Reproducir la nota playNote(note); }); });CORO — Home