Choking Hi Hats

Hello!
Really stuck with this one, I am currently trying to get the synthesiser to detect if it’s playing a hi hat (detecting the note) then iterating through all the voices to find ones which have been marked hi hat (this is done when the voice hits start note).
For some reason however, it isnt working.
Anyone spot why?

void DrumSynthVoice::startNote(int midiNoteNumber, float velocity, SynthesiserSound* sound, int currentPitchWheelPosition)
{
if(checkHiHat(midiNoteNumber) && velocity > 0.0)/midiNoteNumber == 47 || midiNoteNumber == 54 || midiNoteNumber == 56 || midiNoteNumber == 58/
{
// DrumSynthVoice* tempVoice;
//
// int count = 0;
printf(“Hi Hat Triggered\n”);
// for (int i = 0; i < 32; i++)
// {
//// DrumSynthVoice* tempVoice = static_cast<DrumSynthVoice*> (p->synth.getVoice(i));
// if (tempVoice->isHiHat == true)
// {
// tempVoice = static_cast<DrumSynthVoice*> (p->synth.getVoice(i));
// if(count < 4){
// tempVoice->stopNote(9, false);
// printf(“Count = %d\n”, count);
// count++;
// }
// else
// {
// printf(“count reset\n”);
// count = 0;
// }
// // if (tempVoice->getCurrentlyPlayingNote() == 47 || tempVoice->getCurrentlyPlayingNote() == 54 || tempVoice->getCurrentlyPlayingNote() == 56 || tempVoice->getCurrentlyPlayingNote() == 58)
// // tempVoice->stopNote(9, true);
// }
// }
}
// printf(“VOICE\n”);
jassert (dynamic_cast<DrumSound*> (sound) != nullptr);
drumSound = static_cast<DrumSound*> (sound);

    currentDrumBuffer = drumSound->getBuffer(0, velocity);
    editor = static_cast<Fyp_samplerPrototype2AudioProcessorEditor*>(p->getActiveEditor());
    positionInBuffer = 0;
    level = velocity;
    
    //is it muted?
    //is it soloed?
    
    /** Get level values */
    fLevel = editor->getSliderValue(drumSound->getID());
    
    /** Get panning values */
    fPan = editor->getPanLevel(drumSound->getID());

// printf(“Pan = %f\n”,fPan);

// printf(“Level = %f\n”,fLevel);
tailOff = 0.0;
}

void DrumSynthVoice::renderNextBlock(AudioSampleBuffer& outputBuffer, int startSample, int numSamples)
{
    //    printf("%d\n", numSamples);
    if (currentDrumBuffer == nullptr)
        return;
    
    const AudioSampleBuffer& currentSound = *currentDrumBuffer;
    
    while( --numSamples >= 0)
    {
        for(int i = outputBuffer.getNumChannels(); --i >= 0;)
        {
            if(positionInBuffer < currentSound.getNumSamples())
            {
                const float sampleValue = currentSound.getSample (i % currentSound.getNumChannels(), positionInBuffer);
                //                if(startSample % 256 == 0)
                //                {
                //                    editor->setMeter(drumSound->getID(), fabs(sampleValue));
                //                    printf("updated\n");
                //                }
                switch(i)
                {
                    case 0:
                        outputBuffer.addSample (i, startSample, (sampleValue * (fLevel * level)) * (1 - fPan));
                        break;
                    case 1:
                        outputBuffer.addSample (i, startSample, (sampleValue * (fLevel * level)) * fPan);
                        break;
                }
            }
            else
            {
                tailOff = 0.0;
                clearCurrentNote();
                currentDrumBuffer = nullptr;
                break;
            }
        }
        
        startSample++;
        positionInBuffer++;
    }
    //        }
}`

void gSynth::noteOn (int midiChannel, int midiNoteNumber, float velocity)
{
const ScopedLock sl (lock);

for (int i = sounds.size(); --i >= 0;)
{
    SynthesiserSound* const sound = sounds.getUnchecked(i);
    
    if (sound->appliesToNote (midiNoteNumber)
        && sound->appliesToChannel (midiChannel))
    {
        // If hitting a note that's still ringing, stop it first (it could be
        // still playing because of the sustain or sostenuto pedal).
        for (int j = voices.size(); --j >= 0;)
        {
            SynthesiserVoice* const voice = voices.getUnchecked (j);
            
            if (voice->getCurrentlyPlayingNote() == midiNoteNumber
                && voice->isPlayingChannel (midiChannel))
                stopVoice (voice, 1.0f, true);
        }
        
        SynthesiserVoice* voice = findFreeVoice (sound, midiChannel, midiNoteNumber, true);
        DrumSound* gSound = dynamic_cast<DrumSound*> (sound);
        
        if (gSound != nullptr)
        {
            if (gSound->checkHiHat(midiNoteNumber))
            {
                for (int j = voices.size(); --j >= 0;)
                {
                    SynthesiserVoice* const otherVoice = voices.getUnchecked (j);
                    DrumSynthVoice* gOtherVoice = dynamic_cast<DrumSynthVoice*> (otherVoice);
                    
                    if (otherVoice != nullptr && otherVoice != gOtherVoice && gOtherVoice->isHat())
                        stopVoice (voice, 1.0f, false);
                }
            }
        }
        
        startVoice (voice, sound, midiChannel, midiNoteNumber, velocity);
    }
}

};