Skip to content

Commit f174142

Browse files
authored
Audio Plugin Host and Audio Graph (#93)
1 parent 5e9cddf commit f174142

105 files changed

Lines changed: 17866 additions & 1218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ For main module headers (e.g., `yup_graphics.h`), include this declaration block
5757
description: Brief module description
5858
website: https://github.com/kunitoki/yup
5959
license: ISC
60-
minimumCppStandard: 17
6160
6261
dependencies: yup_graphics [other_dependencies]
6362
searchpaths: native
@@ -337,9 +336,9 @@ yup::Result performOperation()
337336
yup::ResultValue<int> maybeGetInteger()
338337
{
339338
if (preconditionFailed)
340-
return yup::ResultValue<int>::fail ("Precondition not met");
339+
return yup::makeResultValueFail ("Precondition not met");
341340

342-
return 1;
341+
return 1; // or yup::makeResultValueOk (1)
343342
}
344343

345344
// Use assertions for programming errors

CLAUDE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ For main module headers (e.g., `yup_graphics.h`), include this declaration block
5757
description: Brief module description
5858
website: https://github.com/kunitoki/yup
5959
license: ISC
60-
minimumCppStandard: 17
6160
6261
dependencies: yup_graphics [other_dependencies]
6362
searchpaths: native
@@ -337,9 +336,9 @@ yup::Result performOperation()
337336
yup::ResultValue<int> maybeGetInteger()
338337
{
339338
if (preconditionFailed)
340-
return yup::ResultValue<int>::fail ("Precondition not met");
339+
return yup::makeResultValueFail ("Precondition not met");
341340

342-
return 1;
341+
return 1; // or yup::makeResultValueOk (1)
343342
}
344343

345344
// Use assertions for programming errors

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ if (YUP_BUILD_EXAMPLES)
7878
add_subdirectory (examples/graphics)
7979
if (YUP_PLATFORM_DESKTOP)
8080
add_subdirectory (examples/plugin)
81+
add_subdirectory (examples/audiograph)
8182
endif()
8283
endif()
8384

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
<a href="./examples/graphics/source/examples/ColorLab.h"><img src="./docs/images/yup_color_picker.png" style="width:51.8%;" /></a>
2626
</div>
2727

28+
<div style="display: flex; width: 100%; flex-wrap: nowrap;">
29+
<a href="./examples/graphics/source/examples/AudioGraph.h"><img src="./docs/images/yup_audio_graph.png" style="width:49%;" /></a>
30+
<a href="./examples/graphics/source/examples/AudioFileDemo.h"><img src="./docs/images/yup_audio_waveform.png" style="width:49%;" /></a>
31+
</div>
32+
33+
<div style="display: flex; width: 100%; flex-wrap: nowrap;">
34+
<a href="./examples/graphics/source/examples/AudioHost.h"><img src="./docs/images/yup_audio_host.png" style="width:99%;" /></a>
35+
</div>
36+
2837
<div style="display: flex; width: 100%; flex-wrap: nowrap;">
2938
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_rbj.png" style="width:26.5%;" /></a>
3039
<a href="./examples/graphics/source/examples/FilterDemo.h"><img src="./docs/images/yup_dsp_filter_butter.png" style="width:26.5%;" /></a>
@@ -113,6 +122,14 @@ YUP brings a suite of powerful features, including:
113122
| **Linux** | :construction: | :construction: | | | | | |
114123

115124

125+
## Supported Plugin Hosting Formats
126+
| | **CLAP** | **VST3** | **VST2** | **AUv3** | **AUv2** | **AAX** | **LV2** |
127+
|--------------------------|:------------------:|:------------------:|:------------------:|:------------------:|:-------------------------:|:---------------------:|:---------------------:|
128+
| **Windows** | :construction: | :construction: | | | | | |
129+
| **macOS** | :construction: | :construction: | | | :white_check_mark: | | |
130+
| **Linux** | :construction: | :construction: | | | | | |
131+
132+
116133
## Supported Sound Formats
117134

118135
| | **Wav** | **Wav64** | **Mp3** | **OGG** | **Flac** | **Opus** | **AAC** | **WMF** |
@@ -130,6 +147,7 @@ YUP brings a suite of powerful features, including:
130147
| **iOS** (enc) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
131148
| **iOS** (dec) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
132149

150+
133151
## Prerequisites
134152
Before building, ensure you have a:
135153
- C++20-compliant compiler

cmake/yup_audio_plugin.cmake

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ function (yup_audio_plugin)
9191
_yup_fetch_sdl2()
9292
list (APPEND additional_libraries sdl2::sdl2)
9393

94+
_yup_target_list_contains ("${YUP_ARG_MODULES}" yup_audio_plugin_host has_audio_plugin_host)
95+
if (has_audio_plugin_host)
96+
_yup_collect_audio_plugin_host_dependencies ("${YUP_ARG_DEFINITIONS}" audio_plugin_host_libraries)
97+
list (APPEND additional_libraries ${audio_plugin_host_libraries})
98+
if (audio_plugin_host_libraries)
99+
target_link_libraries (${target_name}_shared INTERFACE
100+
${audio_plugin_host_libraries})
101+
endif()
102+
endif()
103+
94104
# ==== Fetch clap SDK and build clap target
95105
if (YUP_ARG_PLUGIN_CREATE_CLAP)
96-
_yup_message (STATUS "Fetching CLAP SDK")
97-
_yup_fetchcontent_declare (clap
98-
GIT_REPOSITORY https://github.com/free-audio/clap.git
99-
GIT_TAG main)
100-
FetchContent_MakeAvailable (clap)
101-
set_target_properties (clap-tests PROPERTIES FOLDER "Tests")
106+
_yup_fetch_clap()
102107

103108
_yup_message (STATUS "Setting up CLAP plugin client")
104109
_yup_module_setup_plugin_client (
@@ -144,22 +149,7 @@ function (yup_audio_plugin)
144149

145150
# ==== Fetch vst3 SDK and build vst3 target
146151
if (YUP_ARG_PLUGIN_CREATE_VST3)
147-
_yup_message (STATUS "Fetching VST3 SDK")
148-
set (SMTG_CREATE_MODULE_INFO OFF)
149-
set (SMTG_ADD_VST3_UTILITIES OFF)
150-
set (SMTG_ENABLE_VST3_HOSTING_EXAMPLES OFF)
151-
set (SMTG_ENABLE_VST3_PLUGIN_EXAMPLES OFF)
152-
set (SMTG_ENABLE_VSTGUI_SUPPORT OFF)
153-
set (SMTG_CREATE_PLUGIN_LINK OFF)
154-
if (NOT YUP_PLATFORM_MAC OR XCODE)
155-
set (SMTG_RUN_VST_VALIDATOR ON)
156-
else()
157-
set (SMTG_RUN_VST_VALIDATOR OFF)
158-
endif()
159-
_yup_fetchcontent_declare (vst3sdk
160-
GIT_REPOSITORY https://github.com/steinbergmedia/vst3sdk.git
161-
GIT_TAG master)
162-
FetchContent_MakeAvailable (vst3sdk)
152+
_yup_fetch_vst3sdk()
163153

164154
_yup_message (STATUS "Setting up VST3 plugin client")
165155
smtg_enable_vst3_sdk()

cmake/yup_dependencies.cmake

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,157 @@ endfunction()
7777

7878
#==============================================================================
7979

80+
function (_yup_fetch_clap)
81+
if (NOT TARGET clap)
82+
_yup_message (STATUS "Fetching CLAP SDK")
83+
_yup_fetchcontent_declare (clap
84+
GIT_REPOSITORY https://github.com/free-audio/clap.git
85+
GIT_TAG main)
86+
87+
FetchContent_MakeAvailable (clap)
88+
endif()
89+
90+
if (TARGET clap-tests)
91+
set_target_properties (clap-tests PROPERTIES FOLDER "Tests")
92+
endif()
93+
endfunction()
94+
95+
#==============================================================================
96+
97+
function (_yup_fetch_vst3sdk)
98+
if (NOT TARGET sdk)
99+
_yup_message (STATUS "Fetching VST3 SDK")
100+
101+
set (SMTG_CREATE_MODULE_INFO OFF)
102+
set (SMTG_ADD_VST3_UTILITIES OFF)
103+
set (SMTG_ENABLE_VST3_HOSTING_EXAMPLES OFF)
104+
set (SMTG_ENABLE_VST3_PLUGIN_EXAMPLES OFF)
105+
set (SMTG_ENABLE_VSTGUI_SUPPORT OFF)
106+
set (SMTG_CREATE_PLUGIN_LINK OFF)
107+
if (NOT YUP_PLATFORM_MAC OR XCODE)
108+
set (SMTG_RUN_VST_VALIDATOR ON)
109+
else()
110+
set (SMTG_RUN_VST_VALIDATOR OFF)
111+
endif()
112+
113+
_yup_fetchcontent_declare (vst3sdk
114+
GIT_REPOSITORY https://github.com/steinbergmedia/vst3sdk.git
115+
GIT_TAG master)
116+
117+
FetchContent_MakeAvailable (vst3sdk)
118+
endif()
119+
120+
if (NOT TARGET yup_audio_plugin_host_vst3sdk)
121+
add_library (yup_audio_plugin_host_vst3sdk INTERFACE)
122+
target_link_libraries (yup_audio_plugin_host_vst3sdk INTERFACE sdk)
123+
124+
set (vst3sdk_source_dir "")
125+
if (DEFINED vst3sdk_SOURCE_DIR)
126+
set (vst3sdk_source_dir "${vst3sdk_SOURCE_DIR}")
127+
elseif (TARGET sdk)
128+
get_target_property (vst3sdk_source_dir sdk SOURCE_DIR)
129+
endif()
130+
131+
set (vst3sdk_memorystream_source "${vst3sdk_source_dir}/public.sdk/source/common/memorystream.cpp")
132+
if (vst3sdk_source_dir AND EXISTS "${vst3sdk_memorystream_source}")
133+
target_sources (yup_audio_plugin_host_vst3sdk INTERFACE "${vst3sdk_memorystream_source}")
134+
endif()
135+
136+
set (vst3sdk_parameterchanges_source "${vst3sdk_source_dir}/public.sdk/source/vst/hosting/parameterchanges.cpp")
137+
if (vst3sdk_source_dir AND EXISTS "${vst3sdk_parameterchanges_source}")
138+
target_sources (yup_audio_plugin_host_vst3sdk INTERFACE "${vst3sdk_parameterchanges_source}")
139+
endif()
140+
141+
set (vst3sdk_eventlist_source "${vst3sdk_source_dir}/public.sdk/source/vst/hosting/eventlist.cpp")
142+
if (vst3sdk_source_dir AND EXISTS "${vst3sdk_eventlist_source}")
143+
target_sources (yup_audio_plugin_host_vst3sdk INTERFACE "${vst3sdk_eventlist_source}")
144+
endif()
145+
endif()
146+
endfunction()
147+
148+
#==============================================================================
149+
150+
function (_yup_target_list_contains target_list target_name output_variable)
151+
foreach (target IN LISTS target_list)
152+
if ("${target}" STREQUAL "${target_name}" OR "${target}" STREQUAL "yup::${target_name}")
153+
set (${output_variable} ON PARENT_SCOPE)
154+
return()
155+
endif()
156+
157+
if (TARGET "${target}")
158+
get_target_property (aliased_target "${target}" ALIASED_TARGET)
159+
if ("${aliased_target}" STREQUAL "${target_name}")
160+
set (${output_variable} ON PARENT_SCOPE)
161+
return()
162+
endif()
163+
endif()
164+
endforeach()
165+
166+
set (${output_variable} OFF PARENT_SCOPE)
167+
endfunction()
168+
169+
#==============================================================================
170+
171+
function (_yup_definitions_enable definitions definition_name output_variable)
172+
set (enabled OFF)
173+
174+
foreach (definition IN LISTS definitions)
175+
string (REGEX REPLACE "^-D" "" normalized_definition "${definition}")
176+
177+
if (normalized_definition MATCHES "^${definition_name}($|=)")
178+
set (enabled ON)
179+
180+
if (normalized_definition MATCHES "^${definition_name}=")
181+
string (REGEX REPLACE "^${definition_name}=(.*)$" "\\1" definition_value "${normalized_definition}")
182+
string (STRIP "${definition_value}" definition_value)
183+
string (REGEX REPLACE "^\"(.*)\"$" "\\1" definition_value "${definition_value}")
184+
string (REGEX REPLACE "^'(.*)'$" "\\1" definition_value "${definition_value}")
185+
string (TOUPPER "${definition_value}" definition_value)
186+
187+
if ("${definition_value}" STREQUAL "0"
188+
OR "${definition_value}" STREQUAL "OFF"
189+
OR "${definition_value}" STREQUAL "FALSE"
190+
OR "${definition_value}" STREQUAL "NO")
191+
set (enabled OFF)
192+
endif()
193+
endif()
194+
endif()
195+
endforeach()
196+
197+
set (${output_variable} "${enabled}" PARENT_SCOPE)
198+
endfunction()
199+
200+
#==============================================================================
201+
202+
function (_yup_collect_audio_plugin_host_dependencies definitions output_variable)
203+
set (dependencies "")
204+
205+
_yup_definitions_enable ("${definitions}" YUP_AUDIO_PLUGIN_HOST_ENABLE_CLAP enable_clap)
206+
if (enable_clap)
207+
_yup_fetch_clap()
208+
list (APPEND dependencies clap)
209+
endif()
210+
211+
_yup_definitions_enable ("${definitions}" YUP_AUDIO_PLUGIN_HOST_ENABLE_VST3 enable_vst3)
212+
if (enable_vst3)
213+
_yup_fetch_vst3sdk()
214+
list (APPEND dependencies yup_audio_plugin_host_vst3sdk)
215+
endif()
216+
217+
_yup_definitions_enable ("${definitions}" YUP_AUDIO_PLUGIN_HOST_ENABLE_AU enable_au)
218+
if (enable_au AND YUP_PLATFORM_MAC)
219+
list (APPEND dependencies
220+
"-framework AudioUnit"
221+
"-framework AudioToolbox"
222+
"-framework CoreAudio"
223+
"-framework CoreFoundation")
224+
endif()
225+
226+
set (${output_variable} "${dependencies}" PARENT_SCOPE)
227+
endfunction()
228+
229+
#==============================================================================
230+
80231
function (_yup_fetch_perfetto)
81232
if (TARGET perfetto::perfetto)
82233
return()

cmake/yup_modules.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ function (yup_add_module module_path modules_definitions module_group)
802802
list (APPEND module_defines ${module_definition})
803803
endforeach()
804804

805+
if ("${module_name}" STREQUAL "yup_audio_plugin_host")
806+
_yup_collect_audio_plugin_host_dependencies ("${module_defines}" audio_plugin_host_dependencies)
807+
list (APPEND module_dependencies ${audio_plugin_host_dependencies})
808+
endif()
809+
805810
# ==== Prepare include paths
806811
get_filename_component (module_include_path ${module_path} DIRECTORY)
807812
list (APPEND module_include_paths "${module_include_path}" "${module_path}")

cmake/yup_standalone.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function (yup_standalone_app)
102102
list (APPEND additional_libraries perfetto::perfetto)
103103
endif()
104104

105+
if (YUP_PLATFORM_DESKTOP)
106+
_yup_target_list_contains ("${YUP_ARG_MODULES}" yup_audio_plugin_host has_audio_plugin_host)
107+
if (has_audio_plugin_host)
108+
_yup_collect_audio_plugin_host_dependencies ("${YUP_ARG_DEFINITIONS}" audio_plugin_host_libraries)
109+
list (APPEND additional_libraries ${audio_plugin_host_libraries})
110+
endif()
111+
endif()
112+
105113
# ==== Prepare executable
106114
set (executable_options "")
107115
if (NOT "${target_console}")

docs/images/yup_audio_graph.png

62.5 KB
Loading

docs/images/yup_audio_host.png

571 KB
Loading

0 commit comments

Comments
 (0)