Final Cut and the MessageThread


#1

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?

Thanks,
Daniel

EDIT: just confirming that changing the assert into

    const MessageManagerLock mmLock;

works fine in FinalCutProX…


Calling setValueNotifyingHost() from processBlock()
#2

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?


#3

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…

Cheers!


#4

This change will appear on the develop branch shortly.

Thanks for reporting!


#5

Great, thanks @t0m!


#6

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


#7

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: )


#8

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,
Daniel

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

FilmstroAudioProcessor::FilmstroAudioProcessor()
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", AudioChannelSet::stereo(), true)
                     #endif
                       )
, 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);
}

#9

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