From f76d93112738771f597c684a06347676cb8f90ee Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 18 Sep 2022 22:06:59 +0100 Subject: [PATCH] Add patch to fix initial AU sample rate mismatch --- .github/workflows/build.yml | 2 + ...b6dcc7d17d35ed31dc9761a46eb510a668ac.patch | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 jucewrapper/bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c4833b..4f20a47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -532,6 +532,7 @@ jobs: if [ "${{ env.WITH_LTO }}" != "true" ]; then export PAWPAW_SKIP_LTO=1; fi pushd deps/PawPaw; source local.env macos; popd git clone --depth=1 -b 6.1.6 https://github.com/juce-framework/JUCE.git jucewrapper/JUCE + patch -d jucewrapper/JUCE -p1 -i ../bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch sed -i -e 's/kAudioUnitProperty_SupportsMPE/kAudioUnitProperty_ignore_SupportsMPE/' jucewrapper/JUCE/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h mkdir -p jucewrapper/build pushd jucewrapper/build; cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.8 -DCMAKE_OSX_SYSROOT="macosx" -DCMAKE_BUILD_TYPE=Release .. && make VERBOSE=1 -j $(sysctl -n hw.logicalcpu); popd @@ -621,6 +622,7 @@ jobs: if [ "${{ env.WITH_LTO }}" != "true" ]; then export PAWPAW_SKIP_LTO=1; fi pushd deps/PawPaw; source local.env macos-universal; popd git clone --depth=1 -b 6.1.6 https://github.com/juce-framework/JUCE.git jucewrapper/JUCE + patch -d jucewrapper/JUCE -p1 -i ../bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch mkdir -p jucewrapper/build pushd jucewrapper/build; cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DCMAKE_OSX_SYSROOT="macosx" -DCMAKE_BUILD_TYPE=Release .. && make VERBOSE=1 -j $(sysctl -n hw.logicalcpu); popd mv jucewrapper/build/*_artefacts/Release/AU/*.component bin/ diff --git a/jucewrapper/bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch b/jucewrapper/bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch new file mode 100644 index 0000000..9476e37 --- /dev/null +++ b/jucewrapper/bf85b6dcc7d17d35ed31dc9761a46eb510a668ac.patch @@ -0,0 +1,51 @@ +From bf85b6dcc7d17d35ed31dc9761a46eb510a668ac Mon Sep 17 00:00:00 2001 +From: Sebastian Kraft +Date: Fri, 6 May 2022 09:09:34 +0200 +Subject: [PATCH] Always set sample rate of hosted AU plugins, fixes a bug with + plugins reporting incorrect sample rates + +--- + .../juce_AudioUnitPluginFormat.mm | 25 ++++++++----------- + 1 file changed, 11 insertions(+), 14 deletions(-) + +diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +index 59c0e06d368..8ee8f9a465c 100644 +--- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm ++++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +@@ -1057,25 +1057,22 @@ void prepareToPlay (double newSampleRate, int estimatedSamplesPerBlock) override + + AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SampleRate, scope, static_cast (i), &sampleRate, &sampleRateSize); + +- if (sampleRate != sr) ++ if (isAUv3) // setting kAudioUnitProperty_SampleRate fails on AUv3s + { +- if (isAUv3) // setting kAudioUnitProperty_SampleRate fails on AUv3s +- { +- AudioStreamBasicDescription stream; +- UInt32 dataSize = sizeof (stream); +- auto err = AudioUnitGetProperty (audioUnit, kAudioUnitProperty_StreamFormat, scope, static_cast (i), &stream, &dataSize); ++ AudioStreamBasicDescription stream; ++ UInt32 dataSize = sizeof (stream); ++ auto err = AudioUnitGetProperty (audioUnit, kAudioUnitProperty_StreamFormat, scope, static_cast (i), &stream, &dataSize); + +- if (err == noErr && dataSize == sizeof (stream)) +- { +- stream.mSampleRate = sr; +- AudioUnitSetProperty (audioUnit, kAudioUnitProperty_StreamFormat, scope, static_cast (i), &stream, sizeof (stream)); +- } +- } +- else ++ if (err == noErr && dataSize == sizeof (stream)) + { +- AudioUnitSetProperty (audioUnit, kAudioUnitProperty_SampleRate, scope, static_cast (i), &sr, sizeof (sr)); ++ stream.mSampleRate = sr; ++ AudioUnitSetProperty (audioUnit, kAudioUnitProperty_StreamFormat, scope, static_cast (i), &stream, sizeof (stream)); + } + } ++ else ++ { ++ AudioUnitSetProperty (audioUnit, kAudioUnitProperty_SampleRate, scope, static_cast (i), &sr, sizeof (sr)); ++ } + + if (isInput) + {