PnS: Need help with adding high-pass filter to my script

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS
Plug'n Script

Post

Hi,

I have created a plugin using Plug'n Script to process audio from variable density optical soundtrack negatives. When attempting to playback from negatives, these tracks have severe distortion resulting from the logarithmic gamma curve of the film. Normally, the reversal printing to a positive track would have corrected this, but these days, no one is going to make a print, so we have been tasked with processing the audio from the negatives. This script is working pretty well, but I need to add one more process. I need a high-pass filter to remove the DC offset in my audio, as well as attenuate some low frequency noise in the original track.

I'm hoping someone may be able to give me an idea why the Biquad highpass filter is behaving strangely when I add it to my script, but works fine when it is in another plugin following my script.

Here's my script code (I have commented out the filter):

/** \file "Gamma v2.cxx 071023 B.Weitz"
* Gamma Correction with Gain, Phase Invert, and High Pass Filter.
*/

/* include your dsp files.
*
*/
#include "library/BiquadFilter.hxx"
#include "library/Constants.hxx"

// Create a biquad filter instance
//KittyDSP::Biquad::Filter filter(audioInputsCount);
//double freqFactor=2*PI*20/sampleRate;

array<string> inputParametersNames = {"INVERT", "GAIN", "PROCESS", "OFFSET", "GAMMA"/*, "HIGH PASS"*/};
array<string> inputParametersUnits = {"", "dB", "", "", "", ""};
array<string> inputParametersEnums = {"OFF;ON", "", "OFF;ON", "", ""/*, "OFF;ON"*/};
array<double> inputParameters(inputParametersNames.length);
array<int> inputParametersSteps = {2, 41, 2, 0, 201/*, 2*/};
array<double> inputParametersMin = {0, -14, 0, 20, 0/*, 0*/};
array<double> inputParametersMax = {1, 6, 1, 40, 100/*, 1*/};
array<double> inputParametersDefault = {1, 0, 0, 31, 45.5/*, 0*/};

bool phaseInvert = false;
double gain = 0;
bool gammaEnable = false;
double offset = 0;
double gamma = 1;
//bool highPassEnable = false;

void processSample(array<double>& ioSample)
{
// Apply reverse logarithmic taper to offset control
double offsetScaled = pow(10, offset / 100) - 1;

for (uint channel = 0; channel < ioSample.length; ++channel)
{
// Apply input Gain
ioSample[channel] *= gain;

// Apply phase invert if enabled
if (phaseInvert)
{
ioSample[channel] = -ioSample[channel];
}

// Apply gamma processing if enabled
if (gammaEnable)
{
// Apply offset
ioSample[channel] += offsetScaled;

// Apply gamma correction
ioSample[channel] = pow(ioSample[channel], gamma / 5);
}

// Apply high-pass filter if enabled
//if (highPassEnable)
//{
// filter.processSample(ioSample);
//}
}
}

void updateInputParameters()
{
phaseInvert = (inputParameters[0] > 0.50);
gain = pow(10, inputParameters[1] / 20);
gammaEnable = (inputParameters[2] > 0.50);
offset = inputParameters[3];
gamma =inputParameters[4];
//highPassEnable = (inputParameters[5] > 0.50);
// filter.setResonantHighPass(freqFactor*pow(1000, .078), 0.707);
}

Post

Just looking at the code, it seems that you are doing the filtering inside the for loop, so it is actually processing the frame as many times as you have channels. If you just close the for loop bracket before the filter (instead of after), it should probably work fine.

Post Reply

Return to “Blue Cat Audio”