title: efficiently interpret serial data
body: <p>I'm working on a c++ project that reads MIDI-data from an external USB-device. The program is supposed to call certain functions depending on which fader/knob/button on the USB-device is shiftet/rotated/pressed (such as vol +- or mute/unmute channel).</p>
  
  <p>The only way I came up with finding out which fader/knob/button was changed was using a pretty big switch statement that basically checks every incoming midi event. </p>
  
  <p>looks sort of like this :</p>
  
  <pre><code>switch(MidiMessage.get2ndByte()){
  
      case 1 : cout &lt;&lt; "Fader 1 Value : " &lt;&lt; MidiMessage.get3rdByte() &lt;&lt; endl;  
      case 2 : cout &lt;&lt; "Fader 2 Value : " &lt;&lt; MidiMessage.get3rdByte() &lt;&lt; endl;  
      case 10 : cout &lt;&lt; "Button 1 Value : &lt;&lt; "MidiMessage.get3rdByte() &lt;&lt; endl;  
      ...
      ...
      ...
  }
  </code></pre>
  
  <p>Isn't there a more efficient/smart way to do this?</p>