AudioProcessorValueTreeState ComboBoxAttachment arguments issue

I feel that this is going to be a silly one, but I am attaching Sliders, a ComboBox and a Button through AudioProcessorValueTreeState.

My ParameterLayout in PluginProcessor.cpp is this one:

AudioProcessorValueTreeState::ParameterLayout CircularAudioBufferAudioProcessor::createParameters()
{
    std::vector<std::unique_ptr<RangedAudioParameter>> params;

    params.push_back(std::make_unique<AudioParameterFloat>("DELAYTIME", "DelayTime", 0.f, 1000.f, 0.f));
    params.push_back(std::make_unique<AudioParameterFloat>("DELAYFEEDBACK", "DelayFeedback", 0.f, 1.1f, 0.5f));
    params.push_back(std::make_unique<AudioParameterChoice>("FILTERTYPEMENU", "FilterTypeMenu", { "Lowpass", "HighPass" }, 0));
    params.push_back(std::make_unique<AudioParameterBool>("FILTERONOFF", "filterOnOff", false)); 
    params.push_back(std::make_unique<AudioParameterFloat>("FILTERCUTOFF", "FilterCutoff", 500.f, 20000.f, 20000.f));

    return { params.begin(), params.end() };
}

In PluginEditor h:

std::unique_ptr<AudioProcessorValueTreeState::SliderAttachment> delayTimeAttachment, delayFeedbackAttachment, filterCutoffAttachment;

std::unique_ptr<AudioProcessorValueTreeState::ComboBoxAttachment> filterTypeMenuAttachment;

std::unique_ptr<AudioProcessorValueTreeState::ButtonAttachment> filterOnOffAttachment;

In PluginEditor.cpp constructor the line for my comboBox is:

 filterTypeMenuAttachment = std::make_unique<AudioProcessorValueTreeState::ComboBoxAttachment>(audioProcessor.apvts, "FILTERTYPEMENU", filterTypeMenu);

But when I run my project I always have these two errors referring to the comboBox:

Error C7627 ‘initializer list’: is not a valid template argument for ‘_Types’

|Error|C2672|‘std::make_unique’: no matching overloaded function

Could someone point me which of the ComboBoxAttachment arguments are wrong or which is the problem?

Thank you so much

This is the problematic line of code :confused:

Yes, thanks to the template make_unique it cannot deduce the type of the initialiser_list. You will have to tell it that it is a StringArray:

params.push_back(std::make_unique<AudioParameterChoice>("FILTERTYPEMENU", "FilterTypeMenu", 
                                                        juce::StringArray( "Lowpass", "HighPass" ), 0));

Hope that helps

1 Like

Thanks Daniel! that makes sense