From 0e12c2da92f3d32d7157aa0a8e8bcb22197805dd Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Mon, 2 Dec 2024 15:24:16 +0000 Subject: [PATCH] VST3 Client: Fix an issue with the reporting of VST3 plugin IDs --- .../utilities/juce_VST3ClientExtensions.cpp | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/modules/juce_audio_processors/utilities/juce_VST3ClientExtensions.cpp b/modules/juce_audio_processors/utilities/juce_VST3ClientExtensions.cpp index b3cd133bb8..8cb875b114 100644 --- a/modules/juce_audio_processors/utilities/juce_VST3ClientExtensions.cpp +++ b/modules/juce_audio_processors/utilities/juce_VST3ClientExtensions.cpp @@ -74,13 +74,39 @@ VST3ClientExtensions::InterfaceId VST3ClientExtensions::convertJucePluginId (uin return 0; }); - std::array data; - std::memcpy (&data[0], &word0, sizeof (word0)); - std::memcpy (&data[4], &word1, sizeof (word1)); - std::memcpy (&data[8], &manufacturerCode, sizeof (manufacturerCode)); - std::memcpy (&data[12], &pluginCode, sizeof (pluginCode)); + constexpr auto getByteFromLSB = [] (uint32_t word, int byteIndex) + { + jassert (isPositiveAndNotGreaterThan (byteIndex, 3)); + return (std::byte) ((word >> (byteIndex * 8)) & 0xff); + }; - return data; + #if JUCE_WINDOWS + constexpr auto isWindows = true; + #else + constexpr auto isWindows = false; + #endif + + return { + getByteFromLSB (word0, isWindows ? 0 : 3), + getByteFromLSB (word0, isWindows ? 1 : 2), + getByteFromLSB (word0, isWindows ? 2 : 1), + getByteFromLSB (word0, isWindows ? 3 : 0), + + getByteFromLSB (word1, isWindows ? 2 : 3), + getByteFromLSB (word1, isWindows ? 3 : 2), + getByteFromLSB (word1, isWindows ? 0 : 1), + getByteFromLSB (word1, isWindows ? 1 : 0), + + getByteFromLSB (manufacturerCode, 3), + getByteFromLSB (manufacturerCode, 2), + getByteFromLSB (manufacturerCode, 1), + getByteFromLSB (manufacturerCode, 0), + + getByteFromLSB (pluginCode, 3), + getByteFromLSB (pluginCode, 2), + getByteFromLSB (pluginCode, 1), + getByteFromLSB (pluginCode, 0) + }; } VST3ClientExtensions::InterfaceId VST3ClientExtensions::convertVST2PluginId (uint32_t pluginCode,