home *** CD-ROM | disk | FTP | other *** search
/ PC Musician 2000 / PC_Musician_2000.iso / PCMUSIC / NOTATION / SILENCE / MIDI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-23  |  5.2 KB  |  155 lines

  1.  //        *** MidiOut Class Declaration ***
  2.  
  3. #ifndef MIDI_H_    // check if already compiled
  4. #define MIDI_H_
  5.  
  6. #include <windows.h>
  7. #include <mmsystem.h>
  8.  
  9.  
  10.  
  11.                     // Midi Status Byte definitions
  12.  
  13. #define MIDI_NOTEON         0x90    // Midi Channel voice status bytes
  14. #define MIDI_NOTEOFF        0x80
  15. #define MIDI_POLYPRESS        0xA0
  16. #define MIDI_CHANPRESS        0xD0
  17. #define MIDI_PROGCHANGE        0xC0
  18. #define MIDI_CTRLCHANGE     0xB0
  19. #define MIDI_PITCHBEND        0xE0
  20.  
  21. #define MIDI_ALLNOTESOFF    0x7B
  22.  
  23.  
  24.                     // Control Change parameters
  25.  
  26. #define CTRL_MOD        1    // Modulation wheel or lever
  27. #define CTRL_BREATH        2    // Breath Controller
  28. #define CTRL_FOOT        4    // Foot controller
  29. #define CTRL_PORTTM        5    // Portamento time
  30. #define CTRL_DATA        6    // Data entry MSB
  31. #define CTRL_VOL        7    // Main Volume
  32. #define CTRL_BAL        8    // Balance
  33. #define CTRL_PAN        10    // Pan
  34. #define CTRL_EXPR        11    // Expression controller
  35. #define CTRL_GEN1        16    // General purpose 1
  36. #define CTRL_GEN2        17    // General purpose 2
  37. #define CTRL_GEN3        18    // General purpose 3
  38. #define CTRL_GEN4        19    // General purpose 4
  39.  
  40. //     ** 32-63 are normally used for LSB's of parameters 0-31 ** 
  41. #define CTRL_MODLSB        33    // Modulation wheel or lever
  42. #define CTRL_BREATHLSB        34    // Breath Controller
  43. #define CTRL_FOOTLSB        36    // Foot controller
  44. #define CTRL_PORTTMLSB        37    // Portamento time
  45. #define CTRL_DATALSB        38    // Data entry MSB
  46. #define CTRL_VOLLSB        39    // Main Volume
  47. #define CTRL_BALLSB        40    // Balance
  48. #define CTRL_PANLSB        42    // Pan
  49. #define CTRL_EXPRLSB        43    // Expression controller
  50. #define CTRL_GEN1LSB        48    // General purpose 1
  51. #define CTRL_GEN2LSB        49    // General purpose 2
  52. #define CTRL_GEN3LSB        50    // General purpose 3
  53. #define CTRL_GEN4LSB        51    // General purpose 4
  54.  
  55. #define CTRL_DAMP        64    // Damper pedal (sustain)
  56. #define CTRL_PORT               65    // Portamento
  57. #define CTRL_SOST        66    // sostenuto
  58. #define CTRL_SOFTPED        67    // Soft Pedal
  59. #define CTRL_HOLD2        68    // Hold 2
  60. #define CTRL_GEN5        80    // General purpose 5
  61. #define CTRL_GEN6        81    // General purpose 6
  62. #define CTRL_GEN7        82    // General purpose 7
  63. #define CTRL_GEN8        83    // General purpose 8
  64. #define CTRL_TREM        92    // Tremelo depth
  65. #define CTRL_CHORUS        93    // Chorus depth
  66. #define CTRL_CELST        94    // Celeste (detune) depth
  67. #define CTRL_PHASE        95    // Phaser depth
  68. #define CTRL_DATAINC        96    // Data increment
  69. #define CTRL_DATADEC        97    // Data decrement
  70.  
  71.  
  72. #define STATUS 0
  73. #define    DATA1  1
  74. #define DATA2  2
  75.  
  76. typedef union { 
  77.     DWORD dwData; 
  78.     BYTE bData[4]; 
  79. } MIDIMESSAGE; 
  80.     
  81. /********************** MIDI Channel Voice Messages ************************/
  82. #define NoteOn( channel, noteNumber, velocity ) \
  83.         sendMIDIEvent(  (BYTE) (MIDI_NOTEON + channel), noteNumber, velocity ) 
  84.  
  85. #define NoteOff( channel, noteNumber, velocity ) \
  86.         sendMIDIEvent(  (BYTE) (MIDI_NOTEOFF + channel), noteNumber, velocity ) 
  87.  
  88. #define PolyPress ( channel, noteNumber, pressure ) \
  89.         sendMIDIEvent(  (BYTE) (MIDI_NOTEOFF + channel), noteNumber, velocity)
  90.  
  91. #define ChanPress (BYTE channel, BYTE pressure) \
  92.         sendMIDIEvent(  (BYTE) (MIDI_CHANPRESS + channel), pressure, (BYTE)0)
  93.  
  94. #define ProgChange ( channel, newPatch) \
  95.         sendMIDIEvent(  (BYTE) (MIDI_PROGCHANGE + channel), newPatch, (BYTE)0)
  96.  
  97.  
  98. #define CtrlChange ( channel, ctrlNum, ctrlVal) \
  99.         sendMIDIEvent(  (BYTE) (MIDI_CTRLCHANGE + channel), ctrlNum, ctrlVal)
  100.  
  101. #define PitchBend (BYTE channel, UINT bendVal) \
  102.             sendMIDIEvent(  (BYTE) (MIDI_PITCHBEND + channel), (BYTE)(HIBYTE( bendVal << 1)), \
  103.                                                        (BYTE)(LOBYTE(bendVal) & 0x7f ))
  104.  
  105. /*************************************** MIDI Channel Mode Messages ***********************/
  106. #define AllNotesOff(channel) \
  107.         sendMIDIEvent(  (BYTE) (MIDI_CTRLCHANGE + channel), (BYTE)MIDI_ALLNOTESOFF, (BYTE)0 )
  108.             
  109.  
  110.         
  111.  
  112.  
  113. MMRESULT OpenMidiOutput (UINT midiDevNum) ;     // opens the port specified
  114. MMRESULT CloseMidiOutput (void) ;    // Resets then closes the midi port
  115.  
  116. int  TestDevice (void) ;            
  117. UINT sendMIDIEvent( BYTE bStatus, BYTE bData1, BYTE bData2);
  118. // MIDI Channel Voice messages
  119. //void NoteOn (BYTE channel, BYTE noteNumber, BYTE velocity) ;
  120. //void NoteOff (BYTE channel, BYTE noteNumber, BYTE velocity) ;
  121. //void PolyPress (BYTE channel, BYTE noteNumber, BYTE pressure) ;
  122. //void ChanPress (BYTE channel, BYTE pressure) ;
  123. //void ProgChange (BYTE channel, BYTE newPatch) ;
  124. //void CtrlChange (BYTE channel, BYTE ctrlNum, BYTE ctrlVal) ;
  125. //void PitchBend (BYTE channel, UINT bendVal) ;
  126. // MIDI Channel Mode messages
  127. //void AllNotesOff (BYTE channel) ;
  128.  
  129.  
  130. MMRESULT SystemExclusive( BYTE *data, UINT numData );
  131. void printOutputErrorMessage( char* func, MMRESULT result );
  132.  
  133. static void CALLBACK handleMidiOut( HMIDIOUT hmo, UINT wMsg, 
  134.             DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
  135.  
  136.  
  137.  
  138. /***********************************************************************************/
  139. /*        Midi Input Declarations            */
  140.  
  141.  
  142.  
  143.  
  144. MMRESULT OpenMidiInput (UINT midiDevNum) ;     // opens the port specified
  145. MMRESULT CloseMidiInput (void) ;                // Resets then closes the midi port
  146. UINT GetMidiMessage( MIDIMESSAGE* newMsg );
  147. void printInputErrorMessage( char* func, MMRESULT result );
  148.  
  149. static void CALLBACK handleMidiIn( HMIDIOUT hmo, UINT wMsg, 
  150.             DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
  151.  
  152. #endif  // MIDI_H_
  153.  
  154.  
  155.