From d3bc57b280912fab13556144d6db3a5f6c531f6b Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 20 Dec 2024 20:52:59 -0500 Subject: [PATCH] Fix a parameter threading error; Juce8 in CI; CPM upgrade I had mistakenly thought htat the value change listeners on param were not audio safe, so moved them to the main thread. This was wrong, and this commit corrects that. While in there add a Juce 8 test, which restructured CI a smidge and also upgrade CPM since it throws a warning with newer cmakes --- .github/workflows/build-cmake.yml | 13 ++-- .gitignore | 112 ++++++++++++++++++++++++++++-- CMakeLists.txt | 4 +- README.md | 2 +- examples/cmake/CPM.cmake | 28 +++----- src/wrapper/clap-juce-wrapper.cpp | 12 ++++ 6 files changed, 139 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build-cmake.yml b/.github/workflows/build-cmake.yml index 8c42ae2..12d66d2 100644 --- a/.github/workflows/build-cmake.yml +++ b/.github/workflows/build-cmake.yml @@ -12,22 +12,23 @@ on: jobs: build_and_test: - name: Build example plugins with CMake and JUCE ${{ matrix.juce_version }} on ${{ matrix.os }} + name: JUCE ${{ matrix.juce_version }} / ${{ matrix.os }} CMake example plugins runs-on: ${{ matrix.os }} strategy: fail-fast: false # show all errors for each platform (vs. cancel jobs on error) matrix: - os: [ubuntu-latest, windows-2019, macOS-latest] - juce_version: ["6.0.7", "6.1.5", "6.1.6", "7.0.0", "7.0.6"] + os: [ubuntu-latest, windows-2019, macOS-latest] # win 2019 needed for juce 6 + juce_version: ["6.0.7", "6.1.5", "6.1.6", "7.0.0", "7.0.6", "7.0.12","8.0.4"] + steps: - name: Install Linux Deps if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt install libasound2-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev libfreetype6-dev libglu1-mesa-dev libjack-jackd2-dev - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9 + sudo apt install libasound2-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev libfreetype6-dev libfontconfig1-dev libglu1-mesa-dev libjack-jackd2-dev + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 - name: Get latest CMake uses: lukka/get-cmake@latest diff --git a/.gitignore b/.gitignore index 9b4f163..eec1b72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,110 @@ -build*/ -Builds/ -JuceLibraryCode/ +# Prerequisites +*.d -.vscode/ -.idea/ +# Compiled Object files +*.slo +*.lo +*.o +*.obj +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Visual Studio +obj/ +*.sln +*.vcxproj +*.vcxproj.filters +*.vcxproj.user +.vs/ +packages/ +target/ +*.pdb +packages.config +CMakeSettings.json +.vscode +.cache + +# XCode +Surge.xcworkspace/ +surge-au.xcodeproj/ +surge-vst2.xcodeproj/ +surge-vst3.xcodeproj/ +surge-headless.xcodeproj/ +products/ +installer_mac/installer +installer_mac/*.dmg +installer_osx/installer +installer_osx/Install_Surge_*.dmg +build_logs/ +fxbuild/ .DS_Store + +# IntelliJ IDEA +.idea + +# Linux +Makefile +surge-*.make +premake-stamp +cmake-stamp +/Debug +*.deb + +# Qt Creator +*.txt.user +*.txt.user.* + +# CMake +build/ +build32/ +buildlin/ +buildlin-*/ +buildmac/ +buildwin/ +buildxt/ +build-arm/ +build_lv2 +buildiwyu/ +buildpy/ +cmake-build-*/ +bwd/ +CMakeUserPresets.json + +# Reaper +*.RPP-bak + +VERSION_GIT_INFO +.clang-tidy + +# Juce until we add a submodule +libs/juce-* + +# A place for BP to store stuff +ignore/* +__pycache__ +minst.sh + +Testing/ +installer-tmp/ diff --git a/CMakeLists.txt b/CMakeLists.txt index d269fab..85ba289 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ cmake_minimum_required (VERSION 3.21 FATAL_ERROR) get_directory_property(parent_dir PARENT_DIRECTORY) if ("${parent_dir}" STREQUAL "") - # OSX deployment target needs to be set before the `project()` call - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment target") + # OSX deployment target needs to be set before the `project()` call. Move to 10.11 to allow Juce8 + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment target") set(is_toplevel 1) else () set(is_toplevel 0) diff --git a/README.md b/README.md index 642e79d..b3fdd01 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# JUCE6 and 7 Unofficial CLAP Plugin Support +# JUCE6, 7 and 8 Unofficial CLAP Plugin Support This is a set of code which, combined with a JUCE 6 or JUCE 7 plugin project, allows you to build a CLAP plugin. It is licensed under the MIT license, and can be used for both open and closed source projects. diff --git a/examples/cmake/CPM.cmake b/examples/cmake/CPM.cmake index eaa397b..baf2d8c 100644 --- a/examples/cmake/CPM.cmake +++ b/examples/cmake/CPM.cmake @@ -1,4 +1,9 @@ -set(CPM_DOWNLOAD_VERSION 0.36.0) +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors + +set(CPM_DOWNLOAD_VERSION 0.40.2) +set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d") if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") @@ -11,22 +16,9 @@ endif() # Expand relative path. This is important if the provided path contains a tilde (~) get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) -function(download_cpm) - message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") - file(DOWNLOAD - https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} - ) -endfunction() - -if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - download_cpm() -else() - # resume download if it previously failed - file(READ ${CPM_DOWNLOAD_LOCATION} check) - if("${check}" STREQUAL "") - download_cpm() - endif() -endif() +file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} +) include(${CPM_DOWNLOAD_LOCATION}) diff --git a/src/wrapper/clap-juce-wrapper.cpp b/src/wrapper/clap-juce-wrapper.cpp index 688f3f6..671276a 100644 --- a/src/wrapper/clap-juce-wrapper.cpp +++ b/src/wrapper/clap-juce-wrapper.cpp @@ -1383,14 +1383,25 @@ class ClapJuceWrapper : public clap::helpers::Plugin< param.processorParam->setValue(newValue); +#if 0 // PARAM_LISTENERS_ON_MAIN_THREAD // we want to trigger the parameter listener callbacks on the main thread, // but MessageManager::callAsync is not safe to call from the audio thread. + // This assumption though turns out to be wrong. We want to call the listener + // from the audio thread and leave it up to the pugin to be smart. audioThreadParamListenerQ.push(ParamListenerCall{param.processorParam, newValue}); _host.requestCallback(); +#else + { + juce::ScopedValueSetter suppressCallbacks{supressParameterChangeMessages, true}; + param.processorParam->sendValueChangedMessageToListeners(newValue); + } +#endif + } void onMainThread() noexcept override { +#if 0 // PARAM_LISTENERS_ON_MAIN_THREAD // handle parameter change listener callbacks juce::ScopedValueSetter suppressCallbacks{supressParameterChangeMessages, true}; ParamListenerCall listenerCall{}; @@ -1398,6 +1409,7 @@ class ClapJuceWrapper : public clap::helpers::Plugin< { listenerCall.parameter->sendValueChangedMessageToListeners(listenerCall.newValue); } +#endif } bool implementsLatency() const noexcept override { return true; }