Two or more waveforms on one key

I managed to make two simple wavetable oscillators with SynthesiserSound/SynthesiserVoice: a saw and a square.

They both work fine when used alone, but I want to hear both waves when I press a key.

So I am initializing like this:

    //Initialise the synth...
    for (int i = 4; --i >= 0;)
    {
        synth.addVoice (new SawWaveVoice());
        synth.addVoice (new SquareWaveVoice());
    }

    synth.addSound (new SawWaveSound());
    synth.addSound (new SquareWaveSound());

The problem is when I play a note I can only hear the first oscillator and not the second. What should I do?

Thanks in advance.

 

I managed to get both saw and square playing together in a single voice just summing them in the output sample. I guess that's even better (one voice instead of 2 for the same result) however, I still don't understand how Voice and Sound work inside the Synthesizer class.

How can I layer more voices together? For example what is the workflow to mix a sample with a generated waveform, or just two generated waveforms using more voices?

 

The best thing would be using more Synthesiser instances (one for each Sound/Voice Type.

Every time a note on comes in, the Synthesiser searches its sounds until it finds one that returns true on appliesToNoteNumber() && appliesToChannel() and then starts this sound.

so you can either subclass the synthesiser and change that behaviour (make it continue the search for all sounds) or simply use another Synthesiser.

1 Like

Ok I added another Synthesiser and it worked. Thanks a lot.