Skip to content

Commit

Permalink
Fix a parameter threading error; Juce8 in CI; CPM upgrade
Browse files Browse the repository at this point in the history
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
  • Loading branch information
baconpaul authored Dec 21, 2024
1 parent e3c3abe commit d3bc57b
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 32 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
112 changes: 107 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
28 changes: 10 additions & 18 deletions examples/cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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})
12 changes: 12 additions & 0 deletions src/wrapper/clap-juce-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,21 +1383,33 @@ 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<bool> 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<bool> suppressCallbacks{supressParameterChangeMessages, true};
ParamListenerCall listenerCall{};
while (audioThreadParamListenerQ.pop(listenerCall))
{
listenerCall.parameter->sendValueChangedMessageToListeners(listenerCall.newValue);
}
#endif
}

bool implementsLatency() const noexcept override { return true; }
Expand Down

0 comments on commit d3bc57b

Please # to comment.