# Dev harness: quantify the fidelity of the injection audio path. Two complementary modes:
#  - default: play a known sine (coop_tone), inject coop_hook.dll as the host does (late
#    attach), capture the hook's ring, and analyze it -- proves the CAPTURE side.
#  - --render: drive the REAL shipping AudioMirror (its run_hooked re-renders the ring to
#    the device) while self-loopback-capturing this process's own output -- proves the
#    RENDER side, surfacing under-run / re-prime "metallic" gaps a write-side tap can't see.
# Both run the analyzer (pitch error in cents, SNR/THD, click + dropout counts) + dump a .wav.
add_executable(coop_audio_validate
	main.cpp
	${CMAKE_SOURCE_DIR}/host/src/audio/audio_loopback.cpp
	${CMAKE_SOURCE_DIR}/host/src/audio/audio_format_verifier.cpp
	${CMAKE_SOURCE_DIR}/host/src/audio/process_loopback_capture.cpp
	${CMAKE_SOURCE_DIR}/host/src/audio/audio_overrides.cpp)

target_include_directories(coop_audio_validate PRIVATE
	${CMAKE_SOURCE_DIR}/host/src
	${CMAKE_SOURCE_DIR}/tools/audio_tone) # shared ToneSource (for --selfcheck)

# AudioMirror's run_hooked re-renders the ring; process loopback (the --render self-capture)
# needs the Windows 10 20H1 (NTDDI_WIN10_CO) headers, same as the host build.
target_compile_definitions(coop_audio_validate PRIVATE NTDDI_VERSION=0x0A00000B)

target_link_libraries(coop_audio_validate PRIVATE coop_common ole32 mmdevapi)
set_target_properties(coop_audio_validate PROPERTIES OUTPUT_NAME "coop_audio_validate")

# Needs coop_hook.dll (the deployable root) and coop_tone.exe (staged in tests/) at runtime.
add_dependencies(coop_audio_validate coop_hook coop_tone)

coop_output_subdir(tools coop_audio_validate) # dev tool -> bin/<config>/tools/
