Files
SonicForgeStudio/TASKS_WINDOWS_AUDIO_NORMALIZE.md

5.3 KiB

TASKS WINDOWS — Chuẩn hóa luồng audio lossless (SonicForgeStudio)

Branch: standalone-shm-bridge — Pull code mới nhất trước khi làm.

Bối cảnh

Linux đã hoàn tất chuẩn hóa luồng audio theo skill lossless-audio-compliance (Float32 nội bộ, WAV IEEE Float32 khi render/export, TPDF dither chỉ ở bước lượng tử cuối, resample Kaiser ≥130dB, null-test gate). Code C++/Python/JS đã sửa trên Linux và commit sẵn — phần còn lại trên Windows chỉ là BUILD lại binary, COPY vào install/, VERIFY, COMMIT.

Đã sửa (kèm theo branch này)

File Thay đổi
native_bridge/src/RenderJob.cpp, RenderFxJob.cpp WAV writer: 16-bit PCM (truncate, không dither) → IEEE Float32 (format 3, 32-bit)
app/core/render_engine.py, app/api/v1/audio.py, app/api/v1/plugins.py sf.write(...) → subtype="FLOAT" (4 chỗ)
app/core/audio_features.py, app/core/render_engine.py resample_poly → window=("kaiser", 16) (stopband ≥130dB)
app/static/js/app.jsx + app.precompiled.js (đã build trên Linux) Encoder client → Float32 mặc định; TPDF dither cho 16/24/8-bit; sửa bug 24-bit ghi nhầm 8-bit; UI thêm "32 float"
app/templates/index.html bump cache ?v=20260818
tests/test_lossless_compliance.py (mới) Null-test gate (Rule 6) + assert float32 WAV (Rule 7) + bridge render deterministic
native_bridge/tests/test_offline_render.py read_wav hiểu cả IEEE float32 lẫn PCM 16-bit
Dockerfile fix git clone --branch v1.2.3 (tag không tồn tại) → clone default

Tasks trên Windows (theo thứ tự)

✅ HOÀN TẤT (2026-08-18) — đã chạy trên máy Windows 192.168.1.24 (Win10 19044): Git 2.55, VS Build Tools 2022 MSVC 14.44, Python 3.11.9, Node 20.20.2, Rust 1.97.1, vcpkg + fluidsynth 2.5.7, sfizz-src clone (native_bridge/sfizz-src, gitignored). Bridge build: cmake -S native_bridge -B build/bridge-win -DCMAKE_TOOLCHAIN_FILE=C:\Users\locpham\vcpkg\scripts\buildsystems\vcpkg.cmake

  • -DSFIZZ_SHARED=OFF; bắt buộc -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL
  • patch sfizz-src/cmake/SfizzConfig.cmake (wrap CMAKE_MSVC_RUNTIME_LIBRARY trong if(NOT ...)) — patch chỉ ở máy đó, cần làm lại khi clone sfizz mới. Verify: tests\test_lossless_compliance.py 9/9 PASS, native_bridge\tests\test_offline_render.py 9/9 PASS (cần native_bridge\build\Release\daw_vst_bridge.exe + copy g2_test.sfz vào sfizz-src\tests\TestFiles\). Bundle: src-tauri\target\release\bundle\nsis\SonicForgeDAW_1.0.0_x64-setup.exe. Binary đã copy vào install/: daw_vst_bridge.exe, sonicforge-daw.exe, libfluidsynth-3.dll, jpeg62.dll. Tauri build cần src-tauri\binaries\daw_vst_bridge-x86_64-pc-windows-msvc.exe (externalBin naming, binaries/ gitignored). build_windows.ps1 bước [5/6] Invoke-WebRequest lỗi console-buffer khi chạy qua SSH — dùng curl tải vc_redist.x64.exe.

1. Pull code mới nhất

cd C:\Users\locpham\SonicForgeStudio
git checkout standalone-shm-bridge
git pull origin standalone-shm-bridge

2. Build lại daw_vst_bridge.exe (WAV writer float32)

Bridge build bằng CMake + vcpkg (fluidsynth) + sfizz-src (xem native_bridge/CMakeLists.txt, build/_sfizz.bat):

# sfizz từ source nếu chưa có (native_bridge/sfizz-src)
# vcpkg install fluidsynth
cmake -S native_bridge -B build/bridge-win -DCMAKE_BUILD_TYPE=Release `
  -DCMAKE_TOOLCHAIN_FILE=<vcpkg-root>\scripts\buildsystems\vcpkg.cmake
cmake --build build/bridge-win --target daw_vst_bridge --config Release
Copy-Item build/bridge-win/Release/daw_vst_bridge.exe install/daw_vst_bridge.exe -Force

Nếu có script build sẵn dùng script đó; bắt buộc copy đè install/daw_vst_bridge.exe.

3. Build lại engine + app (build_windows.ps1)

powershell -ExecutionPolicy Bypass -File build_windows.ps1

(Lưu ý: app.precompiled.js đã build sẵn trên Linux — bước [2/6] chỉ cần chạy lại nếu bạn sửa app.jsx.)

4. Copy binary mới vào install/

Copy-Item src-tauri\target\release\sonicforge-daw.exe install\sonicforge-daw.exe -Force
# hoặc từ NSIS/MSI output tùy quy trình hiện tại

5. Verify (null-test gate + định dạng float32)

python tests\test_lossless_compliance.py
python native_bridge\tests\test_offline_render.py

Kỳ vọng:

  • bridge output IEEE float32 (tag 3) PASS — WAV render ra format 3, 32-bit
  • bridge render deterministic (byte-identical) PASS
  • null test ... bit-exact PASS
  • test_offline_render.py 3 test đầu PASS với read_wav mới

6. Commit + push

git add install/daw_vst_bridge.exe install/sonicforge-daw.exe
git commit -m "feat(audio): lossless float32 WAV render/export (bridge + engine) — chuẩn hóa luồng audio"
git push origin standalone-shm-bridge

Lưu ý

  • Không đổi lại WAV writer sang 16-bit: render nội bộ phải là IEEE Float32 (skill Rule 4/7); dither TPDF chỉ áp dụng ở bước export cuối (client 16/24-bit).
  • install/daw_vst_bridge (ELF Linux) không commit — chỉ commit .exe.
  • Nếu sonicforge-daw.exe bundle cũ vẫn dùng app.precompiled.js cũ: xóa cache trình duyệt / dùng ?v= mới đã bump.