What you want to do in general shouldn't be too hard and using JUCE Synthesizer class is definitely the right direction. My suggestion would be to derive a child-class from JUCE's SamplerVoice and simply override the startNote method and multiply the velocity with the note's gain. I haven't tested the code below but it should give you an idea of what I am talking about:
class CustomGainSamplerVoice : public SamplerVoice
{
public:
CustomGainSamplerVoice(JuceDemoPluginAudioProcessor& myPluginProcessor)
: parent (myPluginProcessor)
{
}
void startNote (int midiNoteNumber, float velocity, SynthesiserSound* snd, int pitchWheel) override
{
if (midiNoteNumber == 36)
velocity = velocity * parent.gainOne;
else if (midiNoteNumber == 37)
velocity = velocity * parent.gainTwo;
// call the base class' method
SamplerVoice::startNote(midiNoteNumber, velocity, snd, pitchWheel);
}
private:
JuceDemoPluginAudioProcessor& parent;
};
