Änderung: Optimierung der Audio-Integration und Verbesserung der Benutzerinteraktion im Taxi-Spiel

Änderungen:
- Reduzierung der Buffergröße im MotorSound für geringere Latenz.
- Einführung eines AudioUnlockHandlers zur Aktivierung des AudioContext bei Benutzerinteraktionen.
- Anpassung der Initialisierung und Steuerung des MotorSounds, um eine bessere Benutzererfahrung zu gewährleisten.
- Verbesserung der Konsolenausgaben zur besseren Nachverfolgbarkeit während der Audio-Initialisierung.

Diese Anpassungen verbessern die Audio-Performance und die Benutzerinteraktion im Taxi-Minispiel erheblich.
This commit is contained in:
Torsten Schulz (local)
2025-09-17 13:04:51 +02:00
parent abfa6f4b8d
commit 96491902e3
2 changed files with 51 additions and 24 deletions

View File

@@ -19,7 +19,8 @@ class MotorSound {
async init() {
// Verwende ScriptProcessor für bessere Kompatibilität
console.log('Initialisiere MotorSound mit ScriptProcessor');
this.workletNode = this.context.createScriptProcessor(1024);
// Kleinere Buffergröße für geringere Latenz
this.workletNode = this.context.createScriptProcessor(256);
this.workletNode.onaudioprocess = this.process.bind(this);
// Filter-Kette für motorähnlicheren Klang
@@ -34,7 +35,7 @@ class MotorSound {
this.lowPass.Q.value = 0.5;
this.gainNode = this.context.createGain();
this.gainNode.gain.value = 0.25; // Leiser starten
this.gainNode.gain.setValueAtTime(0.25, this.context.currentTime);
// Verbindung: script -> lowshelf -> lowpass -> gain
this.workletNode.connect(this.lowShelf);