@@ -32,6 +32,22 @@ else()
3232 endif ()
3333endif ()
3434
35+ # --- nlohmann/json (header-only, fetched at configure time) ----------------
36+ # Single-header C++17 JSON library used for preset serialization /
37+ # deserialization. We disable nlohmann's own tests and install rules so
38+ # they don't pollute the Amplitron build.
39+ include (FetchContent )
40+ FetchContent_Declare (
41+ nlohmann_json
42+ GIT_REPOSITORY https://github.com/nlohmann/json.git
43+ GIT_TAG v3.11.3
44+ GIT_SHALLOW TRUE
45+ )
46+ set (JSON_BuildTests OFF CACHE INTERNAL "Disable nlohmann/json tests" )
47+ set (JSON_Install OFF CACHE INTERNAL "Disable nlohmann/json install" )
48+ FetchContent_MakeAvailable (nlohmann_json)
49+ # ---------------------------------------------------------------------------
50+
3551# --- Dependencies ---
3652# Emscripten provides SDL2, OpenGL ES, and audio via built-in ports.
3753# Native builds find PortAudio, SDL2, and OpenGL from the system.
@@ -151,6 +167,7 @@ set(APP_SOURCES
151167 src/audio/effects/equalizer.cpp
152168 src/audio/effects/noise_gate.cpp
153169 src/audio/effects/compressor.cpp
170+ src/audio/effects/looper.cpp
154171 src/audio/effects/cabinet_sim.cpp
155172 src/audio/effects/ir_cabinet.cpp
156173 src/audio/effects/amp_simulator.cpp
@@ -274,6 +291,8 @@ if(EMSCRIPTEN)
274291 # OpenGL ES 3 for ImGui's OpenGL3 backend on WebGL 2
275292 target_compile_definitions (Amplitron PRIVATE IMGUI_IMPL_OPENGL_ES3 AMPLITRON_VERSION= "${AMPLITRON_VERSION} " AMPLITRON_NO_MIDI )
276293
294+ target_link_libraries (Amplitron PRIVATE nlohmann_json::nlohmann_json )
295+
277296 # Emscripten linker flags for Web Audio + AudioWorklet + SharedArrayBuffer
278297 target_link_options (Amplitron PRIVATE
279298 "-sWASM=1"
@@ -341,8 +360,9 @@ elseif(ANDROID)
341360 target_include_directories (main PRIVATE ${OBOE_INCLUDE_DIRS} )
342361
343362 target_link_libraries (main PRIVATE
344- ${OBOE_LIBRARIES} # Google Oboe (AAudio/OpenSL ES low-latency)
345- SDL2::SDL2-static # Still used for display / ImGui rendering
363+ nlohmann_json::nlohmann_json
364+ ${OBOE_LIBRARIES}
365+ SDL2::SDL2-static
346366 android
347367 log
348368 EGL
@@ -380,6 +400,7 @@ elseif(IOS)
380400 )
381401
382402 target_link_libraries (Amplitron PRIVATE
403+ nlohmann_json::nlohmann_json
383404 SDL2::SDL2main
384405 SDL2::SDL2-static
385406 "-framework UIKit"
@@ -430,9 +451,16 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
430451 ${RTMIDI_INCLUDE_DIRS}
431452 )
432453
433- target_compile_definitions (Amplitron PRIVATE AMPLITRON_VERSION= "${AMPLITRON_VERSION} " )
454+ # ============================================================
455+ # DEFINE AMPLITRON_HAS_MIDI FOR DESKTOP BUILDS
456+ # ============================================================
457+ target_compile_definitions (Amplitron PRIVATE
458+ AMPLITRON_VERSION= "${AMPLITRON_VERSION} "
459+ AMPLITRON_HAS_MIDI
460+ )
434461
435462 target_link_libraries (Amplitron PRIVATE
463+ nlohmann_json::nlohmann_json
436464 ${PORTAUDIO_LIBRARIES}
437465 ${SDL2_LIBRARIES}
438466 ${OPENGL_LIBRARIES}
@@ -458,7 +486,9 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
458486 tests/test_common.cpp
459487 tests/test_oboe_ring_buffer.cpp
460488 tests/test_effects.cpp
489+ tests/test_looper.cpp
461490 tests/test_preset_manager.cpp
491+ tests/test_json_serialization.cpp
462492 tests/test_recorder.cpp
463493 tests/test_theme.cpp
464494 tests/test_command_history.cpp
@@ -496,6 +526,7 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
496526 src/audio/effects/equalizer.cpp
497527 src/audio/effects/noise_gate.cpp
498528 src/audio/effects/compressor.cpp
529+ src/audio/effects/looper.cpp
499530 src/audio/effects/cabinet_sim.cpp
500531 src/audio/effects/ir_cabinet.cpp
501532 src/audio/effects/amp_simulator.cpp
@@ -529,7 +560,13 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
529560 ${RTMIDI_INCLUDE_DIRS}
530561 )
531562
563+ # ============================================================
564+ # DEFINE AMPLITRON_HAS_MIDI FOR TEST BUILDS
565+ # ============================================================
566+ target_compile_definitions (amplitron-tests PRIVATE AMPLITRON_HAS_MIDI )
567+
532568 target_link_libraries (amplitron-tests PRIVATE
569+ nlohmann_json::nlohmann_json
533570 ${PORTAUDIO_LIBRARIES}
534571 ${SDL2_LIBRARIES}
535572 ${OPENGL_LIBRARIES}
@@ -567,4 +604,4 @@ else() # NOT EMSCRIPTEN, ANDROID, or IOS
567604 install (DIRECTORY presets DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /amplitron)
568605 install (DIRECTORY assets/fonts DESTINATION bin/assets)
569606
570- endif () # EMSCRIPTEN / ANDROID / IOS / desktop
607+ endif () # EMSCRIPTEN / ANDROID / IOS / desktop
0 commit comments