tools:intervalltrainer-uebung
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
tools:intervalltrainer-uebung [10/05/2025 18:38] – gelöscht - Externe Bearbeitung (Unknown date) 127.0.0.1 | tools:intervalltrainer-uebung [10/05/2025 18:39] (aktuell) – Eric Weber | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Intervalltrainer | Übungsmodus ====== | ||
+ | |||
+ | |||
+ | < | ||
+ | < | ||
+ | <meta charset=" | ||
+ | < | ||
+ | < | ||
+ | body { | ||
+ | font-family: | ||
+ | margin: 20px; | ||
+ | } | ||
+ | .hidden { | ||
+ | display: none; | ||
+ | } | ||
+ | button { | ||
+ | margin: 5px; | ||
+ | padding: 10px; | ||
+ | } | ||
+ | .correct { | ||
+ | background-color: | ||
+ | } | ||
+ | .incorrect { | ||
+ | background-color: | ||
+ | } | ||
+ | .progress { | ||
+ | margin-top: 10px; | ||
+ | height: 20px; | ||
+ | background: #ddd; | ||
+ | position: relative; | ||
+ | } | ||
+ | .progress-bar { | ||
+ | height: 100%; | ||
+ | background: #4caf50; | ||
+ | width: 0%; | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | |||
+ | <div> | ||
+ | < | ||
+ | <select id=" | ||
+ | <option value=" | ||
+ | <option value=" | ||
+ | <option value=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <select id=" | ||
+ | <option value=" | ||
+ | <option value=" | ||
+ | <option value=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <div id=" | ||
+ | <div id=" | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | const intervals = [ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | |||
+ | const semitoneMap = { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }; | ||
+ | |||
+ | const noteFreqs = { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }; | ||
+ | |||
+ | const practiceControls = document.getElementById(" | ||
+ | const intervalButtons = document.getElementById(" | ||
+ | |||
+ | function createPracticeButtons() { | ||
+ | intervalButtons.innerHTML = ''; | ||
+ | intervals.forEach(interval => { | ||
+ | const btn = document.createElement(" | ||
+ | btn.textContent = interval; | ||
+ | btn.onclick = () => playInterval(interval); | ||
+ | intervalButtons.appendChild(btn); | ||
+ | }); | ||
+ | } | ||
+ | |||
+ | function getRandomNote(difficulty, | ||
+ | let pool = []; | ||
+ | if (difficulty === ' | ||
+ | pool = [direction === ' | ||
+ | } else if (difficulty === ' | ||
+ | pool = direction === ' | ||
+ | } else { | ||
+ | pool = Object.keys(noteFreqs); | ||
+ | } | ||
+ | return pool[Math.floor(Math.random() * pool.length)]; | ||
+ | } | ||
+ | |||
+ | function getFrequency(note) { | ||
+ | return noteFreqs[note] || 440; | ||
+ | } | ||
+ | |||
+ | function playTone(frequency, | ||
+ | const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); | ||
+ | const oscillator = audioCtx.createOscillator(); | ||
+ | const gainNode = audioCtx.createGain(); | ||
+ | |||
+ | oscillator.type = ' | ||
+ | oscillator.frequency.setValueAtTime(frequency, | ||
+ | oscillator.connect(gainNode); | ||
+ | gainNode.connect(audioCtx.destination); | ||
+ | |||
+ | oscillator.start(); | ||
+ | gainNode.gain.exponentialRampToValueAtTime(0.0001, | ||
+ | oscillator.stop(audioCtx.currentTime + duration); | ||
+ | } | ||
+ | |||
+ | function playInterval(intervalName, | ||
+ | const direction = document.getElementById(" | ||
+ | const difficulty = document.getElementById(" | ||
+ | const semitones = semitoneMap[intervalName]; | ||
+ | |||
+ | let baseNote = startNote || getRandomNote(difficulty, | ||
+ | let baseFreq = getFrequency(baseNote); | ||
+ | let secondFreq = direction === ' | ||
+ | ? baseFreq / Math.pow(2, semitones / 12) | ||
+ | : baseFreq * Math.pow(2, semitones / 12); | ||
+ | |||
+ | if (direction === ' | ||
+ | playTone(baseFreq); | ||
+ | playTone(secondFreq); | ||
+ | } else { | ||
+ | playTone(baseFreq); | ||
+ | setTimeout(() => playTone(secondFreq), | ||
+ | } | ||
+ | } | ||
+ | |||
+ | createPracticeButtons(); | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||