From 2678c1d10df99c94a68a4c9d82e565a0555de2be Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 30 Dec 2021 20:23:27 +0000 Subject: [PATCH] AUv3 Wrapper: Use correct timestamps for outgoing events Previously, with two instances of the MIDILogger AUv3 in series in Logic, the timestamps received by the second plugin in the chain would not match the timestamps of the events emitted by the first plugin. --- modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index d679b3efa1..5b4b129ef4 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -1607,7 +1607,11 @@ private: { if (auto midiOut = midiOutputEventBlock) for (const auto metadata : midiMessages) - midiOut (metadata.samplePosition, 0, metadata.numBytes, metadata.data); + if (isPositiveAndBelow (metadata.samplePosition, frameCount)) + midiOut ((int64_t) metadata.samplePosition + (int64_t) (timestamp->mSampleTime + 0.5), + 0, + metadata.numBytes, + metadata.data); } #endif }