home *** CD-ROM | disk | FTP | other *** search
- // *** MidiOut Class Declaration ***
-
- #ifndef MIDI_H_ // check if already compiled
- #define MIDI_H_
-
- #include <windows.h>
- #include <mmsystem.h>
-
-
-
- // Midi Status Byte definitions
-
- #define MIDI_NOTEON 0x90 // Midi Channel voice status bytes
- #define MIDI_NOTEOFF 0x80
- #define MIDI_POLYPRESS 0xA0
- #define MIDI_CHANPRESS 0xD0
- #define MIDI_PROGCHANGE 0xC0
- #define MIDI_CTRLCHANGE 0xB0
- #define MIDI_PITCHBEND 0xE0
-
- #define MIDI_ALLNOTESOFF 0x7B
-
-
- // Control Change parameters
-
- #define CTRL_MOD 1 // Modulation wheel or lever
- #define CTRL_BREATH 2 // Breath Controller
- #define CTRL_FOOT 4 // Foot controller
- #define CTRL_PORTTM 5 // Portamento time
- #define CTRL_DATA 6 // Data entry MSB
- #define CTRL_VOL 7 // Main Volume
- #define CTRL_BAL 8 // Balance
- #define CTRL_PAN 10 // Pan
- #define CTRL_EXPR 11 // Expression controller
- #define CTRL_GEN1 16 // General purpose 1
- #define CTRL_GEN2 17 // General purpose 2
- #define CTRL_GEN3 18 // General purpose 3
- #define CTRL_GEN4 19 // General purpose 4
-
- // ** 32-63 are normally used for LSB's of parameters 0-31 **
- #define CTRL_MODLSB 33 // Modulation wheel or lever
- #define CTRL_BREATHLSB 34 // Breath Controller
- #define CTRL_FOOTLSB 36 // Foot controller
- #define CTRL_PORTTMLSB 37 // Portamento time
- #define CTRL_DATALSB 38 // Data entry MSB
- #define CTRL_VOLLSB 39 // Main Volume
- #define CTRL_BALLSB 40 // Balance
- #define CTRL_PANLSB 42 // Pan
- #define CTRL_EXPRLSB 43 // Expression controller
- #define CTRL_GEN1LSB 48 // General purpose 1
- #define CTRL_GEN2LSB 49 // General purpose 2
- #define CTRL_GEN3LSB 50 // General purpose 3
- #define CTRL_GEN4LSB 51 // General purpose 4
-
- #define CTRL_DAMP 64 // Damper pedal (sustain)
- #define CTRL_PORT 65 // Portamento
- #define CTRL_SOST 66 // sostenuto
- #define CTRL_SOFTPED 67 // Soft Pedal
- #define CTRL_HOLD2 68 // Hold 2
- #define CTRL_GEN5 80 // General purpose 5
- #define CTRL_GEN6 81 // General purpose 6
- #define CTRL_GEN7 82 // General purpose 7
- #define CTRL_GEN8 83 // General purpose 8
- #define CTRL_TREM 92 // Tremelo depth
- #define CTRL_CHORUS 93 // Chorus depth
- #define CTRL_CELST 94 // Celeste (detune) depth
- #define CTRL_PHASE 95 // Phaser depth
- #define CTRL_DATAINC 96 // Data increment
- #define CTRL_DATADEC 97 // Data decrement
-
-
- #define STATUS 0
- #define DATA1 1
- #define DATA2 2
-
- typedef union {
- DWORD dwData;
- BYTE bData[4];
- } MIDIMESSAGE;
-
- /********************** MIDI Channel Voice Messages ************************/
- #define NoteOn( channel, noteNumber, velocity ) \
- sendMIDIEvent( (BYTE) (MIDI_NOTEON + channel), noteNumber, velocity )
-
- #define NoteOff( channel, noteNumber, velocity ) \
- sendMIDIEvent( (BYTE) (MIDI_NOTEOFF + channel), noteNumber, velocity )
-
- #define PolyPress ( channel, noteNumber, pressure ) \
- sendMIDIEvent( (BYTE) (MIDI_NOTEOFF + channel), noteNumber, velocity)
-
- #define ChanPress (BYTE channel, BYTE pressure) \
- sendMIDIEvent( (BYTE) (MIDI_CHANPRESS + channel), pressure, (BYTE)0)
-
- #define ProgChange ( channel, newPatch) \
- sendMIDIEvent( (BYTE) (MIDI_PROGCHANGE + channel), newPatch, (BYTE)0)
-
-
- #define CtrlChange ( channel, ctrlNum, ctrlVal) \
- sendMIDIEvent( (BYTE) (MIDI_CTRLCHANGE + channel), ctrlNum, ctrlVal)
-
- #define PitchBend (BYTE channel, UINT bendVal) \
- sendMIDIEvent( (BYTE) (MIDI_PITCHBEND + channel), (BYTE)(HIBYTE( bendVal << 1)), \
- (BYTE)(LOBYTE(bendVal) & 0x7f ))
-
- /*************************************** MIDI Channel Mode Messages ***********************/
- #define AllNotesOff(channel) \
- sendMIDIEvent( (BYTE) (MIDI_CTRLCHANGE + channel), (BYTE)MIDI_ALLNOTESOFF, (BYTE)0 )
-
-
-
-
-
- MMRESULT OpenMidiOutput (UINT midiDevNum) ; // opens the port specified
- MMRESULT CloseMidiOutput (void) ; // Resets then closes the midi port
-
- int TestDevice (void) ;
- UINT sendMIDIEvent( BYTE bStatus, BYTE bData1, BYTE bData2);
- // MIDI Channel Voice messages
- //void NoteOn (BYTE channel, BYTE noteNumber, BYTE velocity) ;
- //void NoteOff (BYTE channel, BYTE noteNumber, BYTE velocity) ;
- //void PolyPress (BYTE channel, BYTE noteNumber, BYTE pressure) ;
- //void ChanPress (BYTE channel, BYTE pressure) ;
- //void ProgChange (BYTE channel, BYTE newPatch) ;
- //void CtrlChange (BYTE channel, BYTE ctrlNum, BYTE ctrlVal) ;
- //void PitchBend (BYTE channel, UINT bendVal) ;
- // MIDI Channel Mode messages
- //void AllNotesOff (BYTE channel) ;
-
-
- MMRESULT SystemExclusive( BYTE *data, UINT numData );
- void printOutputErrorMessage( char* func, MMRESULT result );
-
- static void CALLBACK handleMidiOut( HMIDIOUT hmo, UINT wMsg,
- DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
-
-
-
- /***********************************************************************************/
- /* Midi Input Declarations */
-
-
-
-
- MMRESULT OpenMidiInput (UINT midiDevNum) ; // opens the port specified
- MMRESULT CloseMidiInput (void) ; // Resets then closes the midi port
- UINT GetMidiMessage( MIDIMESSAGE* newMsg );
- void printInputErrorMessage( char* func, MMRESULT result );
-
- static void CALLBACK handleMidiIn( HMIDIOUT hmo, UINT wMsg,
- DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
-
- #endif // MIDI_H_
-
-
-