Hi… while I will study some DSP programming, I’m still using CCRMA Synthesis Toolkit effects. I have that custom object:
class PannedPitch {
public:
PannedPitch()
{
pitchL = stk::PitShift();
pitchR = stk::PitShift();
}
void clear()
{
pitchL.clear();
pitchR.clear();
}
void setVal (float value)
{
val = value;
}
void setPan (float pan)
{
if (pan < 0.0)
{
lMix = 0.5 + fabsf(pan / 2);
rMix = 0.5 - fabsf(pan / 2);
}
if (pan == 0.0)
{
lMix = 0.5;
rMix = 0.5;
}
if (pan > 0.0)
{
lMix = 0.5 - fabsf(pan / 2);
rMix = 0.5 + fabsf(pan / 2);
}
}
void setGain (float value)
{
gain = value;
}
void process (AudioSampleBuffer& buffer)
{
buffer.copyFrom(1, 0, buffer, 0, 0, buffer.getNumSamples());
pitchL.setShift(val);
pitchL.setEffectMix(lMix * gain);
pitchR.setShift(val);
pitchR.setEffectMix(rMix * gain);
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
float* lBuf = buffer.getWritePointer(0);
lBuf[i] = pitchL.tick(lBuf[i]);
float* rBuf = buffer.getWritePointer(1);
rBuf[i] = pitchR.tick(rBuf[i]);
}
}
private:
stk::PitShift pitchL, pitchR;
float val, pan, gain;
float lMix, rMix;
};
And this code in MainComponent.cpp to implement the effect (PannedPitch object) in prepare to play:
pitchA = PannedPitch();
pitchA.setVal(params[1] * 0.1667);
pitchA.setPan(params[2] / 50.0);
pitchA.setGain(params[5] / 100.0);
pitchA.clear();
pitchB = PannedPitch();
pitchB.setVal(params[3] * 0.1667);
pitchB.setPan(params[4] / 50.0);
pitchB.setGain(params[5] / 100.0);
pitchB.clear();
and in getNextAudioBlock (…) that code:
pitchA.setVal(params[1] * 0.1667);
pitchA.setPan(params[2] / 50.0);
pitchA.setGain(params[5] / 100.0);
pitchB.setVal(params[3] * 0.1667);
pitchB.setPan(params[4] / 50.0);
pitchB.setGain(params[5] / 100.0);
if (pitchOn)
{
pitchA.process(*bufferToFill.buffer);
pitchB.process(*bufferToFill.buffer);
}
But in this way only the pitchB instance works with panning (perfectly).
The pitchA instance only sounds in total left panning.But if I comment one of them, the effects is perfect…
Any suggestion/ idea?
I’ve tried to pass to the process in getNextAudioBlock() the current inputChannel and the outputChannels but it’s the same.
If i change the input channel to 1 instead 0, the panning swaps (only right channel sounds).
Really need help plz!