diff CollidoscopeApp/include/MIDI.h @ 3:7fb593d53361

added comments
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 12 Jul 2016 18:29:38 +0200
parents 02467299402e
children 75b744078d66
line wrap: on
line diff
--- a/CollidoscopeApp/include/MIDI.h	Mon Jul 11 17:03:40 2016 +0200
+++ b/CollidoscopeApp/include/MIDI.h	Tue Jul 12 18:29:38 2016 +0200
@@ -29,6 +29,9 @@
     std::string mMessage;
 };
 
+/**
+ * A MIDI message 
+ */ 
 class MIDIMessage
 {
     friend class MIDI;
@@ -40,8 +43,14 @@
 
     unsigned char getChannel() { return mChannel; }
 
+    /**
+     * First byte of MIDI data 
+     */ 
     unsigned char getData_1() { return mData1; }
 
+    /**
+     * Second byte of MIDI data 
+     */ 
     unsigned char getData_2() { return mData2; }
 
 private:
@@ -54,7 +63,10 @@
     
 };
 
-
+/**
+ * Handles MIDI messages from the keyboards and Teensy. It uses RtMidi library.
+ *
+ */ 
 class MIDI
 {
 
@@ -65,22 +77,32 @@
 
     void setup( const Config& );
 
+    /**
+     * Check new incoming messages and stores them into the vector passed as argument by reference.
+     */ 
     void checkMessages( std::vector< MIDIMessage >&  );
 
 private:
 
+    // callback passed to RtMidi library 
     static void RtMidiInCallback( double deltatime, std::vector<unsigned char> *message, void *userData );
 
+    // parse RtMidi messages and turns them into more readable collidoscope::MIDIMessages
     MIDIMessage parseRtMidiMessage( std::vector<unsigned char> *message );
 
-    // messages to pass to checkMessages caller
+    // messages to pass to checkMessages caller 
     std::vector< MIDIMessage > mMIDIMessages;
+    // use specific variables for pitch bend messages. Pitch bend messages are coming 
+    // from the strip sensors that are very jerky and send a lot of values. So instead 
+    // of saving all the messages in mMIDIMessages just save the last received in mPitchBendMessages 
+    // and optimize away redundant messages.
     std::array< MIDIMessage, NUM_WAVES > mPitchBendMessages;
+    // Same principle of pitch bend messages 
     std::array< MIDIMessage, NUM_WAVES > mFilterMessages;
 
-
-
+    // vecotr containing all the MIDI input devices detected.
     std::vector< std::unique_ptr <RtMidiIn> > mInputs;
+    // Used for mutual access to the MIDI messages by the MIDI thread and the graphic thread.  
     std::mutex mMutex;
 };