async initAudio()
button:hover background: #ff6b6b; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.3);
pause() if (this.isPlaying) this.isPlaying = false; this.currentPauseTime = (performance.now() - this.startTime) / 1000; MIDI.stopAllNotes(); midi clef karaoke player
.clef-indicator font-size: 18px; font-weight: bold; margin-bottom: 10px; text-align: center; color: #ffd700; </style> </head> <body> <div class="container"> <div class="player"> <div class="controls"> <input type="file" id="midiFileInput" accept=".mid,.midi"> <button id="playBtn">▶ Play</button> <button id="pauseBtn">⏸ Pause</button> <button id="stopBtn">⏹ Stop</button> </div> <div class="clef-indicator" id="clefIndicator">Clef: --</div> <div class="staff-container"> <canvas id="staffCanvas" width="900" height="300"></canvas> </div> <div class="lyrics" id="lyricsDisplay">🎵 Load a MIDI file to start 🎵</div> <div class="info"> 🎹 Supports karaoke MIDI files with lyrics | Clef auto-detected | Scrolling notes </div> </div> </div>
input[type="file"] background: #533483; color: white; padding: 12px 24px; border-radius: 50px; cursor: pointer; border: none; font-size: 16px; async initAudio() button:hover background: #ff6b6b
play()
drawStaff() this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); const staffTop = 50; const staffBottom = 250; const lineSpacing = 25; // Draw 5 staff lines this.ctx.beginPath(); this.ctx.strokeStyle = '#333'; this.ctx.lineWidth = 1.5; for (let i = 0; i < 5; i++) const y = staffTop + (i * lineSpacing); this.ctx.moveTo(50, y); this.ctx.lineTo(this.canvas.width - 50, y); this.ctx.stroke(); // Draw clef this.ctx.font = 'bold 60px "Segoe UI", "Arial"'; this.ctx.fillStyle = '#e94560'; if (this.clef === 'treble') this.ctx.fillText('𝄞', 20, staffTop + 100); else this.ctx.fillText('𝄢', 20, staffTop + 100); // Draw notes based on current scroll offset const currentTime = this.isPlaying ? (performance.now() - this.startTime) / 1000 : this.currentPauseTime; const visibleTimeRange = 4; // seconds visible const pixelsPerSecond = (this.canvas.width - 100) / visibleTimeRange; this.notes.forEach(note => const noteTime = note.startTime; const x = 80 + (noteTime - currentTime) * pixelsPerSecond; if (x > 30 && x < this.canvas.width - 30) const midiPitch = note.pitch; const staffPosition = this.midiToStaffY(midiPitch); if (staffPosition !== null) this.drawNote(x, staffPosition, note.duration * pixelsPerSecond); ); // Draw current time marker this.ctx.beginPath(); this.ctx.strokeStyle = '#ff0000'; this.ctx.lineWidth = 2; this.ctx.moveTo(80, 20); this.ctx.lineTo(80, this.canvas.height - 20); this.ctx.stroke(); if (this.isPlaying) this.animationId = requestAnimationFrame(() => this.drawStaff()); box-shadow: 0 6px 12px rgba(0
updateLyrics() const currentTime = this.isPlaying ? (performance.now() - this.startTime) / 1000 : this.currentPauseTime; const currentLyric = this.lyrics.filter(l => l.time <= currentTime).pop(); if (currentLyric) document.getElementById('lyricsDisplay').innerHTML = `🎤 $currentLyric.text 🎤`;
initEventListeners() document.getElementById('midiFileInput').addEventListener('change', (e) => this.loadMIDI(e)); document.getElementById('playBtn').addEventListener('click', () => this.play()); document.getElementById('pauseBtn').addEventListener('click', () => this.pause()); document.getElementById('stopBtn').addEventListener('click', () => this.stop());
stop() this.pause(); this.currentPauseTime = 0; this.startTime = 0; this.drawStaff(); document.getElementById('lyricsDisplay').innerHTML = '⏹ Stopped';
async loadMIDI(event) const file = event.target.files[0]; if (!file) return;
async initAudio()
button:hover background: #ff6b6b; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.3);
pause() if (this.isPlaying) this.isPlaying = false; this.currentPauseTime = (performance.now() - this.startTime) / 1000; MIDI.stopAllNotes();
.clef-indicator font-size: 18px; font-weight: bold; margin-bottom: 10px; text-align: center; color: #ffd700; </style> </head> <body> <div class="container"> <div class="player"> <div class="controls"> <input type="file" id="midiFileInput" accept=".mid,.midi"> <button id="playBtn">▶ Play</button> <button id="pauseBtn">⏸ Pause</button> <button id="stopBtn">⏹ Stop</button> </div> <div class="clef-indicator" id="clefIndicator">Clef: --</div> <div class="staff-container"> <canvas id="staffCanvas" width="900" height="300"></canvas> </div> <div class="lyrics" id="lyricsDisplay">🎵 Load a MIDI file to start 🎵</div> <div class="info"> 🎹 Supports karaoke MIDI files with lyrics | Clef auto-detected | Scrolling notes </div> </div> </div>
input[type="file"] background: #533483; color: white; padding: 12px 24px; border-radius: 50px; cursor: pointer; border: none; font-size: 16px;
play()
drawStaff() this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); const staffTop = 50; const staffBottom = 250; const lineSpacing = 25; // Draw 5 staff lines this.ctx.beginPath(); this.ctx.strokeStyle = '#333'; this.ctx.lineWidth = 1.5; for (let i = 0; i < 5; i++) const y = staffTop + (i * lineSpacing); this.ctx.moveTo(50, y); this.ctx.lineTo(this.canvas.width - 50, y); this.ctx.stroke(); // Draw clef this.ctx.font = 'bold 60px "Segoe UI", "Arial"'; this.ctx.fillStyle = '#e94560'; if (this.clef === 'treble') this.ctx.fillText('𝄞', 20, staffTop + 100); else this.ctx.fillText('𝄢', 20, staffTop + 100); // Draw notes based on current scroll offset const currentTime = this.isPlaying ? (performance.now() - this.startTime) / 1000 : this.currentPauseTime; const visibleTimeRange = 4; // seconds visible const pixelsPerSecond = (this.canvas.width - 100) / visibleTimeRange; this.notes.forEach(note => const noteTime = note.startTime; const x = 80 + (noteTime - currentTime) * pixelsPerSecond; if (x > 30 && x < this.canvas.width - 30) const midiPitch = note.pitch; const staffPosition = this.midiToStaffY(midiPitch); if (staffPosition !== null) this.drawNote(x, staffPosition, note.duration * pixelsPerSecond); ); // Draw current time marker this.ctx.beginPath(); this.ctx.strokeStyle = '#ff0000'; this.ctx.lineWidth = 2; this.ctx.moveTo(80, 20); this.ctx.lineTo(80, this.canvas.height - 20); this.ctx.stroke(); if (this.isPlaying) this.animationId = requestAnimationFrame(() => this.drawStaff());
updateLyrics() const currentTime = this.isPlaying ? (performance.now() - this.startTime) / 1000 : this.currentPauseTime; const currentLyric = this.lyrics.filter(l => l.time <= currentTime).pop(); if (currentLyric) document.getElementById('lyricsDisplay').innerHTML = `🎤 $currentLyric.text 🎤`;
initEventListeners() document.getElementById('midiFileInput').addEventListener('change', (e) => this.loadMIDI(e)); document.getElementById('playBtn').addEventListener('click', () => this.play()); document.getElementById('pauseBtn').addEventListener('click', () => this.pause()); document.getElementById('stopBtn').addEventListener('click', () => this.stop());
stop() this.pause(); this.currentPauseTime = 0; this.startTime = 0; this.drawStaff(); document.getElementById('lyricsDisplay').innerHTML = '⏹ Stopped';
async loadMIDI(event) const file = event.target.files[0]; if (!file) return;
© 2025, H & H Sign Supply, Inc All Right Reserved.
Website Hosted and Designed by NetSource Technologies