Vst 2 mono input -> true stereo output

Hi @t0m, I had some work to do but now I’m returning to Juce and C++ programming…
I have migrate from vst2 to vst3, but the configurations you tell me to do, don’t produce different effects for different channels: if i use:

buffer.getWritePointer(1);

the sound is not effected, if I use

buffer.getWritePointer(0);

the sound is effected but in both stereo channels…
Am I missing something?
I used the buffer.copyFrom() method but the pointer at the right channel seems to be empty…

In the demo there is code to clear all unused input buffers, in case it contains garbage, that would kill your hearing if it is still there at the end of processBlock…
There is a long explanation (worth reading) to these two lines:

    for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

You can remove them, because you copied the left channel into the right channel, so you don’t have to clean them (and especially not after the copy)…

HTH

I’ve already tried that… It doesn’t work anyway.

Now I have this code to try the stereo effect:

    pitch1.setShift(params[3]);
    pitch1.setEffectMix(params[4]);

    pitch2.setShift(params[5]);
    pitch2.setEffectMix(params[6]);
    
    const int numSamples = buffer.getNumSamples();
    buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);
    
    float* channelDataL = buffer.getWritePointer(0);
    float* channelDataR = buffer.getWritePointer(1);
    
    for (int i = 0; i< numSamples; ++i)
    {
        channelDataL[i] = pitch1.tick(channelDataL[i]);
        channelDataR[i] = pitch2.tick(channelDataR[i]);
    }

But it doesn’t work… It’s all in the processBlock function…

If you’ve made sure that all the calls to getTotalNumInputChannels() and getTotalNumOutputChannels() in the AudioProcessor class are doing what you expect (the code in the examples assume these will return the same number, which is not true in your case, so you need to check) then the code I posted on the 1st Feb will turn your mono input into stereo output. Try doing this yourself with a much simpler example first.

1 Like

Excuse me, but how can I check? And what I have to check? (And where)

a. If you don’t know the result, you type

DBG ("Number output channels: " + String (getTotalNumOutputChannels())):

If you run your host from the terminal/cmd, you will see the printout.

b. If you know the result and want to make sure, it is always what you expect, type

jassert (getTotalNumOutputChannels() == 2);

In this case your programm will stop executing, if the result is not 2, so you can use your debugger to figure out why (e.g. by inspecting the call stack) and fix things.

Ok, I’ve started a new AudioPlugin, I set:

.withInput  ("Input",  AudioChannelSet::mono(), true)

And:

bool StktestAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
    const AudioChannelSet& mainInput  = layouts.getMainInputChannelSet();
    const AudioChannelSet& mainOutput = layouts.getMainOutputChannelSet();
    
    return mainInput.size() == 1 && mainOutput.size() == 2;
}

And:

void StktestAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)

{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();

DBG ("Number output channels: " + String (getTotalNumOutputChannels()));

// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
//for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
//    buffer.clear (i, 0, buffer.getNumSamples());

// This is the place where you'd normally do the guts of your plugin's
// audio processing...

const int numSamples = buffer.getNumSamples();
buffer.copyFrom(1, 0, buffer, 0, 0, numSamples);

float* channelDataL = buffer.getWritePointer (0);
float* channelDataR = buffer.getWritePointer (1);
    
pitch1.setShift(0.5);
pitch1.setEffectMix(0.5);

pitch2.setShift(0.5);
pitch2.setEffectMix(0.5);

for (int i = 0; i < numSamples; ++i)
{
    channelDataR[i] = pitch2.tick(channelDataR[i]);
}

}

I receive from debugger “mums channels 2”, But no sound on buffer.getWritePointer(1); …
And stereo sound on writePointer 0…

I’ve tried to leave all by default with a new AUdioPlugin and use only the buffer.copyFrom() and i receive an error on dest channel 1…

jassert must be positive or below numChannels

I really need help…

Why did you not also include

?

Please take the JUCE Demo Plugin, modify it as I have described, and check that you get the expected mono to stereo behaviour. If this works we can rule out all sorts of problems: we would know that it’s not a misconfigured host or JUCE project. At the moment you have an unknown function call, pitch2.tick, which could be doing anything, so it’s very difficult to help.

I’ve included even .withOutput stereo true…
And I have already modified the the demo plugin…
The call pitch2.tick(STKFloat); is a method from STK C++ libraries developed by Stanford University and translated to JUCE by @danlin.

https://ccrma.stanford.edu/software/stk/index.html

So does the modified JUCE demo (without the STK libraries) work as you expect?

No… it has the same behavior of my complete programs…
The best result I had was that both write pointers (0 and 1) returned mono effect (in another audio plugin). If you need the code I can post it.

How are you hosting your plug-in?

Cubase 9 elements.
Here is the PluginProcessor.cpp

PluginProcessor.cpp (5.2 KB)

The rBuf is completely ignored…
Is a VST2 plugin but I’ve tried even VST3… same error…

Does Cubase 9 elements support a mono-input stereo-output track? Have you tried testing in the JUCE demo host? Here it’s very easy to route your audio correctly.

I don’t know effectively…
Let me test on Juce Host.

Eh… it is Cubase…you’re right!
It works perfectly on Juce Host…
How can I set it for Cubase?

No idea!

You’ll have to read the Cubase documentation.

Ok, thank you very much for the help!