# Vst 2 mono input -\> true stereo output

**URL:** <https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589>\
**Category:** General JUCE discussion\
**Created:** [January 13, 2017, 2:56pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589 "2017-01-13T14:56:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 13, 2017, 2:56pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/1 "2017-01-13T14:56:02Z")

</div>

I’m moved here from another post because I need to understand very well the channel setup of a VST 2 plugin.  
My intention is to develop VSTs for guitar/bass, instruments that have a mono output.  
So in my plugins I need to have a mono input and a TRUE stereo output.  
I mean that even I have only one getReadPointer(0) (left channel or mono), i must have two separate writePointers (0 = Left and 1 = right).

Please can some of you make a step by step process to get this setup?

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 13, 2017, 11:10pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/2 "2017-01-13T23:10:02Z")

</div>

Ok, I’ve found a very good start point in the plugin example…  
Now i would like to add another effect, a reverb:

I’ve settled up all but the algorithm.

This is the code for ::applyDelay()

```
const int numSamples = buffer.getNumSamples();
const float delayLevel = *delayParam;

int delayPos = 0;

for (int channel = 0; channel < getTotalNumInputChannels(); ++channel)
{
    FloatType* const channelData = buffer.getWritePointer (channel);
    FloatType* const delayData = delayBuffer.getWritePointer (jmin (channel, delayBuffer.getNumChannels() - 1));
    delayPos = delayPosition;
    
    for (int i = 0; i < numSamples; ++i)
    {
        const FloatType in = channelData[i];
        channelData[i] += delayData[delayPos];
        delayData[delayPos] = (delayData[delayPos] + in) * delayLevel;
        
        if (++delayPos >= delayBuffer.getNumSamples())
            delayPos = 0;
    }
}

delayPosition = delayPos;

```

But now i have a new template function named ::applyReverb()

I have this code for reverberation:

int numlines = 8;  
float t1 = 50.0; // d0 time  
float g1 = 0.75; // d0 gain  
float rev = -3\*t1 / log10 (g1);

for (int n = 0; n \< numlines; ++n)  
{  
float dt = t1 / pow (2, (float (n) / numlines));  
float g = pow (10, -((3\*dt) / rev));  
printf (“d%d t=%.3f g=%.3f\n”, n, dt, g);  
}

The above with t1=50.0 and g1=0.75 yields:

d0 t=50.000 g=0.750  
d1 t=45.850 g=0.768  
d2 t=42.045 g=0.785  
d3 t=38.555 g=0.801  
d4 t=35.355 g=0.816  
d5 t=32.421 g=0.830  
d6 t=29.730 g=0.843  
d7 t=27.263 g=0.855

How I can implement it in the ::applyReverb() template?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 16, 2017, 9:11am UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/3 "2017-01-16T09:11:50Z")

</div>

You haven’t provided enough information about the algorithm you want to implement. What do `d`, `t` and `g` represent?

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 16, 2017, 12:29pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/4 "2017-01-16T12:29:25Z")

</div>

Don’t mind… I’ve found the STK modules and now I use them…  
No more need to implement external algorithms.

Thanks anyway!

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 17, 2017, 12:32pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/5 "2017-01-17T12:32:54Z")

</div>

Excuse me, I realized that the configuration I have is mono-\>mono or stereo-\>stereo again.  
How do have I set the buffers and the various configurations to obtain a mono input and a stereo output?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 17, 2017, 5:33pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/6 "2017-01-17T17:33:16Z")

</div>

In the constructor of your AudioProcessor do:

```
YourAudioProcessor::YourAudioProcessor()
    : AudioProcessor (BusesProperties().withInput ("Input", AudioChannelSet::mono(), true)
                                       .withOutput ("Output", AudioChannelSet::stereo(), true))

```

Also have your `isBusesLayoutSupported` method look like this:

```
bool YourAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
    const AudioChannelSet& mainInput = layouts.getMainInputChannelSet();
    const AudioChannelSet& mainOutput = layouts.getMainOutputChannelSet();

    return mainInput.size() == 1 && mainOutput.size() == 2;
}
```

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 17, 2017, 6:16pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/7 "2017-01-17T18:16:27Z")

</div>

Thanks very much!!!  
I’m becoming mad to understand a way to do that!

And now, how i can use buffers?

If I use:

if (int channel = 0; channel \< getNumTotalOutputChannels(); ++channel)  
{  
float\* channelData = buffer.getWritePointer(channel);

```
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
    channelData[i] = ....
}

```

}

should work?

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 17, 2017, 6:43pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/8 "2017-01-17T18:43:09Z")

</div>

No, it doesn’t work…  
Ho can i route from mono input buffer and stereo output buffer?

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 17, 2017, 7:10pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/9 "2017-01-17T19:10:03Z")

</div>

Your technique is wrong: I receive this from Xcode:

// if some output channels are disabled, some hosts supply the same buffer  
// for multiple channels - this buggers up our method of copying the  
// inputs over the outputs, so we need to create unique temp buffers in this case…

on the line:

if (chan != input[i]) …

of the juceVstWrapper class, input = NULL

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 18, 2017, 10:25am UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/10 "2017-01-18T10:25:43Z")

</div>

This was a bug in JUCE - I’ve just pushed a fix to the develop branch.

The changes I suggested work as expected with VST3 and AU, and with the latest fix they should now work with VST2 too.

Thank you for your patience!

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 18, 2017, 2:13pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/11 "2017-01-18T14:13:39Z")

</div>

So now I can use your code?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 18, 2017, 2:22pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/12 "2017-01-18T14:22:11Z")

</div>

If you get the latest version of JUCE from GitHub, yes.

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 18, 2017, 2:39pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/13 "2017-01-18T14:39:52Z")

</div>

Ok thanks…  
But now how can I setup the read/write pointers of buffer?  
Said:

```
const float readBuf = buffer.getReadPointer(0);
float lBuf = buffer.getWritePointer(0);
float rBuf = buffer.getWritePointer(1);

```

something like this?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 18, 2017, 2:43pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/14 "2017-01-18T14:43:58Z")

</div>

Yes, but remember that these return pointers: `float*`

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 18, 2017, 2:50pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/15 "2017-01-18T14:50:51Z")

</div>

Ok, thanks again…  
Oh, how can I download the latest version from GitHub?  
I have OS X and JUCE installed… I have only to copy the new JUCE folder?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 18, 2017, 2:59pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/16 "2017-01-18T14:59:15Z")

</div>

> **[WeAreROLI/JUCE](https://github.com/WeAreROLI/JUCE/tree/master)**
>
> The JUCE cross-platform C++ framework.

Click on the green download button and download the zip file, then replace your JUCE folder.

If you do this you will need to either move the Projucer application somewhere else first, or recompile the Projucer in the new directory afterwards.

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 19, 2017, 10:41am UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/17 "2017-01-19T10:41:10Z")

</div>

At the end I got it work!  
Thanks for your JUCE update!

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [January 30, 2017, 4:38pm UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/18 "2017-01-30T16:38:13Z")

</div>

How can I set an audio plugin to have always mono input and stereo output?  
The above code doesn’t work…it doesn’t split channels in getWritePointer(0) and getWritePointer(1).  
I don’t ear left and right diversity…

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [February 1, 2017, 9:25am UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/19 "2017-02-01T09:25:10Z")

</div>

How are you testing it? The above code works correctly for me.

Add the code to the JUCE demo plug-in, change a few calls from `getTotalNumInputChannels()` to `getTotalNumOutputChannels()`, do

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

```

as the first thing in `JuceDemoPluginAudioProcessor::process`, and that’s all you need. From here you can process the left and right sides of the audio differently.

---

<div class="post-metadata">

**Author:** ![arstudio](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@arstudio](https://forum.juce.com/u/arstudio)\
**Post date:** [February 1, 2017, 11:09am UTC](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589/20 "2017-02-01T11:09:15Z")

</div>

Ok now It works… but only in certain effects (I use the STK modules by @danlin) like pit shift chorus and reverb… but not in the delay. Please watch this post:

> [@STK 4.5.0 modules](https://forum.juce.com/t/stk-4-5-0-modules/13643/25):
>
> @IvanC Thank you very much for the snippet of code, it works perfectly with stk pitch reverb and chorus, but not with the delay… Here is the code that work for example in chorus: void DigiFexAudioProcessor::applyChorus2(AudioSampleBuffer &buffer, int inputChannels) { const int numSamples = buffer.getNumSamples(); const float chorusDepth = params[14]; const float chorusRate = params[15]; const float chorusMix = params[16]; chorus2.setModDepth(chorusDepth); chor…

(My last post)

[Next page](https://forum.juce.com/t/vst-2-mono-input-true-stereo-output/20589.md?page=2)
