Polyphonic Synthesiser Issue

Hi, I am creating a polyphonic synthesiser with which 4 notes can be played at the same time. In the incoming Midi message function, I am trying to set it up so that when a noteOn message is received, 1 is added to my numOfNotesPlaying variable.

I currently have a 2D array of oscillators because I want 4 to be controlled individually with amplitude sliders but also be able to play a chord.

I had the 4 initial oscillators working fine, I am struggling to implement the second array of oscillators.

>     for(int i = 0; i < 4; i++)
>     {
>         
>         
>         
>             if(message.isNoteOn())
>             {
>                 numOfNotesPlaying += 1;
>             }
>             if(message.isNoteOff())
>             {
>                 
>                 numOfNotesPlaying -= 1;
>                 DBG("Off");
>             }
>     
>         
>         oscillatorBasePtr[i][numOfNotesPlaying].get()->setFrequency(message.getMidiNoteInHertz(message.getNoteNumber()));
>         oscillatorBasePtr[i][numOfNotesPlaying].get()->setAmplitude(message.getVelocity() * 0.1);
>            
>         
>     }

Any advice would be much appreciated, thanks in advance.