FEAT: thêm nút bypass cho track strip để bypass không qua mastering panel

This commit is contained in:
2026-08-03 15:47:10 +07:00
parent 6f55d36085
commit a9da813cb1
28 changed files with 2076 additions and 233 deletions
+16 -10
View File
@@ -280,31 +280,37 @@ class SoundFontConverter:
@staticmethod
def _sf3_plays_audio(path: str) -> bool:
"""Verify a SoundFont actually loads and renders audible audio (guards
against shipping malformed SF3 files that silently play nothing)."""
against shipping malformed SF3 files that silently play nothing).
Uses the low-level CFFI binding (new_fluid_synth / write_float) — the
high-level Synth() class does not exist in this binding, so it is never
used here.
"""
if not os.path.exists(path):
return False
try:
import fluidsynth
import fluidsynth as _fs
import numpy as np
fl = fluidsynth.Synth()
_settings = _fs.new_fluid_settings()
_fl = _fs.new_fluid_synth(_settings)
try:
h = fl.sfload(path)
h = _fs.fluid_synth_sfload(_fl, path.encode("utf-8"), 1)
if h < 0:
return False
fl.program_select(0, h, 0, 0)
fl.noteon(0, 60, 100)
_fs.fluid_synth_program_select(_fl, 0, h, 0, 0)
_fs.fluid_synth_noteon(_fl, 0, 60, 100)
frames = 8820 # 0.2s
buf = np.zeros(frames * 2, dtype=np.float32)
fluidsynth._fl.fluid_synth_write_float(
fl.synth, frames, buf.ctypes.data, 0, 1,
_fs.fluid_synth_write_float(
_fl, frames, buf.ctypes.data, 0, 1,
buf.ctypes.data + frames * 4, 0, 1
)
fl.noteoff(0, 60)
_fs.fluid_synth_noteoff(_fl, 0, 60)
rms = float(np.sqrt(np.mean(buf ** 2)))
return rms > 1e-4
finally:
try:
fl.delete()
_fs.delete_fluid_synth(_fl)
except Exception:
pass
except Exception: