Final Cut and the MessageThread

Hi everybody,

I am writing an audio plugin for FinalCutProX, and I am using the AudioProcessorValueTreeState.
FinalCut opens several instances of the plugin, to render the waveform previews in the timeline. But this triggers an assert in AudioProcessorValueTreeState.cpp:199:

What can be done, so that the AudioProcessorValueTreeState can be used in FinalCut and possibly other hosts we are not aware of?

The MessageManager is shared amongst all JUCE plugin instances, right?

This assert means, that the creation of a plugin instance is not thread safe, right?

Can this assert be changed into a lock, because creating a plugin instance is not time critical anyway?


EDIT: just confirming that changing the assert into

    const MessageManagerLock mmLock;

works fine in FinalCutProX…

I don’t think it’ particularly important that this parameter creation is done on the message thread? Just needs to be guaranteed to be complete before the plugin processor constructor is complete, before the ValueTree is added, and to only be done on a single thread?

Thanks @jimc, I think so too, but can’t make an educated statement, if locking is necessary.
All I know is, that in FinalCut it is called from non-message threads.

@jules, @fabian, could you please comment on that and if positive make the changes?
I would like to get back to a non-patched JUCE…


This change will appear on the develop branch shortly.

Thanks for reporting!

1 Like

Great, thanks @t0m!

@daniel I’m curious as to what Plugin you are writing for Final Cut?

Hi MIDIculous,
thanks for asking. We integrate our dynamic music library Filmstro into Final Cut, so you can add music to your movie. It needs to be a plugin, because you can keyframe musical parameters momentum, depth and power and change the style while playing.

I am happy to tell more about, but I don’t want to spam the board (actually I want to, but I try to be nice :smile: )

Hi @t0m, unfortunately I realised, that it doesn’t work like that.
It is ok, if I have already at least one instance in the project.
However, when I try to drag the plugin the first time on an audio clip, the MessageManagerLock stops FCPX completely (0%-CPU, waiting forever).
This is reproducible every time here.

I only could make it work removing the MessageManagerLock.

When I have the instance on the timeline, I can close the project, recompile the plugin with the lock and restart FCPX with no problem. Very strange.

Is it safe to remove the lock completely?

Thank you for looking again,

…just in case, this is my constructor, nothing special:

     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  AudioChannelSet::stereo(), true)
                       .withOutput ("Output", AudioChannelSet::stereo(), true)
, state (*this, &undo)
    state.createAndAddParameter ("momentum", "Momentum", "Momentum",
                                 NormalisableRange<float> (0.0, 2.0, 0.001), 0.0, nullptr, nullptr);
    state.createAndAddParameter ("depth", "Depth", "Depth",
                                 NormalisableRange<float> (0.0, 2.0, 0.001), 0.0, nullptr, nullptr);
    state.createAndAddParameter ("power", "Power", "Power",
                                 NormalisableRange<float> (0.0, 2.0, 0.001), 0.0, nullptr, nullptr);

    state.state = ValueTree (getName());

    state.addParameterListener ("momentum", this);
    state.addParameterListener ("depth", this);
    state.addParameterListener ("power", this);

I think it would be OK to remove the lock completely - I was originally torn between including it and not, so this simplifies things.