Juce Attachments (yet another example)

  • LabelAttachment (new)
  • ComboBoxAttachment (based on the existing version)

Both attachents make use of the user defined valueToTextFunction and textToValueFunction when set as the last 2 parameters from the
createAndAddParameter function.

These functions are used to create an updated text entry from a new
parameter value and to evaluate text entries in the label or comboBox
editor.
It is also possible to create the Combobox item list by connecting the box to a parameter through the Attachment.

The Demo Project:

The AudioProcessorValueTreeState class design does not allow the
addition of user defined Attachments from outside the class definition.
Because of that I had to modify two files from the juce framework to
make things possible. Before compiling the demo project you will have to replace the two files
juce_AudioProcessorValueTreeState.cpp and
juce_AudioProcessorValueTreeState.h
with the versions that are supplied with this release.

2 Likes

I have now fixed the bug that prevented the combobox from being initialized properly.
The issue that prevents the combobox from displaying the proper item text after the same value is repeatedly inserted in the editor still needs to be addressed.

This update features some enhancements and bugfixes as well as a new example project.

  • Bugfix: Combobox now always displays the proper item text even when entered text is not equal to the item text.
  • Feature: LabelAttachment now allows to remove or replace an attached parameter.
  • Example: new SliderMonitor demo
    This example features a status bar at the bottom of the UI panel. The
    status bar shows the value of the most recently moved slider. It can
    also be used to change the value via text input. The text representation
    of the status bar is determined by the valueToText function of the
    parameter that is attached to the selected slider.
    The example shows how a complete custom attachment can be
    implemented outside the (modified) framework code.

Added a new example:

ConverterWithState

This example shows how a stateful text converter can be used with the
AudioProcessorValueTreeState.
The radiobutton allows to change the text display of the parameter value
from numbers to letters (each letter of the alphabet reperesenting a
number.)
In a real world application the mechanism might be used to offer:

  • different pitch display options (note number, note name, frequency, localized note names (indian, persian, italian, …))
  • different amplitude display options (percent, decibel)

Here is a new example:

RadioGroup

the RadioGroup example features a component that is populated with a group of radio buttons. The Buttons are created by a SbRadioGroupAttachment upon connection to the component.

recent changes:

  • added a radio button group example
  • modified AudioProcessorValueTreeState to allow for separate handling of user settings (example coming later)
  • added a canAutomate property to AudioProcessorParameterWithID

If anybody finds my attempts interesting, weird or even useful I’d be happy to get some feedback. Thanks!

1 Like