midiman.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: midiman.h
00004 
00005     DESCRIPTION: A manager for MIDI
00006 
00007     CREATED BY: Rolf Berteig
00008 
00009     HISTORY: 6/7/97
00010 
00011  *> Copyright (c) 1997, All Rights Reserved.
00012  **********************************************************************/
00013 
00014 #pragma once
00015 #include "coreexp.h"
00016 #include <WTypes.h>
00017 #include <mmsystem.h>
00018 #include <mmreg.h>
00019 
00020 
00021 // This is the same function type that is passed to the Win32 API midiInOpen()
00022 // except that it returns a DWORD instead of void.
00023 typedef DWORD(*MIDI_IN_PROC)(HMIDIIN hMidiIn,UINT wMsg, DWORD dwInstance,DWORD dwParam1, DWORD dwParam2);
00024 
00025 // Return values from MIDI_IN_PROC
00026 #define MIDIPROC_PROCESSED      1           // The message was processed and so no other callbacks should be called.
00027 #define MIDIPROC_NOTPROCESSED   0           // The message was not processed.
00028 
00029 // These can be called to open/close/start/stop the midi in device.
00030 // The MIDI device can be opened more than once... it will only actually
00031 // close when Close() is called as many times as Open().
00032 CoreExport MMRESULT MIDIMan_Open(MIDI_IN_PROC proc,DWORD dwInstance,int priority=0);
00033 CoreExport MMRESULT MIDIMan_Close(MIDI_IN_PROC proc,DWORD dwInstance);
00034 CoreExport MMRESULT MIDIMan_Start();
00035 CoreExport MMRESULT MIDIMan_Stop();
00036 CoreExport BOOL MIDIMan_IsOpened();
00037 CoreExport BOOL MIDIMan_IsStarted();
00038 
00039 // To temporary close and stop the MIDI device use these methods. These
00040 // will preserve the state of the Open/Close Start/Stop stack.
00041 CoreExport void MIDIMan_Suspend();
00042 CoreExport void MIDIMan_Resume();
00043 
00044 // Macros to pull out peices of param1
00045 #define MIDI_CHANNEL(a)             ((a)&0x0f)
00046 #define MIDI_EVENT(a)               ((a)&0xf0)
00047 #define MIDI_NOTENUMBER(a)          (((a)&0xff00)>>8)
00048 #define MIDI_VELOCITY(a)            (((a)&0xff0000)>>16)
00049 #define MIDI_PITCHBEND(a)           (((a)&0xff0000)>>16)
00050 #define MIDI_NOTEFLOAT(a,low,high)  (float((a)-(low))/float((high)-(low)))
00051 #define MIDI_VELFLOAT(a)            (float(a)/127.0f)
00052 #define MIDI_BENDFLOAT(a)           (float(a)/127.0f)
00053 
00054 // MIDI events
00055 #define MIDI_NOTE_ON        0x90
00056 #define MIDI_NOTE_OFF       0x80
00057 #define MIDI_PITCH_BEND     0xe0
00058 #define MIDI_CONTROLCHANGE  0xb0
00059 
00060 
00061