grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 323 forks source link

Controls under a tabbed control do not display correctly in VST Created via JUCE. #597

Open Digital-Larry opened 3 years ago

Digital-Larry commented 3 years ago

Selector is properly displayed in Faust IDE. It seems hidden or zero-dimension or something in the VST3 created via faust2juce. ZIP file contains DSP, Jucer, and C++ file. Compiled with Projucer 6.0.8 and Visual Studio 2019. FAUST Version 2.13.15

faust-ide-selector

vst-selector

echoFlanger.zip

sletz commented 3 years ago

Thanks, I'll have a look ASAP.

sletz commented 3 years ago

The tab group code indeed has some problems. But since the code was written by a student, I do not master it completely. I took some time to debug without success for now. So probably avoiding tabgoup layout is the workaround for now.

Digital-Larry commented 3 years ago

@sletz The issue is, as you've suggested, that controls placed below a tabbed component get squished down to 1 pixel or worse!

I've come up with a minimal program to demonstrate this, along with a reference control under an hgroup, which works properly.

declare version     "1.11";
declare author      "Gary Worsham";
declare license     "none";
declare copyright   "(c) Gary Worsham 2021";
import("stdfaust.lib");

// flanger/vibrato block UI controls
flaDelay = vslider("/h:/v:[02]FX/t:Modulation/h:Flange/[03]Delay[style:knob]", 156, 5, 1000, 1) : si.smoo;
flaLFORate = vslider("/h:/v:[02]FX/t:Modulation/h:Flange/[03]Rate[style:knob]", 2, 0.5, 10, 1) : si.smoo;
flaLFOWidth = 1; 
flaLFO2 = os.lf_triangle(flaLFORate/2);
flaMod1 = flaLFOWidth * (flaLFO2/2) ;
flaMod2 = flaLFOWidth * (flaLFO2/2) ;
flanger(x, mod) = pf.flanger_mono(512, flaDelay * (1 + (x * mod)), 0.5, 0, 1);
flange(lfo) = hgroup("[02]Flange", flanger(1, lfo));

freq = vslider("/h:/v:[02]FX2/h:LowPass/[03]Freq[style:knob]", 156, 5, 1000, 1) : si.smoo;
res = vslider("/h:/v:[02]FX2/h:LowPass/[03]Resonance[style:knob]", 156, 5, 1000, 1) : si.smoo;
// effect selector
s1 = vslider("/h:/v:[02]FX/Select[style:menu{'Flanger':0;'Phaser':1}][00]",0,0,1,1) : int;
s2 = vslider("/h:/v:[02]FX2/Select[style:menu{'FlangerX':0;'Phaser':1}][00]",0,0,1,1) : int;

modulation1 = _ <: flange(flaMod1), fi.resonlp(100, 1.0) : select2(s1) : _;
modulation2 = _ <: flange(flaMod2), fi.resonlp(freq, res) : select2(s2) : _;

//=============================================
process =  _,_: modulation1, modulation2 : _,_;

In FaustIDE:

image

After faust2juce (and my own color overrides):

image

I've put bargraphs below tabbed controls and they too disappear completely or almost.

I am looking at the calls in buildUserInterface():

        ui_interface->openHorizontalBox("tgroup bug");
        ui_interface->declare(0, "02", "");
        ui_interface->openVerticalBox("FX");
        ui_interface->openTabBox("Modulation");
        ui_interface->openHorizontalBox("Flange");
        ui_interface->declare(&fVslider1, "03", "");
        ui_interface->declare(&fVslider1, "style", "knob");
        ui_interface->addVerticalSlider("Delay", &fVslider1, 156.0f, 5.0f, 1000.0f, 1.0f);
        ui_interface->declare(&fVslider2, "03", "");
        ui_interface->declare(&fVslider2, "style", "knob");
        ui_interface->addVerticalSlider("Rate", &fVslider2, 2.0f, 0.5f, 10.0f, 1.0f);
        ui_interface->closeBox();
        ui_interface->closeBox();
        ui_interface->declare(&fVslider0, "00", "");
        ui_interface->declare(&fVslider0, "style", "menu{'Flanger':0;'Phaser':1}");
        ui_interface->addVerticalSlider("Select", &fVslider0, 0.0f, 0.0f, 1.0f, 1.0f);
        ui_interface->closeBox();
        ui_interface->declare(0, "02", "");
        ui_interface->openVerticalBox("FX2");
        ui_interface->openHorizontalBox("LowPass");
        ui_interface->declare(&fVslider4, "03", "");
        ui_interface->declare(&fVslider4, "style", "knob");
        ui_interface->addVerticalSlider("Freq", &fVslider4, 156.0f, 5.0f, 1000.0f, 1.0f);
        ui_interface->declare(&fVslider5, "03", "");
        ui_interface->declare(&fVslider5, "style", "knob");
        ui_interface->addVerticalSlider("Resonance", &fVslider5, 156.0f, 5.0f, 1000.0f, 1.0f);
        ui_interface->closeBox();
        ui_interface->declare(&fVslider3, "00", "");
        ui_interface->declare(&fVslider3, "style", "menu{'FlangerX':0;'Phaser':1}");
        ui_interface->addVerticalSlider("Select", &fVslider3, 0.0f, 0.0f, 1.0f, 1.0f);
        ui_interface->closeBox();
        ui_interface->closeBox();
    }

The add for the selector under the tabbed control is these lines:

        ui_interface->declare(&fVslider0, "00", "");
        ui_interface->declare(&fVslider0, "style", "menu{'Flanger':0;'Phaser':1}");
        ui_interface->addVerticalSlider("Select", &fVslider0, 0.0f, 0.0f, 1.0f, 1.0f);

while the add for the selector under the regular hgroup is:

        ui_interface->declare(&fVslider3, "00", "");
        ui_interface->declare(&fVslider3, "style", "menu{'FlangerX':0;'Phaser':1}");
        ui_interface->addVerticalSlider("Select", &fVslider3, 0.0f, 0.0f, 1.0f, 1.0f);

I am trying to trace into these calls to see where there is any concept of space allocation and while I do occasionally see "fTotalHeight" and "fTotalWidth" here and there, I haven't stumbled across the place where these two scenarios differ.

Digital-Larry commented 3 years ago

I'm tracing on closeBox(), where I can tell where we are in the hierarchy as well as what elements we are talking about.

        /** Close the current box. */
        virtual void closeBox() override
        {
            fCurrentBox->setRecommendedSize();

            if (fBoxStack.empty()) {
                // Add root box in JuceGUI component
                addAndMakeVisible(dynamic_cast<juce::Component*>(fCurrentBox));
                fCurrentBox->init();

In order, we hit 6 of them. fTotalHeight and fTotalWidth after each one, and tracing through "getRecommendedSize()", I have the following:

104, 208 134, 208 206, 212 118, 208 190, 212 224, 432

I'll attempt to correlate:

image

I've had to guess at what was "probably" included in these various dimensions. My guess is that the tab control is underallocating its needed space.

Digital-Larry commented 3 years ago

I can make it behave by placing the tabbed control in yet another box. I'm confused now. Is this a bug in FaustIDE, or faust2juce, or not?

image

image

declare name        "tgroup bug";
declare version     "1.11";
declare author      "Gary Worsham";
declare license     "none";
declare copyright   "(c) Gary Worsham 2021";
import("stdfaust.lib");

// flanger/vibrato block UI controls
flaDelay = vslider("/h:/v:[02]FX/h:/t:Modulation/h:Flange/[03]Delay[style:knob]", 156, 5, 1000, 1) : si.smoo;
flaLFORate = vslider("/h:/v:[02]FX/h:/t:Modulation/h:Flange/[03]Rate[style:knob]", 2, 0.5, 10, 1) : si.smoo;
flaLFOWidth = 1; 
flaLFO2 = os.lf_triangle(flaLFORate/2);
flaMod1 = flaLFOWidth * (flaLFO2/2) ;
flaMod2 = flaLFOWidth * (flaLFO2/2) ;
flanger(x, mod) = pf.flanger_mono(512, flaDelay * (1 + (x * mod)), 0.5, 0, 1);
flange(lfo) = hgroup("[02]Flange", flanger(1, lfo));

freq = vslider("/h:/v:[02]FX2/h:LowPass/[03]Freq[style:knob]", 156, 5, 1000, 1) : si.smoo;
res = vslider("/h:/v:[02]FX2/h:LowPass/[03]Resonance[style:knob]", 156, 5, 1000, 1) : si.smoo;
// effect selector
s1 = vslider("/h:/v:[02]FX/Select[style:menu{'Flanger':0;'Phaser':1}][00]",0,0,1,1) : int;
// s1 = vslider("/h:/v:[02]FX/Select[00]",0,0,1,1) : int;
s2 = vslider("/h:/v:[02]FX2/Select[style:menu{'FlangerX':0;'Phaser':1}][00]",0,0,1,1) : int;

modulation1 = _ <: flange(flaMod1), fi.resonlp(100, 1.0) : select2(s1) : _;
modulation2 = _ <: flange(flaMod2), fi.resonlp(freq, res) : select2(s2) : _;

//=============================================
process =  _,_: modulation1, modulation2 : _,_;

image