Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion App.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# `docs/CMake API.md` in the JUCE repo for the full list.

if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
set(_needs_web_browser NEEDS_WEB_BROWSER TRUE)
# NEEDS_WEBVIEW2 links the WebView2 SDK on Windows (see WebView2.cmake); ignored elsewhere
set(_needs_web_browser NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE)
endif()

juce_add_gui_app(RNBOApp
Expand Down Expand Up @@ -54,6 +55,10 @@ if(RNBO_EDITOR_MODE STREQUAL "NATIVE")
include(${NATIVE_EDITOR_DIR}/CMakeLists.txt)
elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
include(${WEB_EDITOR_DIR}/CMakeLists.txt)
if(WIN32)
# Enables the WebView2 backend, which WebBrowserComponent needs on Windows for withResourceProvider
target_compile_definitions(RNBOApp PUBLIC JUCE_USE_WIN_WEBVIEW2_WITH_STATIC_LINKING=1)
endif()
endif()

if (EXISTS ${RNBO_BINARY_DATA_FILE})
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ mark_as_advanced(RNBO_CLASS_FILE_NAME)

set(RNBO_CLASS_NAME "rnbomatic")
set(RNBO_CLASS_FILE "${RNBO_EXPORT_DIR}/${RNBO_CLASS_FILE_NAME}")
if(NOT EXISTS "${RNBO_CLASS_FILE}")
message(FATAL_ERROR
"RNBO class file not found: ${RNBO_CLASS_FILE}\n"
"Export your RNBO patch to ${RNBO_EXPORT_DIR}, and make sure RNBO_CLASS_FILE_NAME "
"matches the exported .cpp file name (currently \"${RNBO_CLASS_FILE_NAME}\").\n"
"In Windows PowerShell, quote the whole argument so the name isn't split at the period, "
"e.g. \"-DRNBO_CLASS_FILE_NAME=my_patch.cpp\"")
endif()
set(RNBO_DESCRIPTION_FILE "${RNBO_EXPORT_DIR}/description.json")
set(RNBO_PRESETS_FILE "${RNBO_EXPORT_DIR}/presets.json")
set(RNBO_BINARY_DATA_FILE "${RNBO_EXPORT_DIR}/${RNBO_CLASS_NAME}_binary.cpp")
Expand Down Expand Up @@ -64,6 +72,10 @@ add_subdirectory(
# Compile web UI files into the binary — only needed for the WEBVIEW editor.
if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
add_subdirectory(${WEB_EDITOR_DIR})
# Windows also needs the WebView2 SDK, fetched here if it isn't already installed
if(WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/WebView2.cmake)
endif()
endif()

# Create the correct UI header depending on UI style
Expand Down
4 changes: 3 additions & 1 deletion CUSTOM_UI.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For most people, we recommend starting with the web-based approach.

## Prerequisites

If you haven't yet followed the setup steps in [README.md](./README.md), you should do so before you follow this tutorial. If you want to follow the guide for building a web-based interface, you will also need to install [Node.js](https://nodejs.org/).
If you haven't yet followed the setup steps in [README.md](./README.md), you should do so before you follow this tutorial. If you want to follow the guide for building a web-based interface, you will also need to install [Node.js](https://nodejs.org/). On Windows, CMake will also download the Microsoft WebView2 SDK the first time you configure the web UI build; see [Choosing a UI system](./README.md#choosing-a-ui-system) for details.

## Switching UI

Expand Down Expand Up @@ -67,6 +67,8 @@ cd build
cmake .. -DRNBO_CLASS_FILE_NAME=three-param-kink.cpp -DRNBO_EDITOR_MODE=WEBVIEW
```

> In Windows PowerShell, quote the class file argument (`"-DRNBO_CLASS_FILE_NAME=three-param-kink.cpp"`), otherwise PowerShell splits it at the period. See [Renaming your export source](./README.md#renaming-your-export-source).

If you look in `src/CustomAudioProcessor.cpp`, you'll see code like this:

```cpp
Expand Down
7 changes: 6 additions & 1 deletion Plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ endif()
# Check the readme at `docs/CMake API.md` in the JUCE repo for the full list.

if(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
set(_needs_web_browser NEEDS_WEB_BROWSER TRUE)
# NEEDS_WEBVIEW2 links the WebView2 SDK on Windows (see WebView2.cmake); ignored elsewhere
set(_needs_web_browser NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE)
endif()

juce_add_plugin(RNBOAudioPlugin
Expand Down Expand Up @@ -65,6 +66,10 @@ if(RNBO_EDITOR_MODE STREQUAL "NATIVE")
include(${NATIVE_EDITOR_DIR}/CMakeLists.txt)
elseif(RNBO_EDITOR_MODE STREQUAL "WEBVIEW")
include(${WEB_EDITOR_DIR}/CMakeLists.txt)
if(WIN32)
# Enables the WebView2 backend, which WebBrowserComponent needs on Windows for withResourceProvider
target_compile_definitions(RNBOAudioPlugin PUBLIC JUCE_USE_WIN_WEBVIEW2_WITH_STATIC_LINKING=1)
endif()
endif()

if (EXISTS ${RNBO_BINARY_DATA_FILE})
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ By default, the build script looks for a RNBO export in the `export` folder name
cmake -DRNBO_CLASS_FILE_NAME=slime_sound.cpp -G Ninja ..
```

**Windows PowerShell:** PowerShell splits unquoted arguments like this one at the period, so CMake only sees `slime_sound`. Wrap the whole argument in quotes: `"-DRNBO_CLASS_FILE_NAME=slime_sound.cpp"`.

#### Choosing a UI system

RNBO provides a default interface for audio plugins, which simply creates a slider for each parameter in your RNBO patch. If you want to create a custom interface, you can configure CMake to use a different interface system.
Expand All @@ -141,6 +143,12 @@ The second uses a WebBrowserComponent to build a UI using HTML/CSS/JS.
cmake -DRNBO_EDITOR_MODE=WEBVIEW ..
```

**Windows:** the WEBVIEW editor uses Microsoft's WebView2, which needs the WebView2 SDK at build time. If the SDK isn't already installed through NuGet, CMake downloads it (about 9 MB) into `build/_deps/webview2` the first time you configure. To use a copy you already have, for example when building offline, point CMake at the directory containing the `Microsoft.Web.WebView2.*` package folder:

```sh
cmake -DRNBO_EDITOR_MODE=WEBVIEW -DJUCE_WEBVIEW2_PACKAGE_LOCATION=C:/path/to/packages ..
```

By default, `NATIVE` sources its C++ files from `src/nativeui` and `WEBVIEW` sources its files from `src/webui`. If you want to supply your own implementation — for example, to keep your custom UI in a separate directory or a separate repository — you can override either path at configure time:

```sh
Expand Down
48 changes: 48 additions & 0 deletions WebView2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# On Windows, the WEBVIEW editor needs the Microsoft WebView2 SDK. JUCE looks for it in the local
# NuGet package folder, or in JUCE_WEBVIEW2_PACKAGE_LOCATION if that is set. If neither has it, we
# download the NuGet package into the build tree and point JUCE at it.
#
# To use your own copy (e.g. for offline builds), configure with
# cmake -DJUCE_WEBVIEW2_PACKAGE_LOCATION=<dir containing Microsoft.Web.WebView2.*> ..

set(WEBVIEW2_VERSION "1.0.3485.44")
set(WEBVIEW2_SHA256 "bc09150b179246ac90189649b13be8e6b11b3ac200e817e18df106e1f3cf489e")

file(GLOB _webview2_nuget_packages "$ENV{USERPROFILE}/AppData/Local/PackageManagement/NuGet/Packages/*Microsoft.Web.WebView2*")

if(JUCE_WEBVIEW2_PACKAGE_LOCATION)
message(STATUS "Using WebView2 SDK from ${JUCE_WEBVIEW2_PACKAGE_LOCATION}")
elseif(_webview2_nuget_packages)
message(STATUS "Using WebView2 SDK from the local NuGet package folder")
else()
set(_webview2_root "${CMAKE_BINARY_DIR}/_deps/webview2")
set(_webview2_dir "${_webview2_root}/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")

if(NOT EXISTS "${_webview2_dir}/build/native/include/WebView2.h")
set(_webview2_nupkg "${_webview2_root}/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}.nupkg")
message(STATUS "Downloading WebView2 SDK ${WEBVIEW2_VERSION}")

file(DOWNLOAD
"https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}"
"${_webview2_nupkg}"
EXPECTED_HASH SHA256=${WEBVIEW2_SHA256}
STATUS _webview2_status)

list(GET _webview2_status 0 _webview2_status_code)
if(NOT _webview2_status_code EQUAL 0)
list(GET _webview2_status 1 _webview2_status_message)
message(FATAL_ERROR
"Failed to download the WebView2 SDK: ${_webview2_status_message}\n"
"Install it manually from a PowerShell prompt:\n"
"> Register-PackageSource -provider NuGet -name nugetRepository -location https://www.nuget.org/api/v2\n"
"> Install-Package Microsoft.Web.WebView2 -Scope CurrentUser -RequiredVersion ${WEBVIEW2_VERSION} -Source nugetRepository\n"
"or pass -DJUCE_WEBVIEW2_PACKAGE_LOCATION=<dir> pointing at an existing copy.")
endif()

file(ARCHIVE_EXTRACT INPUT "${_webview2_nupkg}" DESTINATION "${_webview2_dir}")
file(REMOVE "${_webview2_nupkg}")
endif()

set(JUCE_WEBVIEW2_PACKAGE_LOCATION "${_webview2_root}")
message(STATUS "Using WebView2 SDK from ${_webview2_dir}")
endif()
Loading