Hi all,
I am trying to use a horizontal slider as a cross fader for 2 file players.
The end result i’m hoping for is a basic mixer.
I have pitch control and indipendent gains but wanted to cross fade between them.
The slider range is 0 - 2 at 0.1 increments.
From Right to left is no problem as when the slider passes the middle it goes from 1 to 0.
How can I make it so from left to right when the slider passes the middle (1) and gets to the end (2) it actually goes from 1 - 0???
Here is the code I have at the moment
if(crossFader->getValue()<0.99)
{
std::cout<< "slider to the left" << "\n";
leftPlayer->changeGain(1); // set gain at 1 (playing)
rightPlayer->changeGain(crossFader->getValue()); // attenuate to 0
}
else if (crossFader->getValue()>1)
{
std::cout<< "slider to the right" << "\n";
rightPlayer->changeGain(1); // set gain at 1 (playing)
// leftPlayer->changeGain(crossFader->getValue());
}
else
{
leftPlayer->changeGain(1);
rightPlayer->changeGain(1);
}