Simple channels for simple synth


#1

I needed some documentation about buses management in JUCE, and the following topic helped me to understand some points.
https://forum.juce.com/t/the-ultimate-juce-4-1-multibus-guide/16755/

I just discovered JUCE few days ago. I’m learning every hours I spend on my code.

The weird thing with Projucer configuration is the “is Synth” and “channels config”. I just created a simple sinewave synth (no gain or delay params, nothing but the sinewave), and the plugin can make sounds only with configuration {1,1},{2,2}, which is strange since I don’t use any input channel (or maybe Midi is seen as input, so why I need two inputs to work ?). I tested with “Plugin Host” example app, but for Standalone version (AUv3) inputs channels are set by default on my Mic In and create big Larsen effects…

To more, I can’t set the “isSynth” to true (if i do there’s no sound too, tested with VSTv2 and VSTv3 with Plugin Host example and Standalone (AUv3)).

Since I’m just working on this simple synth, the configuration in my mind was :
-isSynth: true
-Midi Input: true
-Midi Output: false
-channels: {1,2} // (Midi input, Left & Right ouputs)
-Midi Effect Plugin : false
-Key Focus: true

But I have no sound with this configuration and I would know why.

My code looks like the example of audio plugin, but without gain or delay parameters.

void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) override
{ 
    
    const int numSamples = buffer.getNumSamples();
    keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true);
    synth.renderNextBlock (buffer, midiMessages, 0, numSamples);
    
    for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
        buffer.clear (i, 0, numSamples);
}

Thank you :wink:


#2

Hi there,

exactly the same problem here,

did you find a way to correct it ?

thanks


#3

if getTotalNumInputChannels() returns 0 and getTotalNumOutputChannels() returns > 0 (what I’d expect for a MIDI-synth), you’re clearing all the data you have produced.

You could try:

void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) override
{
buffer.clear(); // clear all the output, in case we don’t produce data for each output channel.
const int numSamples = buffer.getNumSamples();
keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true);
synth.renderNextBlock (buffer, midiMessages, 0, numSamples);
}


#4

Thanks a lot you opened my eyes.