Exemple for ParameterAttachment in JUCE 6

Thanks for your reply @kamedin

I would like to use ParameterAttachment for 2 reasons:

  • I’ve a custom GUI attachement (double slider)
  • I don’t want the parameter to be visible by the host, since as you mentioned ( which some hosts ignore ), but I need to observe the value inside my audioProcessor.

ParameterAttachment seems to be a good candidate for this case.

My first try was to use the AudioProcessorValueTreeState with something like this:

// .h
RangeSliderComponent(AudioProcessorValueTreeState& apvts);
...
AudioProcessorValueTreeState& apvts_;
std::unique_ptr<TwoValueSliderAttachment> attachment_;

// .cpp
attachment_ = std::make_unique<TwoValueSliderAttachment>(apvts_,
                                                         parameterMinId,
                                                         parameterMaxId,
                                                         rangeSLider_);

but without any surprise, the two parameterId are visible by the host and can be automatized.

@reuk mentioned:

The part that is interesting is:

Also, even if you do decide to use an APVTS, you no longer need your editor to know about the APVTS or your parameterIDs when creating attachments (as you can pass parameter references instead), which reduces unnecessary coupling

So I’m wondering what should as input parameter instead of the current AudioProcessorValueTreeState