SHARE
TWEET

CharlesMIDI.h

charlieslick Aug 25th, 2014 236 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef charlesMIDI.h
  2. #define charlesMIDI.h
  3.  
  4.  
  5. #include <arduino.h>
  6.  
  7. const byte noteOn = 0x90;
  8. const byte noteOff = 0x80;
  9. const byte nullByte = 0x00;
  10. const byte middleC = 0x3C;
  11. const byte maxVelocity = 0x7F;
  12. const byte TOTAL_CHANNELS = 0x04;
  13.  
  14. class MidiWord{
  15.   private:
  16.   byte command;
  17.   byte pitch;
  18.   byte velocity;
  19.  
  20.  
  21.   public:
  22.   MidiWord();
  23.   MidiWord(byte inCommand, byte inPitch, byte inVelocity);
  24.   void getWord();
  25.   byte getCommand() const;
  26.   byte getPitch() const;
  27.   byte getVelocity() const;
  28.   byte setAll(byte inCommand, byte inPitch, byte inVelocity);  
  29.   boolean isEqual(MidiWord inWord) const;
  30.   void writeWord(byte snChannel = nullByte)const;
  31.  
  32. };
  33.  
  34. class MidiChannel{
  35.   private:
  36.   //byte channel;
  37.   byte currentPitch;
  38.   boolean playState;
  39.   unsigned long startTime;
  40.  
  41.   public:
  42.   MidiChannel();
  43.   byte getCurrentPitch() const;
  44.   boolean getPlayState() const;
  45.   unsigned long getStartTime() const;
  46.   void setCurrentPitch(const byte inCurrentPitch);
  47.   void setPlayState(const byte inState);
  48.   void setStartTime();
  49.  
  50. };
  51.  
  52. class MCArray{
  53.   private:
  54.   MidiChannel midiArray[TOTAL_CHANNELS];
  55.  
  56.   public:
  57.   MCArray();
  58.   byte nextNotePlayTime(MidiWord& killNote, byte numberOfChannels) const;
  59.   byte nextNotePlayPitch(MidiWord& killNote, byte numberOfChannels) const;
  60.   byte noteOffMatch(const byte inPitch) const;
  61.   void updateStatus(const MidiWord& currentMessage, byte messageChannel);
  62.  
  63. };
  64.  
  65.  
  66.  
  67.  
  68. #endif
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top