How to use modifiers?

I am trying to figure out how to apply a modifier to a plugin parameter. Ive got it mostly working except for this one issue: After applying the modifier and pressing a midi key, the note plays and the modifier works, however the sound just keeps going and going even after lifting off the midi key.

Here is how I am applying the modifier:

auto modifier = track->getModifierList().insertModifier(juce::ValueTree(tracktion_engine::IDs::LFO), -1, nullptr);
// this method returns an AutomatableParameter of the plugin
// right now I am testing using the volume parameter of the volume and pan plugin
auto pluginParameter = viewModel.getSelectedItem();
pluginParameter->addModifier(*modifier);

As I said the modifier works, I can hear the volume being raised and lowered with the LFO, however the note just keeps going even after releasing the midi key. I figure I must be missing something after applying the modifier but since there arent any modifier examples I am not too sure what it is I need to do.

Any ideas?

EDIT:
restarting playback after adding the modifier fixed it

track->edit.restartPlayback();

Are you doing anything else else apart from adding the modifier?
The modifier should only change the automation, any note handling is done by the synth so it sounds like that might be hanging perhaps because it doesn’t receive the note-off?

The only other thing im doing is strictly UI related. I might have something funky happening with the input monitoring/armed track. Ill investigate more. I thought it was odd that this was happening so there’s probably something happening on my end.

I found the culprit. Forgot to remove an input listener on a previous view in my view stack, and it was firing off a change that was changing the inputs target track at the same time I was adding the modifier causing that track to never get the note off. Its working fine now and I was able to remove that restart playback call. Thanks!

Great. Glad it’s working as expected.

@dave96 is there a way to get a list of parameter names a modifier is modifying? I can get a list of modifiers that are currently on a track (using track->getModifierList().getModifiers()) , but I would like to be able to show what plugin/parameter each modifier is currently modifying. I cant seem to find a method on the modifier that would give me that. Does a modifier know what its modifying?

I think what you want is this in tracktion_AutomatableParameter.h?

juce::ReferenceCountedArray<AutomatableParameter> getAllParametersBeingModifiedBy (Edit&, AutomatableParameter::ModifierSource&);

ModifierSource will be your Modifier.

1 Like

that’s just what I need. Thank you