Synthesiser and PitchBend

I’m betting that I’m overlooking something really simple, but at the moment I’m stuck on this. I’ve implemented a multi-voice Synthesiser and added one sound per note for about 40 notes. This all seems to work fine in that MIDI notes trigger each sound correctly. What isn’t working is any response to MIDI Pitch Bend. I’ve confirmed that the same keyboard that is sending Note-On/Off message is also sending Pitch Bend messages on the same channel. The Synthesiser class documentation seems to imply that pitch bend messages should be properly handled. What am I missing?

I’ll answer my own question here for the benefit of others. SamplerVoice::pitchWheelMoved(), which is called on receiving MIDI Pitch Bend messages, is an empty function. Nothing implemented. Same is true for Controller messages.

The functions are empty because there isn’t necessarily any good default implementation to do in the Juce code. The SynthVoice subclasses are in a better position to implement those virtual methods themselves.

Here is what I do;

void pitchWheelMoved (int newPitchWheelValue)
		pitchWheelAdjustment = 1 + float (newPitchWheelValue - 8192) / 65536;
		getNewDelta = true;

pitchWheelAdjustment is a local float which I can either use to calculate new delta’s (phase incrementor’s) in between buffer loop, or directly multiplying delta every time a sample is calculated, so therefore the second method is slower but more instantaneous. The constant divider of 65536 is used to determine the modulation effect.

1 Like

Thanks. It would seem to me that for a regular synthesiser, not MPE, the best place to implement pitch bend would be after all the voices have been mixed, rather than on individual voices. At least on a given channel, the entire output is affected by Pitch Bend, and you’re then only doing it once.

With more digging, I realize that my requirements are sufficient unique that it makes sense for me to implement by own synth engine.

@robertsonics I understand and appreciate what your are saying, always looking for a more efficient way of doing things. So in PluginProcessor I guess you could do some pitch manipulation of all voices, the buffer, but I am not sure if it would be any faster than just adjusting note frequency (delta) on each voice (SynthVoice).

I realize that the above instead should be;

	// The below pitchWheelAdjustment variable I multiply 
	// with my tone generator's delta
	// The 65536 divider is the movement sensitivity
	pitchWheelAdjustment = 1.0f + float (newPitchWheelValue - 8192) / 65536;

	// The below I added so correct frequency ratio change is maintained.
	if (pitchWheelAdjustment < 1.0f)
		pitchWheelAdjustment = pitchWheelAdjustment / 2 + 0.5f;