diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
commit | 526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch) | |
tree | 22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/src/s_midi_pm.c | |
parent | 4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff) | |
download | rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip |
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_midi_pm.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/s_midi_pm.c | 165 |
1 files changed, 0 insertions, 165 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_midi_pm.c b/apps/plugins/pdbox/PDa/src/s_midi_pm.c index b167175396..a4f376e0ca 100644 --- a/apps/plugins/pdbox/PDa/src/s_midi_pm.c +++ b/apps/plugins/pdbox/PDa/src/s_midi_pm.c | |||
@@ -164,169 +164,4 @@ void sys_listmididevs(void) /* lifted from pa_devs.c in portaudio */ | |||
164 | printf("\n"); | 164 | printf("\n"); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | /* Copyright (c) 1997-2003 Guenter Geiger, Miller Puckette, Larry Troxler, | ||
168 | * Winfried Ritsch, Karl MacMillan, and others. | ||
169 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
170 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. | ||
171 | |||
172 | this file calls portmidi to do MIDI I/O for MSW and Mac OSX. | ||
173 | |||
174 | */ | ||
175 | |||
176 | #include "m_pd.h" | ||
177 | #include "s_stuff.h" | ||
178 | #include <stdio.h> | ||
179 | #ifdef UNIX | ||
180 | #include <unistd.h> | ||
181 | #include <sys/time.h> | ||
182 | #include <sys/resource.h> | ||
183 | #endif | ||
184 | #include <stdlib.h> | ||
185 | #include <string.h> | ||
186 | #include <errno.h> | ||
187 | #include "portaudio.h" | ||
188 | #include "portmidi.h" | ||
189 | #include "porttime.h" | ||
190 | #include "pminternal.h" | ||
191 | 167 | ||
192 | static PmStream *mac_midiindevlist[MAXMIDIINDEV]; | ||
193 | static PmStream *mac_midioutdevlist[MAXMIDIOUTDEV]; | ||
194 | static int mac_nmidiindev; | ||
195 | static int mac_nmidioutdev; | ||
196 | |||
197 | void sys_open_midi(int nmidiin, int *midiinvec, | ||
198 | int nmidiout, int *midioutvec) | ||
199 | { | ||
200 | int i = 0; | ||
201 | int n = 0; | ||
202 | PmError err; | ||
203 | |||
204 | Pt_Start(1, 0, 0); /* start a timer with millisecond accuracy */ | ||
205 | mac_nmidiindev = 0; | ||
206 | |||
207 | /* protect the unwary from having MIDI inputs open; they're | ||
208 | bad news if you close Pd's terminal window. see sys_nmidiin | ||
209 | in s_main.c too. */ | ||
210 | #ifdef MSW | ||
211 | if (nmidiin) | ||
212 | { | ||
213 | post( | ||
214 | "midi input enabled; warning, don't close the DOS window directly!"); | ||
215 | } | ||
216 | else post("not using MIDI input (use 'pd -midiindev 1' to override)"); | ||
217 | #endif | ||
218 | |||
219 | for (i = 0; i < nmidiin; i++) | ||
220 | { | ||
221 | if (midiinvec[i] == DEFMIDIDEV) | ||
222 | midiinvec[i] = Pm_GetDefaultInputDeviceID(); | ||
223 | err = Pm_OpenInput(&mac_midiindevlist[mac_nmidiindev], midiinvec[i], | ||
224 | NULL, 100, NULL, NULL, NULL); | ||
225 | if (err) | ||
226 | post("could not open midi input device number %d: %s", | ||
227 | midiinvec[i], Pm_GetErrorText(err)); | ||
228 | else | ||
229 | { | ||
230 | if (sys_verbose) | ||
231 | post("Midi Input opened.\n"); | ||
232 | mac_nmidiindev++; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | mac_nmidioutdev = 0; | ||
237 | for (i = 0; i < nmidiout; i++) | ||
238 | { | ||
239 | if (midioutvec[i] == DEFMIDIDEV) | ||
240 | midioutvec[i] = Pm_GetDefaultOutputDeviceID(); | ||
241 | err = Pm_OpenOutput(&mac_midioutdevlist[mac_nmidioutdev], midioutvec[i], | ||
242 | NULL, 0, NULL, NULL, 0); | ||
243 | if (err) | ||
244 | post("could not open midi output device number %d: %s", | ||
245 | midioutvec[i], Pm_GetErrorText(err)); | ||
246 | else | ||
247 | { | ||
248 | if (sys_verbose) | ||
249 | post("Midi Output opened.\n"); | ||
250 | mac_nmidioutdev++; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | void sys_close_midi( void) | ||
256 | { | ||
257 | int i; | ||
258 | for (i = 0; i < mac_nmidiindev; i++) | ||
259 | Pm_Close(mac_midiindevlist[mac_nmidiindev]); | ||
260 | mac_nmidiindev = 0; | ||
261 | for (i = 0; i < mac_nmidioutdev; i++) | ||
262 | Pm_Close(mac_midioutdevlist[mac_nmidioutdev]); | ||
263 | mac_nmidioutdev = 0; | ||
264 | } | ||
265 | |||
266 | void sys_putmidimess(int portno, int a, int b, int c) | ||
267 | { | ||
268 | PmEvent buffer; | ||
269 | fprintf(stderr, "put 1 msg %d %d\n", portno, mac_nmidioutdev); | ||
270 | if (portno >= 0 && portno < mac_nmidioutdev) | ||
271 | { | ||
272 | buffer.message = Pm_Message(a, b, c); | ||
273 | buffer.timestamp = 0; | ||
274 | fprintf(stderr, "put msg\n"); | ||
275 | Pm_Write(mac_midioutdevlist[portno], &buffer, 1); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | void sys_putmidibyte(int portno, int byte) | ||
280 | { | ||
281 | post("sorry, no byte-by-byte MIDI output implemented in MAC OSX"); | ||
282 | } | ||
283 | |||
284 | void sys_poll_midi(void) | ||
285 | { | ||
286 | int i, nmess; | ||
287 | PmEvent buffer; | ||
288 | for (i = 0; i < mac_nmidiindev; i++) | ||
289 | { | ||
290 | int nmess = Pm_Read(mac_midiindevlist[i], &buffer, 1); | ||
291 | if (nmess > 0) | ||
292 | { | ||
293 | int status = Pm_MessageStatus(buffer.message); | ||
294 | int data1 = Pm_MessageData1(buffer.message); | ||
295 | int data2 = Pm_MessageData2(buffer.message); | ||
296 | int msgtype = (status >> 4) - 8; | ||
297 | switch (msgtype) | ||
298 | { | ||
299 | case 0: | ||
300 | case 1: | ||
301 | case 2: | ||
302 | case 3: | ||
303 | case 6: | ||
304 | sys_midibytein(i, status); | ||
305 | sys_midibytein(i, data1); | ||
306 | sys_midibytein(i, data2); | ||
307 | break; | ||
308 | case 4: | ||
309 | case 5: | ||
310 | sys_midibytein(i, status); | ||
311 | sys_midibytein(i, data1); | ||
312 | break; | ||
313 | case 7: | ||
314 | sys_midibytein(i, status); | ||
315 | break; | ||
316 | } | ||
317 | } | ||
318 | } | ||
319 | } | ||
320 | |||
321 | void sys_listmididevs(void) /* lifted from pa_devs.c in portaudio */ | ||
322 | { | ||
323 | int i,j; | ||
324 | for (i = 0; i < Pm_CountDevices(); i++) | ||
325 | { | ||
326 | const PmDeviceInfo *info = Pm_GetDeviceInfo(i); | ||
327 | printf("%d: %s, %s", i, info->interf, info->name); | ||
328 | if (info->input) printf(" (input)"); | ||
329 | if (info->output) printf(" (output)"); | ||
330 | printf("\n"); | ||
331 | } | ||
332 | } | ||