[JUCE API] PingPong Delay(2)

SangHoon You·2025년 5월 27일
0

JUCE API

목록 보기
15/17

Now, I'm going to make a GUI for the ping-pong delay effect.

There are some steps to make it.

1. Adding ping-pong button to the control panel

class PanelControl  : public PanelBase
{	
	public:
    	PanelControl():
             mButtonPingPong(mAudioprocessor.getmApvts(),
                             MyParamId::Control::PingPong.getParamID(),
                             MyHelper::CmdIdButtons::PingPong)
         {
              mLabelPingPong.setText("PingPong", juce::NotificationType::dontSendNotification);
              mLabelPingPong.setJustificationType(juce::Justification::centred);
              addAndMakeVisible(mLabelPingPong);
              addAndMakeVisible(mButtonPingPong);
         }
         
	private:
        juce::Label mLabelPingPong;
    	MyParamToggleButton mButtonPingPong;
}
  • At the constructor, I connect the button of ping-pong with Apvts. And I arrange the specific ID to the button for identification.
  • We can decide the button's size and location by resized() function, which is pure virtual function of Component class.

2. Delay pannel have to detect the change of ping-pong button.

class PanelDelay  : public PanelBase,
                    private juce::Button::Listener
{
	public:
    	PanelDelay(juce::Button& inButtonPingPong):
        mButtonPingPong(inButtonPingPong)
        {
			mButtonPingPong.addListener(this);	
        }
        
        ~PanelDelay()
        {
            mButtonPingPong.removeListener(this);
        }

  	private:
        juce::Button& mButtonPingPong;
}

Delay Panel has to be added as a listener of button of ping-pong.


buttonClicked(juce::Button* inButton)
{
    switch(inButton->getCommandID())
    {
        case MyHelper::CmdIdButtons::PingPong:
        {
            setTextLabels(inButton -> getToggleState());
            setVisibleLaveAndKnobs(mButtonTempo.getToggleState(), inButton -> getToggleState());
            break;
        }
        default: break;
    }
}

When ping-pong button is clicked, we need to change the label of delay L and show delay knob partically.


setVisibleLaveAndKnobs(const bool inTempo, const bool inPingPong) noexcept
{
            for(int i=0;i<2 ; ++i)
            {
                mLabelTime[i].setVisible(i == 0 ? !inTempo : !inTempo && !inPingPong);
                mKnobTime[i].setVisible(i == 0 ? !inTempo : !inTempo && !inPingPong);
                
                mLabelNote[i].setVisible(i == 0 ? inTempo : inTempo && !inPingPong);
                mKnobNote[i].setVisible(i == 0 ? inTempo : inTempo && !inPingPong);
            }
}

This function sets the visibility of labels and knobs based on two conditions (inTempo and inPingPong). For the first element (i == 0), visibility depends only on inTempo. For the second element (i == 1), visibility is set only if inTempo is off (false) and inPingPong is also off (false).


setTextLabels(const bool inPingPong) noexcept
{
    mLabelTime[0].setText(inPingPong ? "Time" : "Time L", juce::NotificationType::dontSendNotification);
    mLabelNote[0].setText(inPingPong ? "Note" : "Note L", juce::NotificationType::dontSendNotification);
}

This function sets label texts to either "Time"/"Note" if inPingPong is active (true), or "Time L"/"Note L" if it's inactive (false).

profile
Audio Plugin Developer

0개의 댓글