|
|
| version 1.4, 2003/12/25 05:07:49 | version 1.6, 2005/02/09 20:11:35 |
|---|---|
| Line 19 extern MIDIMOD vermouth_module; | Line 19 extern MIDIMOD vermouth_module; |
| #define MIDIOUTS3(a) ((*(UINT32 *)(a)) & 0xffffff) | #define MIDIOUTS3(a) ((*(UINT32 *)(a)) & 0xffffff) |
| const char cmmidi_midimapper[] = "MIDI MAPPER"; | const OEMCHAR cmmidi_midimapper[] = OEMTEXT("MIDI MAPPER"); |
| #if defined(VERMOUTH_LIB) | #if defined(VERMOUTH_LIB) |
| const char cmmidi_vermouth[] = "VERMOUTH"; | const OEMCHAR cmmidi_vermouth[] = OEMTEXT("VERMOUTH"); |
| #endif | #endif |
| const char *cmmidi_mdlname[12] = { | const OEMCHAR *cmmidi_mdlname[12] = { |
| "MT-32", "CM-32L", "CM-64", | OEMTEXT("MT-32"), OEMTEXT("CM-32L"), OEMTEXT("CM-64"), |
| "CM-300", "CM-500(LA)", "CM-500(GS)", | OEMTEXT("CM-300"), OEMTEXT("CM-500(LA)"), OEMTEXT("CM-500(GS)"), |
| "SC-55", "SC-88", "LA", | OEMTEXT("SC-55"), OEMTEXT("SC-88"), OEMTEXT("LA"), |
| "GM", "GS", "XG"}; | OEMTEXT("GM"), OEMTEXT("GS"), OEMTEXT("XG")}; |
| enum { MIDI_MT32 = 0, MIDI_CM32L, MIDI_CM64, | enum { MIDI_MT32 = 0, MIDI_CM32L, MIDI_CM64, |
| MIDI_CM300, MIDI_CM500LA, MIDI_CM500GS, | MIDI_CM300, MIDI_CM500LA, MIDI_CM500GS, |
| MIDI_SC55, MIDI_SC88, MIDI_LA, | MIDI_SC55, MIDI_SC88, MIDI_LA, |
| MIDI_GM, MIDI_GS, MIDI_XG, MIDI_OTHER}; | MIDI_GM, MIDI_GS, MIDI_XG, MIDI_OTHER}; |
| static const BYTE EXCV_MTRESET[] = { | static const UINT8 EXCV_MTRESET[] = { |
| 0xfe, 0xfe, 0xfe}; | 0xfe, 0xfe, 0xfe}; |
| static const BYTE EXCV_GMRESET[] = { | static const UINT8 EXCV_GMRESET[] = { |
| 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7}; | 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7}; |
| static const BYTE EXCV_GSRESET[] = { | static const UINT8 EXCV_GSRESET[] = { |
| 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7}; | 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7}; |
| static const BYTE EXCV_XGRESET[] = { | static const UINT8 EXCV_XGRESET[] = { |
| 0xf0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xf7}; | 0xf0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xf7}; |
| static const BYTE EXCV_GMVOLUME[] = { | static const UINT8 EXCV_GMVOLUME[] = { |
| 0xf0, 0x7F, 0x7F, 0x04, 0x01, 0x00, 0x00, 0xF7}; | 0xf0, 0x7F, 0x7F, 0x04, 0x01, 0x00, 0x00, 0xF7}; |
| enum { | enum { |
| Line 84 typedef struct _cmmidi _CMMIDI; | Line 84 typedef struct _cmmidi _CMMIDI; |
| typedef struct _cmmidi *CMMIDI; | typedef struct _cmmidi *CMMIDI; |
| typedef struct { | typedef struct { |
| BYTE prog; | UINT8 prog; |
| BYTE press; | UINT8 press; |
| UINT16 bend; | UINT16 bend; |
| BYTE ctrl[28]; | UINT8 ctrl[28]; |
| } _MIDICH, *MIDICH; | } _MIDICH, *MIDICH; |
| struct _cmmidi { | struct _cmmidi { |
| Line 104 struct _cmmidi { | Line 104 struct _cmmidi { |
| UINT midisyscnt; | UINT midisyscnt; |
| UINT mpos; | UINT mpos; |
| BYTE midilast; | UINT8 midilast; |
| BYTE midiexcvwait; | UINT8 midiexcvwait; |
| BYTE midimodule; | UINT8 midimodule; |
| BYTE buffer[MIDI_BUFFER]; | UINT8 buffer[MIDI_BUFFER]; |
| _MIDICH mch[16]; | _MIDICH mch[16]; |
| BYTE excvbuf[MIDI_BUFFER]; | UINT8 excvbuf[MIDI_BUFFER]; |
| BYTE def_en; | UINT8 def_en; |
| MIMPIDEF def; | MIMPIDEF def; |
| UINT recvpos; | UINT recvpos; |
| UINT recvsize; | UINT recvsize; |
| BYTE recvbuf[MIDI_BUFFER]; | UINT8 recvbuf[MIDI_BUFFER]; |
| BYTE midiinbuf[MIDI_BUFFER]; | UINT8 midiinbuf[MIDI_BUFFER]; |
| }; | }; |
| typedef struct { | typedef struct { |
| Line 129 typedef struct { | Line 129 typedef struct { |
| static UINT midiinhdls; | static UINT midiinhdls; |
| static MIDIINHDL midiinhdl[MIDIIN_MAX]; | static MIDIINHDL midiinhdl[MIDIIN_MAX]; |
| static const BYTE midictrltbl[] = { 0, 1, 5, 7, 10, 11, 64, | static const UINT8 midictrltbl[] = { 0, 1, 5, 7, 10, 11, 64, |
| 65, 66, 67, 84, 91, 93, | 65, 66, 67, 84, 91, 93, |
| 94, // for SC-88 | 94, // for SC-88 |
| 71, 72, 73, 74}; // for XG | 71, 72, 73, 74}; // for XG |
| static BYTE midictrlindex[128]; | static UINT8 midictrlindex[128]; |
| // ---- | // ---- |
| static BOOL getmidioutid(const char *midiout, UINT *ret) { | static BOOL getmidioutid(const OEMCHAR *midiout, UINT *ret) { |
| UINT num; | UINT num; |
| UINT i; | UINT i; |
| Line 160 static BOOL getmidioutid(const char *mid | Line 160 static BOOL getmidioutid(const char *mid |
| return(FAILURE); | return(FAILURE); |
| } | } |
| static BOOL getmidiinid(const char *midiin, UINT *ret) { | static BOOL getmidiinid(const OEMCHAR *midiin, UINT *ret) { |
| UINT num; | UINT num; |
| UINT i; | UINT i; |
| Line 181 static BOOL getmidiinid(const char *midi | Line 181 static BOOL getmidiinid(const char *midi |
| return(FAILURE); | return(FAILURE); |
| } | } |
| static UINT module2number(const char *module) { | static UINT module2number(const OEMCHAR *module) { |
| UINT i; | UINT i; |
| for (i=0; i<(sizeof(cmmidi_mdlname)/sizeof(char *)); i++) { | for (i=0; i<NELEMENTS(cmmidi_mdlname); i++) { |
| if (milstr_extendcmp(module, cmmidi_mdlname[i])) { | if (milstr_extendcmp(module, cmmidi_mdlname[i])) { |
| break; | break; |
| } | } |
| Line 202 static void waitlastexclusiveout(CMMIDI | Line 202 static void waitlastexclusiveout(CMMIDI |
| } | } |
| } | } |
| static void sendexclusive(CMMIDI midi, const BYTE *buf, UINT leng) { | static void sendexclusive(CMMIDI midi, const UINT8 *buf, UINT leng) { |
| CopyMemory(midi->excvbuf, buf, leng); | CopyMemory(midi->excvbuf, buf, leng); |
| midi->hmidiouthdr.lpData = (char *)midi->excvbuf; | midi->hmidiouthdr.lpData = (char *)midi->excvbuf; |
| Line 256 const SINT32 *ptr; | Line 256 const SINT32 *ptr; |
| static void midireset(CMMIDI midi) { | static void midireset(CMMIDI midi) { |
| const BYTE *excv; | const UINT8 *excv; |
| UINT excvsize; | UINT excvsize; |
| BYTE work[4]; | UINT8 work[4]; |
| switch(midi->midimodule) { | switch(midi->midimodule) { |
| case MIDI_GM: | case MIDI_GM: |
| Line 316 const BYTE *excv; | Line 316 const BYTE *excv; |
| static void midisetparam(CMMIDI midi) { | static void midisetparam(CMMIDI midi) { |
| BYTE i; | UINT8 i; |
| UINT j; | UINT j; |
| MIDICH mch; | MIDICH mch; |
| Line 328 static void midisetparam(CMMIDI midi) { | Line 328 static void midisetparam(CMMIDI midi) { |
| if (mch->bend != 0xffff) { | if (mch->bend != 0xffff) { |
| midi->outfn(midi, (mch->bend << 8) + 0xe0+i); | midi->outfn(midi, (mch->bend << 8) + 0xe0+i); |
| } | } |
| for (j=0; j<sizeof(midictrltbl)/sizeof(BYTE); j++) { | for (j=0; j<NELEMENTS(midictrltbl); j++) { |
| if (mch->ctrl[j+1] != 0xff) { | if (mch->ctrl[j+1] != 0xff) { |
| midi->outfn(midi, | midi->outfn(midi, |
| MIDIOUTS(0xb0+i, midictrltbl[j], mch->ctrl[j+1])); | MIDIOUTS(0xb0+i, midictrltbl[j], mch->ctrl[j+1])); |
| Line 343 static void midisetparam(CMMIDI midi) { | Line 343 static void midisetparam(CMMIDI midi) { |
| // ---- | // ---- |
| static UINT midiread(COMMNG self, BYTE *data) { | static UINT midiread(COMMNG self, UINT8 *data) { |
| CMMIDI midi; | CMMIDI midi; |
| Line 357 static UINT midiread(COMMNG self, BYTE * | Line 357 static UINT midiread(COMMNG self, BYTE * |
| return(0); | return(0); |
| } | } |
| static UINT midiwrite(COMMNG self, BYTE data) { | static UINT midiwrite(COMMNG self, UINT8 data) { |
| CMMIDI midi; | CMMIDI midi; |
| MIDICH mch; | MIDICH mch; |
| Line 536 static UINT midiwrite(COMMNG self, BYTE | Line 536 static UINT midiwrite(COMMNG self, BYTE |
| return(0); | return(0); |
| } | } |
| static BYTE midigetstat(COMMNG self) { | static UINT8 midigetstat(COMMNG self) { |
| return(0x00); | return(0x00); |
| } | } |
| Line 577 static long midimsg(COMMNG self, UINT ms | Line 577 static long midimsg(COMMNG self, UINT ms |
| break; | break; |
| case COMMSG_MIMPIDEFFILE: | case COMMSG_MIMPIDEFFILE: |
| mimpidef_load(&midi->def, (char *)param); | mimpidef_load(&midi->def, (OEMCHAR *)param); |
| return(1); | return(1); |
| case COMMSG_MIMPIDEFEN: | case COMMSG_MIMPIDEFEN: |
| Line 666 void cmmidi_initailize(void) { | Line 666 void cmmidi_initailize(void) { |
| UINT i; | UINT i; |
| ZeroMemory(midictrlindex, sizeof(midictrlindex)); | ZeroMemory(midictrlindex, sizeof(midictrlindex)); |
| for (i=0; i<sizeof(midictrltbl)/sizeof(BYTE); i++) { | for (i=0; i<NELEMENTS(midictrltbl); i++) { |
| midictrlindex[midictrltbl[i]] = (BYTE)(i + 1); | midictrlindex[midictrltbl[i]] = (UINT8)(i + 1); |
| } | } |
| midictrlindex[32] = 1; | midictrlindex[32] = 1; |
| } | } |
| COMMNG cmmidi_create(const char *midiout, const char *midiin, | COMMNG cmmidi_create(const OEMCHAR *midiout, const OEMCHAR *midiin, |
| const char *module) { | const OEMCHAR *module) { |
| UINT opened; | UINT opened; |
| UINT id; | UINT id; |
| Line 755 COMMNG cmmidi_create(const char *midiout | Line 755 COMMNG cmmidi_create(const char *midiout |
| midi->midilast = 0x80; | midi->midilast = 0x80; |
| // midi->midiexcvwait = 0; | // midi->midiexcvwait = 0; |
| midi->midimodule = (BYTE)module2number(module); | midi->midimodule = (UINT8)module2number(module); |
| FillMemory(midi->mch, sizeof(midi->mch), 0xff); | FillMemory(midi->mch, sizeof(midi->mch), 0xff); |
| return(ret); | return(ret); |
| Line 777 cmcre_err1: | Line 777 cmcre_err1: |
| // ---- midiin callback | // ---- midiin callback |
| static void midiinrecv(CMMIDI midi, const BYTE *data, UINT size) { | static void midiinrecv(CMMIDI midi, const UINT8 *data, UINT size) { |
| UINT wpos; | UINT wpos; |
| UINT wsize; | UINT wsize; |
| Line 831 void cmmidi_recvdata(HMIDIIN hdr, UINT32 | Line 831 void cmmidi_recvdata(HMIDIIN hdr, UINT32 |
| break; | break; |
| #endif | #endif |
| } | } |
| midiinrecv(midi, (BYTE *)&data, databytes); | midiinrecv(midi, (UINT8 *)&data, databytes); |
| } | } |
| } | } |
| Line 841 void cmmidi_recvexcv(HMIDIIN hdr, MIDIHD | Line 841 void cmmidi_recvexcv(HMIDIIN hdr, MIDIHD |
| midi = midiinhdlget(hdr); | midi = midiinhdlget(hdr); |
| if (midi) { | if (midi) { |
| midiinrecv(midi, (BYTE *)data->lpData, data->dwBytesRecorded); | midiinrecv(midi, (UINT8 *)data->lpData, data->dwBytesRecorded); |
| midiInUnprepareHeader(midi->hmidiin, | midiInUnprepareHeader(midi->hmidiin, |
| &midi->hmidiinhdr, sizeof(MIDIHDR)); | &midi->hmidiinhdr, sizeof(MIDIHDR)); |
| midiInPrepareHeader(midi->hmidiin, | midiInPrepareHeader(midi->hmidiin, |