1 | gmidi_cpp.patch |
---|
2 | S¸AmBINÆ>--- gmidi.cpp Sat Dec 1 12:24:59 2001
|
---|
3 | +++ ../gmidi.cpp Fri Dec 14 19:44:07 2001
|
---|
4 | @@ -25,6 +25,92 @@
|
---|
5 |
|
---|
6 | #include "stdafx.h"
|
---|
7 |
|
---|
8 | +
|
---|
9 | +#ifdef __APPLE__
|
---|
10 | + #include <Carbon/Carbon.h>
|
---|
11 | + #include <AudioUnit/AudioUnit.h>
|
---|
12 | + #define HMIDIOUT void *
|
---|
13 | + #define DWORD unsigned int
|
---|
14 | + #define UCHAR unsigned char
|
---|
15 | + #define MMSYSERR_NOERROR 0
|
---|
16 | + #define MMSYSERR_BADERRNUM 1
|
---|
17 | + #define UINT UCHAR
|
---|
18 | + #define MIDI_MAPPER void *
|
---|
19 | +
|
---|
20 | +AudioUnit au_output;
|
---|
21 | +MusicDeviceComponent au_MusicDevice;
|
---|
22 | +
|
---|
23 | +int midiOutShortMsg(HMIDIOUT handle, DWORD dwData)
|
---|
24 | +{
|
---|
25 | + UCHAR first_byte, seccond_byte, status_byte;
|
---|
26 | + status_byte = (dwData & 0x000000FF);
|
---|
27 | + first_byte = (dwData & 0x0000FF00) >> 8;
|
---|
28 | + seccond_byte = (dwData & 0x00FF0000) >> 16;
|
---|
29 | +
|
---|
30 | + MusicDeviceMIDIEvent(au_MusicDevice, status_byte, first_byte, seccond_byte, 0);
|
---|
31 | +
|
---|
32 | + return 0;
|
---|
33 | +}
|
---|
34 | +
|
---|
35 | +unsigned long midiOutOpen(void)
|
---|
36 | +{
|
---|
37 | + int err;
|
---|
38 | + struct AudioUnitConnection auconnect;
|
---|
39 | + ComponentDescription compdesc;
|
---|
40 | + Component compid;
|
---|
41 | +
|
---|
42 | + au_MusicDevice=au_output=NULL;
|
---|
43 | +
|
---|
44 | + //Open the Music Device
|
---|
45 | + compdesc.componentType=kAudioUnitComponentType;
|
---|
46 | + compdesc.componentSubType=kAudioUnitSubType_MusicDevice;
|
---|
47 | + compdesc.componentManufacturer=kAudioUnitID_DLSSynth;
|
---|
48 | + compdesc.componentFlags=0;
|
---|
49 | + compdesc.componentFlagsMask=0;
|
---|
50 | +
|
---|
51 | + compid=FindNextComponent(NULL,&compdesc);
|
---|
52 | + if (compid==NULL)
|
---|
53 | + return(MMSYSERR_BADERRNUM);
|
---|
54 | +
|
---|
55 | + au_MusicDevice=(AudioUnit)OpenComponent(compid);
|
---|
56 | + if (au_MusicDevice==NULL)
|
---|
57 | + return(MMSYSERR_BADERRNUM);
|
---|
58 | +
|
---|
59 | + // open the output unit
|
---|
60 | + au_output=(AudioUnit)OpenDefaultComponent(kAudioUnitComponentType,kAudioUnitSubType_Output);
|
---|
61 | + if (au_output==NULL)
|
---|
62 | + return(MMSYSERR_BADERRNUM);
|
---|
63 | +
|
---|
64 | + // connect the units
|
---|
65 | +
|
---|
66 | + auconnect.sourceAudioUnit=au_MusicDevice;
|
---|
67 | + auconnect.sourceOutputNumber=0;
|
---|
68 | + auconnect.destInputNumber=0;
|
---|
69 | +
|
---|
70 | + err=AudioUnitSetProperty(au_output,kAudioUnitProperty_MakeConnection,kAudioUnitScope_Input,0,(void*)&auconnect,sizeof(struct AudioUnitConnection));
|
---|
71 | + if (err!=noErr)
|
---|
72 | + return(MMSYSERR_BADERRNUM);
|
---|
73 | +
|
---|
74 | + // initialize the units
|
---|
75 | + if (AudioUnitInitialize(au_MusicDevice)!=noErr)
|
---|
76 | + return(MMSYSERR_BADERRNUM);
|
---|
77 | +
|
---|
78 | + if (AudioUnitInitialize(au_output)!=noErr)
|
---|
79 | + return(MMSYSERR_BADERRNUM);
|
---|
80 | +
|
---|
81 | + // start the output
|
---|
82 | +
|
---|
83 | + AudioOutputUnitStart(au_output);
|
---|
84 | + return(0);
|
---|
85 | +}
|
---|
86 | +
|
---|
87 | +int midiOutClose(HMIDIOUT handle)
|
---|
88 | +{
|
---|
89 | + return 0;
|
---|
90 | +}
|
---|
91 | +
|
---|
92 | +#endif
|
---|
93 | +
|
---|
94 | #if !defined USE_ADLIB
|
---|
95 |
|
---|
96 | #include "scumm.h"
|
---|
97 | @@ -56,6 +142,13 @@
|
---|
98 | error("midiOutOpen failed");
|
---|
99 | }
|
---|
100 |
|
---|
101 | +#define MIDI_OUT(a,b) midiOutShortMsg((HMIDIOUT)(a), (b))
|
---|
102 | +
|
---|
103 | +#elif defined(__APPLE__)
|
---|
104 | +void MidiSoundDriver::midiInit() {
|
---|
105 | + if (midiOutOpen() != MMSYSERR_NOERROR)
|
---|
106 | + error("midiOutOpen failed");
|
---|
107 | +}
|
---|
108 | #define MIDI_OUT(a,b) midiOutShortMsg((HMIDIOUT)(a), (b))
|
---|
109 |
|
---|
110 | #elif defined(USE_TIMIDITY)
|
---|
111 |
|
---|