# Question on code in Synthesizer::handleController

**URL:** <https://forum.juce.com/t/question-on-code-in-synthesizer-handlecontroller/2533>\
**Category:** General JUCE discussion\
**Created:** [January 26, 2008, 9:40pm UTC](https://forum.juce.com/t/question-on-code-in-synthesizer-handlecontroller/2533 "2008-01-26T21:40:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrblasto](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@mrblasto](https://forum.juce.com/u/mrblasto)\
**Post date:** [January 26, 2008, 9:40pm UTC](https://forum.juce.com/t/question-on-code-in-synthesizer-handlecontroller/2533/1 "2008-01-26T21:40:40Z")

</div>

I’m building a drum machine component and noticed that panning only works if a drum is sounding at the time I move its pan control. The code to call the voice’s handleController method is protected by the followiing guard in Synthesizer::handleController:

```auto
 if (midiChannel <= 0 || voice->isPlayingChannel (midiChannel))
            voice->controllerMoved (controllerNumber, controllerValue);
```

Since midiChannel is obtained with MidiMessage::getChannel which returns zero only if no channel is specified, this implies that voice-\>handleController is called only if a note is sounding. Am I missing something here? There is a similar guard in Synthesiser::handlePitchWheel. I can work around this problem by handling the pan directly instead of midi, but I’d like to understand what’s going on.

Also, it seems that volume messages (controller 7) are handled somewhere else as they work in SamplerVoice and the body to SampleVoice::handleController is empty.

BTW: I created a subclass of SamplerVoice, PanningSamplerVoice, to handle the panning.[/code]

---

<div class="post-metadata">

**Author:** ![mrblasto](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@mrblasto](https://forum.juce.com/u/mrblasto)\
**Post date:** [January 26, 2008, 10:42pm UTC](https://forum.juce.com/t/question-on-code-in-synthesizer-handlecontroller/2533/2 "2008-01-26T22:42:46Z")

</div>

Please ignore the remark about controller 7; the individual volumes are controlled by varying the Midi note on velocity.
