Plugnscript help

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS

Post

I'm hoping I can get some help here with plugnscript. I devised this script for repanning left and right in a stereo signal. While it works, I can see with a bit scope that the straight up mathematical method leaves a really low-level signal in the opposite channel when panned to one side. Is there a more elegant and comprehensive way to express this?

void processSample(array<double>& ioSample)
{
double left=ioSample[0];
double right=ioSample[1];
ioSample[0]=(left*lilo)+(right*rilo);
ioSample[1]=(left*liro)+(right*riro);
}

void updateInputParameters()
{
lilo=cos((.007853982*inputParameters[2])+.7853982);
liro=sin((.007853982*inputParameters[2])+.7853982);
rilo=cos((.007853982*inputParameters[3])+.7853982);
riro=sin((.007853982*inputParameters[3])+.7853982);
}

Post

Isn't your problem that cos/sin(1.5707964) is never going to be precisely one or zero? It wouldn't harm, since I doubt such a low signal affects our perception, but if you want to be exact, use an if/then/else to map the lowest/highest settings of the inputParameters onto 0 or 1.

Post

Yes this looks like a problem with the numerical values you are using. So you can either use values with higher precision (maybe use the PI value in the constants header provided with PlugNScript), or rewrite the parameters mapping to ensure you get 0 and 1 for extreme values (either using a conditional or different formulas).

Post

Thanks for the suggestions. I implemented using pi in the formula and I can see overall improvement on the bitscope so thanks for that. When both sides are panned to the left, the bitscope shows nothing at all on the right. But when I pan them both all the way right, the left channel on the bitscope shows full 32 bits of signal in the least significant portion of a 64 bit scope. Maybe the cos function is not giving zero?

Post

Can you share with us the new formula? I guess it's hard to reach an exact value for pi/2 to make the cos null. So maybe you should use the cos(x)=sin(pi/2-x) identify instead, because reaching an exact zero value is much easier.

Post

I did rewrite the formula so that it was using just the sin function and it made no difference. I use a pan range from -100 to +100.

lilo=sin(((inputParameters[2]-100)*(-.0025))*PI);
liro=sin(((inputParameters[2]+100)*.0025)*PI);
rilo=sin(((inputParameters[3]-100)*(-.0025))*PI);
riro=sin(((inputParameters[3]+100)*.0025)*PI);

It's neither version nor host dependent. I tried both the AAX version and the VST versions in different hosts and the results were identical. I also removed the other active controls in the script and that didn't change anything either.

Image
Image

Post

Examining the bitscope more closely, I see the audio is 24 bits lower not 32 as previously stated.

Post

You do not need to use sin everywhere but make sure you are using a value that goes to 0 inside the the trigonometric function when you want an exact zero value (it is much easier to get an exact 0 than an exact pi/2).

Post Reply

Return to “Blue Cat Audio”