1390ad545b
- native_bridge/src/BuiltinFxChain.{h,cpp}: 8 builtin DSP port 1:1 từ
Python _apply_builtin_fx_chain (eq/eqpro/compressor/limiter/exciter/rebalance)
và JS MASTER_MODULE_IO (imager/maximizer). Biquad RBJ DF2T, block-wise
stateful. createBuiltinFx trả nullptr cho gain/normalize (legacy).
- RenderFxJob: FxSlot thêm bfx, parse builtin 8 loại, runBuiltinSlotSafe SEH,
realtimeRunChain nhánh builtin, chainGen()/entryLatencies(), setParam
áp live lên bfx; Vst3Fx latencySamples từ getLatencySamples().
- RealtimeFxLoop: drain ctrl ring (SET_PARAM -> chain.setParam, drop cũ khi
đầy) + REPORT_LATENCY khi gen đổi (ipc->lat[] ring, lastGen).
- FxRealtimeIPC.h: header 18 u32 (72B), ctrl/lat slots 8, FxCtrlCmd 24B,
FxLatReport 8B, static_asserts.
- app/core/fx_realtime.py: mirror header 72B (ctrl_write/read, lat_write/read,
slots), set_param ghi ctrl ring qua _ctrl_enqueue_locked (guard shm),
get_latencies drain lat ring qua _lat_drain.
- tests/test_builtin_fx_golden.py: golden SNR C++ vs Python (8 cases, ngưỡng
30dB) + order test eq/compressor xen kẽ.
- TASKS_DAW_A.md: tick 2.1-2.9.
Test: 136 passed (4 fx_realtime_chain + 8 builtin golden + regression).
194 lines
7.0 KiB
CMake
194 lines
7.0 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(daw_vst_bridge LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
if(MSVC)
|
|
string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
endif()
|
|
|
|
# ── 1. VST3 SDK (Steinberg, vendored as git submodule — NOT in vcpkg) ──
|
|
if(WIN32 AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/CMakeLists.txt")
|
|
add_subdirectory(vst3sdk EXCLUDE_FROM_ALL)
|
|
set(VST3_SDK_TARGET sdk)
|
|
else()
|
|
message(STATUS "vst3sdk build skipped (Windows-only) — VST3 host disabled; SF2/SF3/SFZ still build")
|
|
set(VST3_SDK_TARGET "")
|
|
endif()
|
|
|
|
# ── 2. FluidSynth + sfizz ──
|
|
# Windows: vcpkg toolchain (-DCMAKE_TOOLCHAIN_FILE=.../vcpkg.cmake) cung cap
|
|
# headers/libs; pkg_check_modules khong co san tren MSVC.
|
|
# Linux/macOS: pkg-config duoc dung (spec goc).
|
|
if(WIN32)
|
|
find_path(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
|
|
find_library(FLUIDSYNTH_LIBRARY NAMES fluidsynth libfluidsynth libfluidsynth-3)
|
|
if(NOT FLUIDSYNTH_INCLUDE_DIR OR NOT FLUIDSYNTH_LIBRARY)
|
|
message(FATAL_ERROR "fluidsynth not found — cai qua vcpkg: vcpkg install fluidsynth")
|
|
endif()
|
|
# sfizz: built from source (native_bridge/sfizz-src, see build/_sfizz.bat) —
|
|
# the sfizz port is NOT in vcpkg upstream. Fall back to vcpkg if present.
|
|
set(SFIZZ_SRC_BUILD "${CMAKE_CURRENT_SOURCE_DIR}/sfizz-src/build/library/lib/Release")
|
|
if(EXISTS "${SFIZZ_SRC_BUILD}/sfizz_static.lib")
|
|
file(GLOB SFIZZ_SRC_LIBS "${SFIZZ_SRC_BUILD}/*.lib")
|
|
set(SFIZZ_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sfizz-src/src")
|
|
set(SFIZZ_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/sfizz-src/src")
|
|
set(SFIZZ_LIBRARY ${SFIZZ_SRC_LIBS})
|
|
else()
|
|
find_path(SFIZZ_INCLUDE_DIR sfizz.hpp)
|
|
find_library(SFIZZ_LIBRARY NAMES sfizz)
|
|
if(NOT SFIZZ_INCLUDE_DIR OR NOT SFIZZ_LIBRARY)
|
|
message(FATAL_ERROR "sfizz not found — build native_bridge/sfizz-src first")
|
|
endif()
|
|
endif()
|
|
else()
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(FLUIDSYNTH REQUIRED fluidsynth)
|
|
pkg_check_modules(SFIZZ REQUIRED sfizz)
|
|
endif()
|
|
|
|
include_directories(
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
${FLUIDSYNTH_INCLUDE_DIR}
|
|
${SFIZZ_INCLUDE_DIR}
|
|
)
|
|
|
|
if(WIN32)
|
|
add_executable(daw_vst_bridge
|
|
src/main.cpp
|
|
src/RenderJob.cpp
|
|
src/RenderFxJob.cpp
|
|
src/FxGuiServer.cpp
|
|
src/NativeInstrumentEngine.cpp
|
|
src/SharedMemoryIPC.cpp
|
|
src/Vst3Instrument.cpp
|
|
src/Vst2Instrument.cpp
|
|
src/StateStore.cpp
|
|
src/SandboxVst3Host.cpp
|
|
src/SandboxVst2Host.cpp
|
|
)
|
|
else()
|
|
# Linux: offline --render only (SF2/SF3 + SFZ; VST3/VST2 hosting is
|
|
# Windows-only). main_linux.cpp is the tiny --render entry.
|
|
add_executable(daw_vst_bridge
|
|
src/main_linux.cpp
|
|
src/RenderJob.cpp
|
|
src/NativeInstrumentEngine.cpp
|
|
)
|
|
endif()
|
|
|
|
# VST3 SDK hosting: sdk_hosting lacks the platform module loader — module_win32.cpp
|
|
# is added to the bridge itself (same approach as the audiohost sample).
|
|
if(VST3_SDK_TARGET)
|
|
target_compile_definitions(daw_vst_bridge PRIVATE HAVE_VST3SDK=1)
|
|
target_link_libraries(daw_vst_bridge PRIVATE ${VST3_SDK_TARGET} sdk_hosting sdk_common)
|
|
if(WIN32)
|
|
target_sources(daw_vst_bridge PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/vst/hosting/module_win32.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/common/memorystream.cpp
|
|
)
|
|
endif()
|
|
endif()
|
|
if(WIN32)
|
|
find_package(JPEG REQUIRED) # libjpeg-turbo (vcpkg) — FxGuiServer.cpp JPEG encode
|
|
target_link_libraries(daw_vst_bridge PRIVATE ${FLUIDSYNTH_LIBRARY} ${SFIZZ_LIBRARY} JPEG::JPEG)
|
|
# Required Windows libs
|
|
target_link_libraries(daw_vst_bridge PRIVATE winmm imm32)
|
|
else()
|
|
target_link_libraries(daw_vst_bridge PRIVATE ${FLUIDSYNTH_LIBRARIES} ${SFIZZ_LIBRARIES})
|
|
endif()
|
|
|
|
# ── fx_vst_bridge: VST FX host (split from daw_vst_bridge). Windows-only:
|
|
# --render-fx (offline) + --realtime-fx (SHM realtime cloud-FX loop). ──
|
|
if(WIN32)
|
|
add_executable(fx_vst_bridge
|
|
src/main_fx.cpp
|
|
src/RenderFxJob.cpp
|
|
src/RealtimeFxLoop.cpp
|
|
src/BuiltinFxChain.cpp
|
|
src/FxGuiServer.cpp
|
|
)
|
|
if(VST3_SDK_TARGET)
|
|
target_compile_definitions(fx_vst_bridge PRIVATE HAVE_VST3SDK=1)
|
|
target_link_libraries(fx_vst_bridge PRIVATE ${VST3_SDK_TARGET} sdk_hosting sdk_common)
|
|
target_sources(fx_vst_bridge PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/vst/hosting/module_win32.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/common/memorystream.cpp
|
|
)
|
|
endif()
|
|
find_package(JPEG REQUIRED) # libjpeg-turbo (vcpkg) — FxGuiServer.cpp JPEG encode
|
|
# FX modes are VST3 + builtin DSP only — no fluidsynth/sfizz (avoids a
|
|
# runtime libfluidsynth-3.dll dependency for the FX bridge).
|
|
target_link_libraries(fx_vst_bridge PRIVATE JPEG::JPEG)
|
|
# Required Windows libs
|
|
target_link_libraries(fx_vst_bridge PRIVATE winmm imm32 ws2_32)
|
|
endif()
|
|
|
|
# ── gui_probe: standalone VST3 GUI attach probe (debug tool, not shipped) ──
|
|
if(WIN32)
|
|
add_executable(gui_probe
|
|
src/gui_probe.cpp
|
|
src/NativeInstrumentEngine.cpp
|
|
src/SharedMemoryIPC.cpp
|
|
src/Vst3Instrument.cpp
|
|
src/Vst2Instrument.cpp
|
|
src/SandboxVst3Host.cpp
|
|
src/SandboxVst2Host.cpp
|
|
)
|
|
if(VST3_SDK_TARGET)
|
|
target_compile_definitions(gui_probe PRIVATE HAVE_VST3SDK=1)
|
|
target_link_libraries(gui_probe PRIVATE ${VST3_SDK_TARGET} sdk_hosting sdk_common)
|
|
if(WIN32)
|
|
target_sources(gui_probe PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/vst/hosting/module_win32.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/common/memorystream.cpp
|
|
)
|
|
endif()
|
|
endif()
|
|
if(WIN32)
|
|
target_link_libraries(gui_probe PRIVATE ${FLUIDSYNTH_LIBRARY} ${SFIZZ_LIBRARY} winmm)
|
|
endif()
|
|
add_executable(plugin_host
|
|
src/plugin_host_main.cpp
|
|
src/SharedMemoryIPC.cpp
|
|
src/Vst3Instrument.cpp
|
|
src/Vst2Instrument.cpp
|
|
)
|
|
if(VST3_SDK_TARGET)
|
|
target_compile_definitions(plugin_host PRIVATE HAVE_VST3SDK=1)
|
|
target_link_libraries(plugin_host PRIVATE ${VST3_SDK_TARGET} sdk_hosting sdk_common)
|
|
if(WIN32)
|
|
target_sources(plugin_host PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/vst/hosting/module_win32.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/common/memorystream.cpp
|
|
)
|
|
endif()
|
|
endif()
|
|
if(WIN32)
|
|
target_link_libraries(plugin_host PRIVATE ${FLUIDSYNTH_LIBRARY} ${SFIZZ_LIBRARY} winmm)
|
|
endif()
|
|
|
|
# G3.3: seh_channel_test — SEH per-channel crash isolation (debug tool, not shipped)
|
|
add_executable(seh_channel_test
|
|
tests/seh_channel_test.cpp
|
|
src/Vst3Instrument.cpp
|
|
src/Vst2Instrument.cpp
|
|
src/SandboxVst3Host.cpp
|
|
src/SharedMemoryIPC.cpp
|
|
)
|
|
if(VST3_SDK_TARGET)
|
|
target_compile_definitions(seh_channel_test PRIVATE HAVE_VST3SDK=1)
|
|
target_link_libraries(seh_channel_test PRIVATE ${VST3_SDK_TARGET} sdk_hosting sdk_common)
|
|
if(WIN32)
|
|
target_sources(seh_channel_test PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/vst/hosting/module_win32.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/vst3sdk/public.sdk/source/common/memorystream.cpp
|
|
)
|
|
endif()
|
|
endif()
|
|
if(WIN32)
|
|
target_link_libraries(seh_channel_test PRIVATE ${FLUIDSYNTH_LIBRARY} ${SFIZZ_LIBRARY} winmm)
|
|
endif()
|
|
endif() # WIN32-only debug tools (gui_probe, plugin_host, seh_channel_test)
|