[beginner] ToggleButton: silence / Redwood Tutorial


#1

Hi folks,

I have some troubles getting started with AU programming.

I'm sorry if the following problem has been already discussed in this forum, then please let me know (I couldn't find something..).

I built an AudioUnit following Redwood's tutorial, which worked fine! I then tried to implement buttons for "Mute Left", "Mute Right", "Mute Mid" and "Mute Side". Mute Side works as expected, but the other three buttons only lead to complete silence in botch channels - although they are all implemented the same way! Does anybody know this behaviour (or something similar)? It does not seem to be a problem with my dsp code, but more with GUI<->Processor relationship.

 

PluginEditor.cpp:

 if (buttonThatWasClicked == BypassBtn)

    {

        //[UserButtonCode_BypassBtn] -- add your button handler code here..

        ourProcessor->setParameter(MidSideAudioProcessor::MasterBypass, (float)BypassBtn->getToggleState());

        //[/UserButtonCode_BypassBtn]

    }

    else if (buttonThatWasClicked == LeftBtn)

    {

        //[UserButtonCode_LeftBtn] -- add your button handler code here..

        ourProcessor->setParameter(MidSideAudioProcessor::LeftVal, (float)LeftBtn->getToggleState());        

        //[/UserButtonCode_LeftBtn]

    }

    else if (buttonThatWasClicked == RightBtn)

    {

        //[UserButtonCode_RightBtn] -- add your button handler code here..

        ourProcessor->setParameter(MidSideAudioProcessor::RightVal, (float)RightBtn->getToggleState());

        //[/UserButtonCode_RightBtn]

    }

    else if (buttonThatWasClicked == MidBtn)

    {

        //[UserButtonCode_MidBtn] -- add your button handler code here..

        ourProcessor->setParameter(MidSideAudioProcessor::MidVal, (float)MidBtn->getToggleState());

        //[/UserButtonCode_MidBtn]

    }

    else if (buttonThatWasClicked == SideBtn)

    {

        //[UserButtonCode_SideBtn] -- add your button handler code here..

        ourProcessor->setParameter(MidSideAudioProcessor::SideVal, (float)SideBtn->getToggleState());

        //[/UserButtonCode_SideBtn]

    }

"DSP" Side:

void LeftRight::setLeft(bool LeftBtnVal)

{

    if (LeftBtnVal == true)

    {LeftFactor = 1.0f;}

else

    {LeftFactor  = 0.0f;}

}


void LeftRight::setRight(bool RightBtnVal)

{

    if (RightBtnVal == true)

    {RightFactor = 1.0f;}

else

    {RightFactor = 0.0f;}

}


void LeftRight::setMid(bool MidBtnVal)

{

    if (MidBtnVal == true)

    {MidFactor = 1.0f;}

else

    {MidFactor  = 0.0f;}

}


void LeftRight::setSide(bool SideBtnVal)

{

    if (SideBtnVal == true)

    {SideFactor = 1.0f;}

else

    {SideFactor  = 0.0f;}

}


void LeftRight::ClockProcess(float* LeftSample, float* RightSample)

{

*LeftSample = *LeftSample * LeftFactor;

*RightSample = *RightSample * RightFactor;

mid = MidFactor * (*LeftSample + *RightSample);

side = SideFactor * (*RightSample - *LeftSample);

*LeftSample= 0.5 * (mid - side);

*RightSample= 0.5 * (mid + side);

}

Why does "Side" (and the global bypass) work, but not Left, Right and Mid? 

Thanks a lot in advance, I hope someone can help me.

Best regards!

JP


#2

Anybody?? :(

 

OSX 10.6.8, XCode 3.2.6


#3

In the button handling code you seem to be setting parameters with names like LeftVal. Yet in LeftRight on the DSP side you're using parameters with names like LeftBtnVal.  Either that's your problem, or you're not showing us all of the relevant code!