[JUCE API] PingPong Delay(3)

SangHoon You·2025년 5월 27일
0

JUCE API

목록 보기
16/17

3. The plugin editor should also detect the ping-pong button state.


AudioProcessorEditor  : private juce::Button::Listener
{
	public:
    	AudioProcessorEditor()
        :mButtonPingPong(mPanelControl.getButtonPingPong())
        {
            mButtonPingPong.addListener(this);
        }
    private:
        juce::Button& mButtonPingPong;
        void buttonClicked(juce::Button* inButton) override;
}

The pure virtual function buttonClicked() should display only half of the delay panel.


void buttonClicked(juce::Button* inButton)
{
    switch (inButton -> getCommandID())
    {
        case MyHelper::CmdIdButtons::PingPong:
        {
            mPanelDelay.setSize(MySize::Panel::Delay::Width,
                                inButton -> getToggleState() ?  MySize::Panel::Delay::Height / 2:
                                                                MySize::Panel::Delay::Height );
            mPanelDelay.repaint();
            break;
        }
        default: break;
    }
}

Using the component's pure virtual function resized(), redraw the delay panel at half-height whenever the ping-pong button is pressed.


4. Create a ping-pong panel and show it below the delay panel whenever the ping-pong button is pressed

EulerDelayAudioProcessorEditor():
{
  	mPanelPingPong.setVisible(mButtonPingPong.getToggleState());
}

In the constructor, detect the initial state when the plugin loads to decide whether to show the ping-pong panel.


void buttonClicked(juce::Button* inButton)
{
    switch (inButton -> getCommandID())
    {
        case MyHelper::CmdIdButtons::PingPong:
        {
    		mPanelPingPong.setVisible(mButtonPingPong.getToggleState());
            break;
        }
        default: break;
    }
}

Naturally, since the ping-pong panel should appear in the space freed by the delay panel when the button is pressed, this behavior is implemented in the buttonClicked() function.

profile
Audio Plugin Developer

0개의 댓글