Multiple output busses

Hi. I’m doing a synth, where user can select output channel (a track in daw) for each sound from combobox (total amount is 25 outputs).
I want to use output busses for it. Am I right?

I do it like that in processBlock:

auto busCount = getBusCount (false);

for (int busNr = 0; busNr < busCount; ++busNr)
   {
        auto audioBusBuffer = getBusBuffer (buffer, false, busNr);
        synth.renderNextBlock(audioBusBuffer, midiMessages, 0, audioBusBuffer.getNumSamples());
  }

but in that case I don’t know how to get the current bus index(or name) in my SynthVoice class. What is the best solution?

Or maybe I’m doing it completely wrong?

Nobody knows?

The bus setup looks right to me, but it is easy to get into a mess with host defined behaviour and such things…
I don’t think the SynthVoice should be concerned about it… I would lay it out to have one Synthesiser class per output and each one has it’s set of SynthesiserVoices.

I think you can feed all midi signals to every instance of Synthesiser and let the Synthesiser do the filtering for a specific channel. But I don’t remember OTOMH the exact API for doing so, or if you have to override some handleMidiXYZ method to achieve that.

Technically the getBusBuffer() method can be of great help:

void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override
{
    auto bus1 = getBusBuffer (buffer, false, 1);
    synth1.renderNextBlock (bus1, midi, 0, bus1.getNumSamples());
    // ...
1 Like

Daniel, thank you!
I’ve thought about the option with multiple synths, but decided that it’s little bit complicated.
But now will return to this idea.

Anyone else? Are you agree that it could be the best solution?

Thought little bit more about multiple synths.
I think that in my case it’s not the best option, because I have crazy amount of samples per synth and user can change channel output during playback. So it should be fast. With multiple synths it could be possible if only I upload all samples to all synths. But in that case I will have problems with RAM, because its 25 channels and each channel has many samples.

You could create your samples in a shared_ptr or ReferenceCountedObject, so you can use the loaded sample from every voice.
I agree it would be crazy to load the same sample in different instances of your synth.

Looking at the API, you are setting the SynthesiserSound on each NoteOn, so you can re-use the same sound in different synthesiser instances without a problem.

1 Like

Right! Thank you again!

One more thing.
I’ve done it. And then found an example: GitHub

My code is more all less the same (without method filterMidiMessagesForChannel)

But during playback only one synth works properly. When I switch channel to another synth I can hear only something like 1ms of the whole sample (something wrong with the buffer?). And all the same for all synths except the first.

What could it be?

Thank you

Even more. Some of the channels are good (for example, channel 7). But I have now ideas why.
All of of them are the same and were filled with for loop. Nothing special

And the problem was in my renderNextBlock code. Have no ideas why… But now it works.

I know this is only 50/50 on topic, but I am just wondering is it possible to dynamically enable and disable these auxiliary busses if more or fewer busses are wanted for a given plugin configuration?