This commit is contained in:
Thomas Farstrike
2025-12-09 14:18:57 +01:00
parent b2f441a8bb
commit 776410bc99
2 changed files with 8 additions and 4 deletions
@@ -18,7 +18,7 @@ _device_type = DEVICE_NULL
_i2s_pins = None # I2S pin configuration dict (created per-stream)
_buzzer_instance = None # PWM buzzer instance
_current_stream = None # Currently playing stream
_volume = 25 # System volume (0-100)
_volume = 50 # System volume (0-100)
_stream_lock = None # Thread lock for stream management
@@ -372,7 +372,7 @@ class WAVStream:
# with optimized volume scaling:
# 6144 => audio stutters and quasibird at ~17fps
# 7168 => audio slightly stutters and quasibird at ~16fps
# 8192 => no audio stutters and quasibird runs at ~15fps
# 8192 => no audio stutters and quasibird runs at ~15-17fps => this is probably best
# with shift volume scaling:
# 6144 => audio slightly stutters and quasibird at ~16fps?!
# 8192 => no audio stutters, quasibird runs at ~13fps?!
@@ -412,8 +412,12 @@ class WAVStream:
raw = self._upsample_buffer(raw, upsample_factor)
# 3. Volume scaling
shift = 16 - int(self.volume / 6.25)
_scale_audio_powers_of_2(raw, len(raw), shift)
#shift = 16 - int(self.volume / 6.25)
#_scale_audio_powers_of_2(raw, len(raw), shift)
scale = self.volume / 100.0
if scale < 1.0:
scale_fixed = int(scale * 32768)
_scale_audio_optimized(raw, len(raw), scale_fixed)
# 4. Output to I2S
if self._i2s: