File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
internal_filesystem/lib/mpos/audio Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1818_i2s_pins = None # I2S pin configuration dict (created per-stream)
1919_buzzer_instance = None # PWM buzzer instance
2020_current_stream = None # Currently playing stream
21- _volume = 25 # System volume (0-100)
21+ _volume = 50 # System volume (0-100)
2222_stream_lock = None # Thread lock for stream management
2323
2424
Original file line number Diff line number Diff line change @@ -372,7 +372,7 @@ def play(self):
372372 # with optimized volume scaling:
373373 # 6144 => audio stutters and quasibird at ~17fps
374374 # 7168 => audio slightly stutters and quasibird at ~16fps
375- # 8192 => no audio stutters and quasibird runs at ~15fps
375+ # 8192 => no audio stutters and quasibird runs at ~15-17fps => this is probably best
376376 # with shift volume scaling:
377377 # 6144 => audio slightly stutters and quasibird at ~16fps?!
378378 # 8192 => no audio stutters, quasibird runs at ~13fps?!
@@ -412,8 +412,12 @@ def play(self):
412412 raw = self ._upsample_buffer (raw , upsample_factor )
413413
414414 # 3. Volume scaling
415- shift = 16 - int (self .volume / 6.25 )
416- _scale_audio_powers_of_2 (raw , len (raw ), shift )
415+ #shift = 16 - int(self.volume / 6.25)
416+ #_scale_audio_powers_of_2(raw, len(raw), shift)
417+ scale = self .volume / 100.0
418+ if scale < 1.0 :
419+ scale_fixed = int (scale * 32768 )
420+ _scale_audio_optimized (raw , len (raw ), scale_fixed )
417421
418422 # 4. Output to I2S
419423 if self ._i2s :
You can’t perform that action at this time.
0 commit comments