diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_midi_sgi.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/s_midi_sgi.c | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_midi_sgi.c b/apps/plugins/pdbox/PDa/src/s_midi_sgi.c deleted file mode 100644 index 105a812b49..0000000000 --- a/apps/plugins/pdbox/PDa/src/s_midi_sgi.c +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
2 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
3 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
4 | |||
5 | #include "s_stuff.h" | ||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <unistd.h> | ||
9 | #include <string.h> | ||
10 | #ifdef HAVE_BSTRING_H | ||
11 | #include <bstring.h> | ||
12 | #endif | ||
13 | #include <sys/types.h> | ||
14 | #include <sys/time.h> | ||
15 | |||
16 | #include <dmedia/audio.h> | ||
17 | #include <sys/fpu.h> | ||
18 | #include <dmedia/midi.h> | ||
19 | int mdInit(void); /* prototype was messed up in midi.h */ | ||
20 | /* #include "sys/select.h" */ | ||
21 | |||
22 | |||
23 | /* | ||
24 | set the special "flush zero" but (FS, bit 24) in the | ||
25 | Control Status Register of the FPU of R4k and beyond | ||
26 | so that the result of any underflowing operation will | ||
27 | be clamped to zero, and no exception of any kind will | ||
28 | be generated on the CPU. | ||
29 | |||
30 | thanks to cpirazzi@cp.esd.sgi.com (Chris Pirazzi). | ||
31 | */ | ||
32 | |||
33 | static void sgi_flush_all_underflows_to_zero(void) | ||
34 | { | ||
35 | union fpc_csr f; | ||
36 | f.fc_word = get_fpc_csr(); | ||
37 | f.fc_struct.flush = 1; | ||
38 | set_fpc_csr(f.fc_word); | ||
39 | } | ||
40 | |||
41 | #define NPORT 2 | ||
42 | |||
43 | static MDport sgi_inport[NPORT]; | ||
44 | static MDport sgi_outport[NPORT]; | ||
45 | |||
46 | void sgi_open_midi(int midiin, int midiout) | ||
47 | { | ||
48 | int i; | ||
49 | int sgi_nports = mdInit(); | ||
50 | if (sgi_nports < 0) sgi_nports = 0; | ||
51 | else if (sgi_nports > NPORT) sgi_nports = NPORT; | ||
52 | if (sys_verbose) | ||
53 | { | ||
54 | if (!sgi_nports) | ||
55 | { | ||
56 | post("no serial ports are configured for MIDI;"); | ||
57 | post("if you want to use MIDI, try exiting Pd, typing"); | ||
58 | post("'startmidi -d /dev/ttyd2' to a shell, and restarting Pd."); | ||
59 | } | ||
60 | else if (sgi_nports == 1) | ||
61 | post("Found one MIDI port on %s", mdGetName(0)); | ||
62 | else if (sgi_nports == 2) | ||
63 | post("Found MIDI ports on %s and %s", | ||
64 | mdGetName(0), mdGetName(1)); | ||
65 | } | ||
66 | if (midiin) | ||
67 | { | ||
68 | for (i = 0; i < sgi_nports; i++) | ||
69 | { | ||
70 | if (!(sgi_inport[i] = mdOpenInPort(mdGetName(i)))) | ||
71 | error("MIDI input port %d: open failed", i+1);; | ||
72 | } | ||
73 | } | ||
74 | if (midiout) | ||
75 | { | ||
76 | for (i = 0; i < sgi_nports; i++) | ||
77 | { | ||
78 | if (!(sgi_outport[i] = mdOpenOutPort(mdGetName(i)))) | ||
79 | error("MIDI output port %d: open failed", i+1);; | ||
80 | } | ||
81 | } | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | void sys_putmidimess(int portno, int a, int b, int c) | ||
86 | { | ||
87 | MDevent mdv; | ||
88 | if (portno >= NPORT || portno < 0 || !sgi_outport[portno]) return; | ||
89 | mdv.msg[0] = a; | ||
90 | mdv.msg[1] = b; | ||
91 | mdv.msg[2] = c; | ||
92 | mdv.msg[3] = 0; | ||
93 | mdv.sysexmsg = 0; | ||
94 | mdv.stamp = 0; | ||
95 | mdv.msglen = 0; | ||
96 | if (mdSend(sgi_outport[portno], &mdv, 1) < 0) | ||
97 | error("MIDI output error\n"); | ||
98 | post("msg out %d %d %d", a, b, c); | ||
99 | } | ||
100 | |||
101 | void sys_putmidibyte(int portno, int foo) | ||
102 | { | ||
103 | error("MIDI raw byte output not available on SGI"); | ||
104 | } | ||
105 | |||
106 | void inmidi_noteon(int portno, int channel, int pitch, int velo); | ||
107 | void inmidi_controlchange(int portno, int channel, int ctlnumber, int value); | ||
108 | void inmidi_programchange(int portno, int channel, int value); | ||
109 | void inmidi_pitchbend(int portno, int channel, int value); | ||
110 | void inmidi_aftertouch(int portno, int channel, int value); | ||
111 | void inmidi_polyaftertouch(int portno, int channel, int pitch, int value); | ||
112 | |||
113 | void sys_poll_midi(void) | ||
114 | { | ||
115 | int i; | ||
116 | MDport *mp; | ||
117 | for (i = 0, mp = sgi_inport; i < NPORT; i++, mp++) | ||
118 | { | ||
119 | int ret, status, b1, b2, nfds; | ||
120 | MDevent mdv; | ||
121 | fd_set inports; | ||
122 | struct timeval timeout; | ||
123 | timeout.tv_sec = 0; | ||
124 | timeout.tv_usec = 0; | ||
125 | if (!*mp) continue; | ||
126 | FD_ZERO(&inports); | ||
127 | FD_SET(mdGetFd(*mp), &inports); | ||
128 | |||
129 | if (select(mdGetFd(*mp)+1 , &inports, 0, 0, &timeout) < 0) | ||
130 | perror("midi select"); | ||
131 | if (FD_ISSET(mdGetFd(*mp),&inports)) | ||
132 | { | ||
133 | if (mdReceive(*mp, &mdv, 1) < 0) | ||
134 | error("failure receiving message\n"); | ||
135 | else if (mdv.msg[0] == MD_SYSEX) mdFree(mdv.sysexmsg); | ||
136 | |||
137 | else | ||
138 | { | ||
139 | int status = mdv.msg[0]; | ||
140 | int channel = (status & 0xf) + 1; | ||
141 | int b1 = mdv.msg[1]; | ||
142 | int b2 = mdv.msg[2]; | ||
143 | switch(status & 0xf0) | ||
144 | { | ||
145 | case MD_NOTEOFF: | ||
146 | inmidi_noteon(i, channel, b1, 0); | ||
147 | break; | ||
148 | case MD_NOTEON: | ||
149 | inmidi_noteon(i, channel, b1, b2); | ||
150 | break; | ||
151 | case MD_POLYKEYPRESSURE: | ||
152 | inmidi_polyaftertouch(i, channel, b1, b2); | ||
153 | break; | ||
154 | case MD_CONTROLCHANGE: | ||
155 | inmidi_controlchange(i, channel, b1, b2); | ||
156 | break; | ||
157 | case MD_PITCHBENDCHANGE: | ||
158 | inmidi_pitchbend(i, channel, ((b2 << 7) + b1)); | ||
159 | break; | ||
160 | case MD_PROGRAMCHANGE: | ||
161 | inmidi_programchange(i, channel, b1); | ||
162 | break; | ||
163 | case MD_CHANNELPRESSURE: | ||
164 | inmidi_aftertouch(i, channel, b1); | ||
165 | break; | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
172 | void sys_open_midi(int nmidiin, int *midiinvec, | ||
173 | int nmidiout, int *midioutvec) | ||
174 | { | ||
175 | sgi_open_midi(nmidiin!=0, nmidiout!=0); | ||
176 | } | ||
177 | |||
178 | |||
179 | void sys_close_midi( void) | ||
180 | { | ||
181 | /* ??? */ | ||
182 | } | ||
183 | |||
184 | void sys_set_priority(int foo) | ||
185 | { | ||
186 | fprintf(stderr, | ||
187 | "warning: priority boosting in IRIX not implemented yet\n"); | ||
188 | } | ||
189 | |||