MIDIfx plugs in Logic - early audio of notes?

Hey everyone, thanks for such a wonderful forum!

I’ve been scouring the forum to educate myself on the timing aspect of MIDIfx plugins built in JUCE. Apologies if I missed the answer, but from looking through the posts the only thing I could gather was that latency compensation, and timing when writing a MIDIfx plug with JUCE is very complicated. :slightly_smiling_face:

The problem I’ve encountered - when inserting a JUCE MIDIfx plugin on a track in Logic Pro w/ a Drum Kit Designer (and a handful of other instruments I tested) MIDI notes that are lined up on the beat play back early, by quite a bit. Around 3500 samples on my system. I did some tests using just the blank “Hello World” JUCE project and without any processing the earliness is present. I’m guessing it has to do with Logic doing some processing for the drums, and delaying things to compensate, but then the MIDIfx not understanding that delay and sending the note right away?

From what I could find it seems like the getLatencySamples, setLatencySamples, is for Audio plugins more, and has to do with the latency the plugin would create. Since a simple MIDI plugin wouldn’t create latency they don’t really apply?

Has anyone else experienced this, and is there a way to get a MIDIfx plugin to find that latency and adjust to make things in time? Lot’s of Logic instruments played perfectly in time, a handful, mostly the newer ones didn’t, and they all had different delay times. Is there a way to find the number from Logic and apply a delay, or is a MIDIfx that plays in time with those instruments just not a possibility?

I tested all latency setting in Logic, and all buffer sizes and sample rates and the amount of delay was consistent.

Here’s a screenshot of bouncing the tracks in place to show the early delay.

Again, apologies if I didn’t search hard enough for the answer, thanks for any comments thoughts!

-DGB

I’m realizing it may be possible that not a lot of the developers on this forum develop midiFX for Logic. Or I may have posted in the wrong part of the forum?

If there are any developers that work with JUCE and make midiFX that work in Logic Pro, I’d love to ask you a couple questions about the timing problems I’m having.

Thanks!

DGB

Does this timing change when you use a different buffer size?

Do you get the same results if you test with the JUCE MIDILoggerPluginDemo? This plugin is a MIDI FX that passes all MIDI input directly through, so it shouldn’t have any effect on the timing of incoming MIDI events.

First idea that comes to my mind is that sample offset of sent events is zero, so that the event occurs at the start of the audio buffer. But changing the audio buffer size will/should affect the result.

If you just pass the input events to the output with their original time stamps there should be no latency in MIDI, the output should be identical with input.

Do you get the same results if you test with the JUCE MIDILoggerPluginDemo?

Yeah, just double checked. Tested the MIDILoggerPluginDemo on both my Mac Studio (Sonoma 14.5, Logic 11.0.1) and my MacBook Pro (Sonoma 14.5, Logic 10.6.2). The track with Logger plays ahead of the beat.

If you just pass the input events to the output with their original time stamps there should be no latency in MIDI, the output should be identical with input.

Yeah, that’s what I assumed, and with some instruments it is, but Logic is buffering some of the instruments and putting a midiFX on the track confuses Logic as to how far ahead the track actually is…

I put some really simple logging into the GUI of the blank JUCE “Hello World” and found this:

For most sampler instruments you get a negative delay of something around -368 as the first MIDI message that gets sent right as the playhead starts at bar 1. However, if you put a Drum Kit Designer on any of the tracks, and then put the midiFX on a track with no sampler instrument you can see that the system is running at a negative delay of -4175. If you check the track that has the Drum Kit Designer on it, it reports a delay of -366. 4175 - 366 = Logic being ahead 3809 samples. I added Logic’s Sample Delay plug with a delay of 3809 samples and the drum kit plays in time again…

Would anyone be up for testing on their system? You just need to create a project with two Drum Kit Designers, pan them L and R, and put identical MIDI info into a region. Then add a JUCE midiFX plug, and play, and see if the notes are together?

Thanks for all the replies! Really hope I can sort out why this is happening.

Best,

DGB

And yeah, tried every buffer size / sample rate / setting. The negative delay stays consistent.

Thanks for trying that. I’m also able to reproduce the same behaviour with the MIDILogger. I also tried out a few other JUCE plugins, and one non-JUCE plugin (BlueARP, from this site). All the plugins I tried seemed to have the same issue. Therefore, I suspect that the behaviour we’re seeing is a bug in Logic (or its plugin hosting layer) rather than in the plugins themselves.

@mfritze I wonder whether this is a known issue?

Steps to repro:

  • Create a track with a Drum Kit Designer instrument. I used the ‘Blue Ridge’ channel strip preset from the factory library.
  • Switch on metronome.
  • Create a MIDI region, and insert some notes on the beat, to coincide with the metronome.
  • Play back audio - the drum sounds exactly match the metronome’s timing.
  • Now, insert a third-party (non-bundled) MIDI FX AU that passes through MIDI events on the track and begin playback. The JUCE MIDILogger demo works well here, but all plugins I tried showed the same issue.
  • The drum sounds play back noticeably ahead of the metronome, by around 1/10 of a second.

Environment:

macOS 15.3 (Arm), Logic 11.2.1

Hi DGB,

Shot in the dark here, but did you try changing the Plug-In Latency Compensation settings at all and see if that makes a difference? (Settings / Audio / General).

I mention it as I’ve had all sorts of fun and games chasing my tail (slightly behind, of course…) with sync issues like this, especially with the various Logic session instruments.

Just a thought. Cheers, -Rob @ WI

I can reproduce it here too but only with Drum Kit Designer, not the other stock instruments (although I didn’t try them all).

Turning off Plug-In Latency Compensation does fix it, but of course that’s not a great solution.

I went through them all, but I probably should’ve made notes on how far they were off. There weren’t a lot of them and I’d probably have missed it if I didn’t just happen to have the drum one up while I was working on some MIDI timing scripts. The new ones seem to be the problem. All of the “Studio” ones “Studio Bass” etc. play out of time. I think maybe Retro Synth too. All the vintage ones like ES2 play fine. Maybe it’s instruments they developed while Apple Silicon?

Yep, this is my limited experience too. Problem seems to be specific to the new “session” instruments introduced in Logic 10.8. -Rob

What’s the next step when something like this happens? Try to sort it out with Apple? Or submit a bug report?

And as a developer, do you go ahead trying to code the midiFX, or wait until it’s fixed?

Thanks!

DGB

Well… if you’re asking me… :grinning:

My very personal opionion based on quite a few years worth of iOS / Apple shenanigans…

In this case, if turning off plug-in latency compensation fixes your issue, then I think that’s the best you can hope for right now, i.e. you’ve got a workaround for customers etc.

Sometimes I’ll submit a radar. I remember a while back there was a horrible issue with their Mastering Assistant that broke offline rendering for a big project I was working on. So I put a report in for that.

For this one, I dunno. I’d be tempted to just roll with it. Definately don’t wait! I remember the first time I saw the option for “Plug-in Compensation” it looked highly suspicious to me, but perhaps I’m just a bit battle-worn :slight_smile:

My €0.02

-Rob

If you’re paying for Apple’s Developer Program, remember that it comes with two free tech support incidents per year. This is the most direct way to get in touch with the actual developers working on this stuff. Success rate is a bit hit-or-miss but you’ve essentially already paid for this support, so why not use it. :slight_smile:

thanks kerfuffle, I’m not in that program, though maybe I’ll join and see what happens.

waverley-instruments - what I found, and maybe others can test, is that turning off PDC does make the instrument play in time, but ONLY if it still has the JUCE midiFX on it… if you take it off it plays late… I suppose because it’s introducing latency, which isn’t strange I guess. In the case of Drum Kit Designer it’s 3809 samples late. I always have PDC on, and honestly have no idea why I’d ever turn it off. But what’s really strange is not that those instruments have latency, but that the JUCE midiFX plug makes them play in time…

A Drum Kit Designer track playing quarter notes on the beat with PDC off and the MIDI logger MIDIfx active - perfectly in time. Turn the MIDI logger off - plays late… How could the MIDI logger, or any other JUCE MIDIfx be compensating for the 3809 samples the drums have declared for that plugin? Any of the Logic MIDIfx plugs don’t do it. The drums still play late with them up and PDC off…

Very weird… I’m guessing most users have PDC on, so when using any of the new Logic instruments they’d never notice anything wrong.

When a plug-in in Logic reports latency, you can hover your mouse over the plug-in and it will show in a tooltip how much latency there is (unless it’s 0). But the Drum Kit Designer doesn’t show any latency for me. (Which may not necessarily mean it reports 0 latency [perhaps that only works for FX plug-ins] but it is suspicious.)

Yeah, it doesn’t seem to have that function for these sampler instruments, hovering over any of them doesn’t display anything. Or the MIDI fx, but I don’t think the MIDI fx have anything to do with the latency, the Hello World blank one doesn’t do any processing that would cause latency, but putting it on a Studio Drummer track makes it play out of time…

I put some logging in a blank JUCE MIDIfx to get the sample position of the playhead and display it in the GUI of the plug.

With PDC off at the very start of bar 1 - the plugin on the Drum Kit track shows

  • Samples: 0, and a plugin on a track with no Sampler Instrument shows - Samples: 0.

If you turn PDC on, the track with drum kit shows - Sample: 3809, but the track with no instrument shows - Samples: 0.

Studio Bass with PDC on shows - Samples: 13743, as I guess it’s asking for a lot more processing time…

I asked around on a Logic forum if other users had come across this and they hadn’t, but they were able to replicate it, so I submitted it to Apple. Let’s see what happens :crossed_fingers:

Seems like @mrfritze might not be on this forum anymore, but maybe someone else from Apple has come across it, or could help?

Thanks again to everyone who responded with suggestions!

DGB