Music.xs

filter: Statementstmt 6.3% 21 / 331 Branchbran 4.2% 21 / 492 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 5.1% 42 / 823 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/MIDI/Music.pm ↑ Summary
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include <fcntl.h>
5 #include <sys/soundcard.h>
6  
7 #define BUFFSIZE 1024
8  
9 int seqfd = -1;
10 int OSS_initialized = 0;
11  
12 SEQ_DEFINEBUF(BUFFSIZE);
13  
14 #ifndef OSSLIB
15 void seqbuf_dump () {
16  
17 0 ▶ if (_seqbufptr) {
Branch: 1 branch
BranchTrueFalseTotal
if (_seqbufptr) { 0 0 0
18  
19 0 ▶ if (write(seqfd, _seqbuf, _seqbufptr) == -1)
Branch: 1 branch
BranchTrueFalseTotal
if (write(seqfd, _seqbuf, _seqbufptr) == -1) 0 0 0
20 0 croak("write /dev/music");
21 }
22 0 _seqbufptr = 0;
23 0 }
24 #endif
25  
26 static int
27 0 not_here(char *s)
28 {
29 0 croak("%s not implemented on this architecture", s);
30 return -1;
31 }
32  
33 static double
34 0 constant(char *name, int arg)
35 {
36 0 errno = 0;
37 0 switch (*name) {
38 0 case 'A':
39 0 break;
40 0 case 'B':
41 0 break;
42 0 case 'C':
43 0 break;
44 0 case 'D':
45 0 break;
46 0 case 'E':
47 0 ▶ if (strEQ(name, "EV_CHN_COMMON"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_CHN_COMMON")) 0 0 0
48 #ifdef EV_CHN_COMMON
49 0 return EV_CHN_COMMON;
50 #else
51 goto not_there;
52 #endif
53 0 ▶ if (strEQ(name, "EV_CHN_VOICE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_CHN_VOICE")) 0 0 0
54 #ifdef EV_CHN_VOICE
55 0 return EV_CHN_VOICE;
56 #else
57 goto not_there;
58 #endif
59 0 ▶ if (strEQ(name, "EV_SEQ_LOCAL"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_SEQ_LOCAL")) 0 0 0
60 #ifdef EV_SEQ_LOCAL
61 0 return EV_SEQ_LOCAL;
62 #else
63 goto not_there;
64 #endif
65 0 ▶ if (strEQ(name, "EV_SYSEX"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_SYSEX")) 0 0 0
66 #ifdef EV_SYSEX
67 0 return EV_SYSEX;
68 #else
69 goto not_there;
70 #endif
71 0 ▶ if (strEQ(name, "EV_SYSTEM"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_SYSTEM")) 0 0 0
72 #ifdef EV_SYSTEM
73 return EV_SYSTEM;
74 #else
75 0 goto not_there;
76 #endif
77 0 ▶ if (strEQ(name, "EV_TIMING"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "EV_TIMING")) 0 0 0
78 #ifdef EV_TIMING
79 0 return EV_TIMING;
80 #else
81 goto not_there;
82 #endif
83 0 break;
84 0 case 'F':
85 0 break;
86 0 case 'G':
87 0 break;
88 0 case 'H':
89 0 break;
90 0 case 'I':
91 0 break;
92 0 case 'J':
93 0 break;
94 0 case 'K':
95 0 break;
96 0 case 'L':
97 0 break;
98 0 case 'M':
99 0 ▶ if (strEQ(name, "MIDI_CHN_PRESSURE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_CHN_PRESSURE")) 0 0 0
100 #ifdef MIDI_CHN_PRESSURE
101 0 return MIDI_CHN_PRESSURE;
102 #else
103 goto not_there;
104 #endif
105 0 ▶ if (strEQ(name, "MIDI_CTL_CHANGE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_CTL_CHANGE")) 0 0 0
106 #ifdef MIDI_CTL_CHANGE
107 0 return MIDI_CTL_CHANGE;
108 #else
109 goto not_there;
110 #endif
111 0 ▶ if (strEQ(name, "MIDI_KEY_PRESSURE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_KEY_PRESSURE")) 0 0 0
112 #ifdef MIDI_KEY_PRESSURE
113 0 return MIDI_KEY_PRESSURE;
114 #else
115 goto not_there;
116 #endif
117 0 ▶ if (strEQ(name, "MIDI_NOTEOFF"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_NOTEOFF")) 0 0 0
118 #ifdef MIDI_NOTEOFF
119 0 return MIDI_NOTEOFF;
120 #else
121 goto not_there;
122 #endif
123 0 ▶ if (strEQ(name, "MIDI_NOTEON"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_NOTEON")) 0 0 0
124 #ifdef MIDI_NOTEON
125 0 return MIDI_NOTEON;
126 #else
127 goto not_there;
128 #endif
129 0 ▶ if (strEQ(name, "MIDI_PGM_CHANGE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_PGM_CHANGE")) 0 0 0
130 #ifdef MIDI_PGM_CHANGE
131 0 return MIDI_PGM_CHANGE;
132 #else
133 goto not_there;
134 #endif
135 0 ▶ if (strEQ(name, "MIDI_PITCH_BEND"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "MIDI_PITCH_BEND")) 0 0 0
136 #ifdef MIDI_PITCH_BEND
137 0 return MIDI_PITCH_BEND;
138 #else
139 goto not_there;
140 #endif
141 0 break;
142 0 case 'N':
143 0 break;
144 0 case 'O':
145 0 break;
146 0 case 'P':
147 0 break;
148 0 case 'Q':
149 0 break;
150 0 case 'R':
151 0 break;
152 0 case 'S':
153 0 break;
154 0 case 'T':
155 0 ▶ if (strEQ(name, "TMR_CLOCK"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_CLOCK")) 0 0 0
156 #ifdef TMR_CLOCK
157 0 return TMR_CLOCK;
158 #else
159 goto not_there;
160 #endif
161 0 ▶ if (strEQ(name, "TMR_CONTINUE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_CONTINUE")) 0 0 0
162 #ifdef TMR_CONTINUE
163 0 return TMR_CONTINUE;
164 #else
165 goto not_there;
166 #endif
167 0 ▶ if (strEQ(name, "TMR_ECHO"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_ECHO")) 0 0 0
168 #ifdef TMR_ECHO
169 0 return TMR_ECHO;
170 #else
171 goto not_there;
172 #endif
173 0 ▶ if (strEQ(name, "TMR_EXTERNAL"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_EXTERNAL")) 0 0 0
174 #ifdef TMR_EXTERNAL
175 0 return TMR_EXTERNAL;
176 #else
177 goto not_there;
178 #endif
179 0 ▶ if (strEQ(name, "TMR_INTERNAL"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_INTERNAL")) 0 0 0
180 #ifdef TMR_INTERNAL
181 0 return TMR_INTERNAL;
182 #else
183 goto not_there;
184 #endif
185 0 ▶ if (strEQ(name, "TMR_MODE_CLS"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_MODE_CLS")) 0 0 0
186 #ifdef TMR_MODE_CLS
187 0 return TMR_MODE_CLS;
188 #else
189 goto not_there;
190 #endif
191 0 ▶ if (strEQ(name, "TMR_MODE_FSK"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_MODE_FSK")) 0 0 0
192 #ifdef TMR_MODE_FSK
193 0 return TMR_MODE_FSK;
194 #else
195 goto not_there;
196 #endif
197 0 ▶ if (strEQ(name, "TMR_MODE_MIDI"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_MODE_MIDI")) 0 0 0
198 #ifdef TMR_MODE_MIDI
199 0 return TMR_MODE_MIDI;
200 #else
201 goto not_there;
202 #endif
203 0 ▶ if (strEQ(name, "TMR_MODE_SMPTE"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_MODE_SMPTE")) 0 0 0
204 #ifdef TMR_MODE_SMPTE
205 0 return TMR_MODE_SMPTE;
206 #else
207 goto not_there;
208 #endif
209 0 ▶ if (strEQ(name, "TMR_SPP"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_SPP")) 0 0 0
210 #ifdef TMR_SPP
211 0 return TMR_SPP;
212 #else
213 goto not_there;
214 #endif
215 0 ▶ if (strEQ(name, "TMR_START"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_START")) 0 0 0
216 #ifdef TMR_START
217 0 return TMR_START;
218 #else
219 goto not_there;
220 #endif
221 0 ▶ if (strEQ(name, "TMR_STOP"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_STOP")) 0 0 0
222 #ifdef TMR_STOP
223 0 return TMR_STOP;
224 #else
225 goto not_there;
226 #endif
227 0 ▶ if (strEQ(name, "TMR_TEMPO"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_TEMPO")) 0 0 0
228 #ifdef TMR_TEMPO
229 0 return TMR_TEMPO;
230 #else
231 goto not_there;
232 #endif
233 0 ▶ if (strEQ(name, "TMR_TIMESIG"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_TIMESIG")) 0 0 0
234 #ifdef TMR_TIMESIG
235 0 return TMR_TIMESIG;
236 #else
237 goto not_there;
238 #endif
239 0 ▶ if (strEQ(name, "TMR_WAIT_ABS"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_WAIT_ABS")) 0 0 0
240 #ifdef TMR_WAIT_ABS
241 0 return TMR_WAIT_ABS;
242 #else
243 goto not_there;
244 #endif
245 0 ▶ if (strEQ(name, "TMR_WAIT_REL"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(name, "TMR_WAIT_REL")) 0 0 0
246 #ifdef TMR_WAIT_REL
247 0 return TMR_WAIT_REL;
248 #else
249 goto not_there;
250 #endif
251 0 break;
252 0 case 'U':
253 0 break;
254 0 case 'V':
255 0 break;
256 0 case 'W':
257 0 break;
258 0 case 'X':
259 0 break;
260 0 case 'Y':
261 0 break;
262 0 case 'Z':
263 0 break;
264 0 case '_':
265 0 break;
266 }
267 0 errno = EINVAL;
268 0 return 0;
269  
270 0 not_there:
271 0 errno = ENOENT;
272 0 return 0;
273 }
274  
275 MODULE = MIDI::Music PACKAGE = MIDI::Music
276  
277 PROTOTYPES: ENABLE
278  
279 double
280 constant(name,arg)
281 char * name
282 int arg
283  
284  
285 ############################################################################
286 ######################## opening/closing device ############################
287  
288 void
289 init(mm, ...)
290 SV * mm
291 PREINIT:
292 int error, dev_no, ndevices, stidx, tmp, wanted, arrlen, arridx;
293 1 int mode = O_RDWR;
294 char * key;
295 SV * gminstr_ref;
296 SV * gmdrum_ref;
297 SV * timesig_ref;
298 1 HV * towhich = (HV*)SvRV(mm);
299 CODE:
300 {
301 1 ▶ if ((items % 2) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((items % 2) == 0) 0 1 1
302 0 croak("Odd number of elements in hash list");
303  
304 5 ▶ for (stidx = 1; stidx < items; stidx += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (stidx = 1; stidx < items; stidx += 2) { 4 1 5
305  
306 4 key = SvPVX(ST(stidx));
307  
308 4 ▶ if (strEQ(key, "mode")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(key, "mode")) { 1 3 4
309 1 mode = SvIV(ST(stidx + 1));
310 3 ▶ } else if (strEQ(key, "device")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "device")) { 0 3 3
311 0 hv_store(towhich, "_device", 7, newSVsv(ST(stidx + 1)), 0);
312  
313 /********************************
314 * Recording-related parameters */
315 3 ▶ } else if (strEQ(key, "readbuf")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "readbuf")) { 0 3 3
316 0 hv_store(towhich, "_readbuf", 8, newSVsv(ST(stidx + 1)), 0);
317 3 ▶## } else if (strEQ(key, "actsense")) {
Branch: 1 branch
BranchTrueFalseTotal
## } else if (strEQ(key, "actsense")) { 0 3 3
318 0 ## hv_store(towhich, "_actsense", 9, newSVsv(ST(stidx + 1)), 0);
319 } else if (strEQ(key, "realtime")) {
320 hv_store(towhich, "_realtime", 9, newSVsv(ST(stidx + 1)), 0);
321 ## } else if (strEQ(key, "timing")) {
322 3 ▶## hv_store(towhich, "_timing", 7, newSVsv(ST(stidx + 1)), 0);
Branch: 1 branch
BranchTrueFalseTotal
## hv_store(towhich, "_timing", 7, newSVsv(ST(stidx + 1)), 0); 0 3 3
323 0  
324 3 ▶ /********************************
Branch: 1 branch
BranchTrueFalseTotal
/******************************** 1 2 3
325 1 * Playback-related parameters */
326 2 ▶## } else if (strEQ(key, "extbuf")) {
Branch: 1 branch
BranchTrueFalseTotal
## } else if (strEQ(key, "extbuf")) { 1 1 2
327 1 ## hv_store(towhich, "_extbuf", 7, newSVsv(ST(stidx + 1)), 0);
328 1 ▶ } else if (strEQ(key, "gmdrum")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "gmdrum")) { 0 1 1
329 0 hv_store(towhich, "_gmdrum", 7, newSVsv(ST(stidx + 1)), 0);
330 1 ▶ } else if (strEQ(key, "gminstr")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(key, "gminstr")) { 1 0 1
331 1 hv_store(towhich, "_gminstr", 8, newSVsv(ST(stidx + 1)), 0);
332 } else if (strEQ(key, "tempo")) {
333 hv_store(towhich, "_tempo", 6, newSVsv(ST(stidx + 1)), 0);
334 } else if (strEQ(key, "timebase")) {
335 hv_store(towhich, "_timebase", 9, newSVsv(ST(stidx + 1)), 0);
336 } else if (strEQ(key, "timesig")) {
337 1 ▶ hv_store(towhich, "_timesig", 8, newSVsv(ST(stidx + 1)), 0);
Branch: 1 branch
BranchTrueFalseTotal
hv_store(towhich, "_timesig", 8, newSVsv(ST(stidx + 1)), 0); 1 0 1
338 }
339 1 ▶ }
Branch: 6 branches
BranchTrueFalseTotal
} 1 0 1
} 1 0 1
} 0 1 1
} 0 0 0
} 1 0 1
} 0 1 1
340  
341 /*************************************************
342 * open the device, initialize OSSlib if present */
343 1 if ((seqfd = open("/dev/music", mode, 0)) == -1) {
344  
345 hv_store(towhich, "_errstr", 7,
346 newSVpvf("%s::init(): failed to open device '/dev/music'",
347 HvNAME(SvSTASH(towhich))), 0);
348  
349 XSRETURN_NO;
350 }
351 #ifdef OSSLIB
352 if (!OSS_initialized) {
353 if ((error = OSS_init(seqfd, BUFFSIZE)) != 0) {
354  
355 hv_store(towhich, "_errstr", 7,
356 newSVpvf("%s::init(): failed to initialize OSSlib, error %d",
357 0 ▶ HvNAME(SvSTASH(towhich)), error), 0);
Branch: 1 branch
BranchTrueFalseTotal
HvNAME(SvSTASH(towhich)), error), 0); 0 0 0
358 0 ▶ XSRETURN_NO;
Branch: 6 branches
BranchTrueFalseTotal
XSRETURN_NO; 0 0 0
XSRETURN_NO; 0 0 0
XSRETURN_NO; 0 0 0
XSRETURN_NO; 0 0 0
XSRETURN_NO; 0 0 0
XSRETURN_NO; 0 0 0
359 }
360 OSS_initialized = 1;
361 0 }
362 #endif
363 if (ioctl(seqfd, SNDCTL_SEQ_NRSYNTHS, &ndevices) == -1) {
364 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 1 branch
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
365 0 ▶ newSVpvf("%s::init(): device unavailable",
Branch: 6 branches
BranchTrueFalseTotal
newSVpvf("%s::init(): device unavailable", 0 0 0
newSVpvf("%s::init(): device unavailable", 0 0 0
newSVpvf("%s::init(): device unavailable", 0 0 0
newSVpvf("%s::init(): device unavailable", 0 0 0
newSVpvf("%s::init(): device unavailable", 0 0 0
newSVpvf("%s::init(): device unavailable", 0 0 0
366 HvNAME(SvSTASH(towhich))), 0);
367 XSRETURN_NO;
368 0 }
369  
370 if (SvIV(*hv_fetch(towhich, "_device", 7, 0)) >= ndevices) {
371 hv_store(towhich, "_errstr", 7,
372 newSVpvf("%s::init(): device doesn't exist",
373 0 HvNAME(SvSTASH(towhich))), 0);
374 XSRETURN_NO;
375 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
376 0 ▶ 
Branch: 6 branches
BranchTrueFalseTotal
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
377 /*********************************
378 * Set initial timing parameters */
379 0 tmp = wanted = SvIV(*hv_fetch(towhich, "_timebase", 9, 0));
380  
381 0 ▶ if (ioctl(seqfd, SNDCTL_TMR_TIMEBASE, &tmp) == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ioctl(seqfd, SNDCTL_TMR_TIMEBASE, &tmp) == -1) { 0 0 0
382 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
383 newSVpvf("%s::init(): failed to set timebase",
384 HvNAME(SvSTASH(towhich))), 0);
385 0 XSRETURN_NO;
386 }
387 if (tmp != wanted) {
388 0 hv_store(towhich, "_errstr", 7,
389 0 ▶ newSVpvf("%s::init(): failed setting timebase to %d",
Branch: 1 branch
BranchTrueFalseTotal
newSVpvf("%s::init(): failed setting timebase to %d", 0 0 0
390 0 ▶ HvNAME(SvSTASH(towhich)), wanted), 0);
Branch: 6 branches
BranchTrueFalseTotal
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
HvNAME(SvSTASH(towhich)), wanted), 0); 0 0 0
391 XSRETURN_NO;
392 }
393 0  
394 tmp = wanted = SvIV(*hv_fetch(towhich, "_tempo", 6, 0));
395 0 ▶ if (ioctl(seqfd, SNDCTL_TMR_TEMPO, &tmp) == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ioctl(seqfd, SNDCTL_TMR_TEMPO, &tmp) == -1) { 0 0 0
396 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
397 newSVpvf("%s::init(): failed to set initial tempo",
398 HvNAME(SvSTASH(towhich))), 0);
399 0 XSRETURN_NO;
400 }
401 if (tmp != wanted) {
402 hv_store(towhich, "_errstr", 7,
403 0 newSVpvf("%s::init(): failed setting tempo to %d",
404 0 HvNAME(SvSTASH(towhich)), wanted), 0);
405 0 XSRETURN_NO;
406 0 }
407 0  
408 /* time signature is a little complicated */
409 0 timesig_ref = *hv_fetch(towhich, "_timesig", 8, 0);
410 wanted = SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 0, 0 )) << 24;
411 0 wanted |= SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 1, 0 )) << 16;
412 wanted |= SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 2, 0 )) << 8;
413 0 ▶ wanted |= SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 3, 0 ));
Branch: 1 branch
BranchTrueFalseTotal
wanted |= SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 3, 0 )); 0 0 0
414 0 ▶ 
Branch: 6 branches
BranchTrueFalseTotal
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
415 tmp = wanted;
416  
417 if (ioctl(seqfd, SNDCTL_TMR_METRONOME, &tmp) == -1) {
418 #
419 # The above seems to be meaningless -- it is always the case.
420 #
421 0 # hv_store(towhich, "_errstr", 7,
422 # newSVpvf("%s::init(): failed to set initial time signature",
423 # HvNAME(SvSTASH(towhich))), 0);
424 0 # XSRETURN_NO;
425 }
426 if (tmp != wanted) {
427 hv_store(towhich, "_errstr", 7,
428 0 ▶ newSVpvf("%s::init(): failed setting time signature to [ %d, %d, %d, %d ]",
Branch: 2 branches
BranchTrueFalseTotal
newSVpvf("%s::init(): failed setting time signature to [ %d, %d, %d, %d ]", 0 0 0
newSVpvf("%s::init(): failed setting time signature to [ %d, %d, %d, %d ]", 0 0 0
429 0 HvNAME(SvSTASH(towhich)),
430 0 SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 0, 0 )),
431 SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 1, 0 )),
432 0 SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 2, 0 )),
433 0 ▶ SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 3, 0 ))), 0);
Branch: 1 branch
BranchTrueFalseTotal
SvIV(*av_fetch( (AV*)SvRV(timesig_ref), 3, 0 ))), 0); 0 0 0
434 XSRETURN_NO;
435 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
} 0 0 0
436  
437 dev_no = SvIV(*hv_fetch(towhich, "_device", 7, 0));
438  
439 /**********************************
440 * instrument caching for playback*/
441 0 if ((mode == O_RDWR) || (mode == O_WRONLY)) {
442 0 ▶ gminstr_ref = *hv_fetch(towhich, "_gminstr", 8, 0);
Branch: 1 branch
BranchTrueFalseTotal
gminstr_ref = *hv_fetch(towhich, "_gminstr", 8, 0); 0 0 0
443 0 ▶ gmdrum_ref = *hv_fetch(towhich, "_gmdrum", 7, 0);
Branch: 1 branch
BranchTrueFalseTotal
gmdrum_ref = *hv_fetch(towhich, "_gmdrum", 7, 0); 0 0 0
444  
445 arrlen = av_len((AV*)SvRV(gminstr_ref));
446 if (arrlen != -1) {
447
448 for (arridx = 0; arridx <= arrlen; arridx++) {
449 SEQ_LOAD_GMINSTR(dev_no,
450 SvIV(*av_fetch( (AV*)SvRV(gminstr_ref), arridx, 0 )));
451 }
452 0 ▶ }
Branch: 2 branches
BranchTrueFalseTotal
} 0 0 0
} 0 0 0
453  
454 arrlen = av_len((AV*)SvRV(gmdrum_ref));
455 0 ▶ if (arrlen != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (arrlen != -1) { 0 0 0
456 for (arridx = 0; arridx <= arrlen; arridx++) {
457 SEQ_LOAD_GMDRUM(dev_no,
458 SvIV(*av_fetch( (AV*)SvRV(gmdrum_ref), arridx, 0 )));
459 }
460 }
461 }
462  
463 /*****************************
464 0 ▶ * recording-related options */
Branch: 6 branches
BranchTrueFalseTotal
* recording-related options */ 0 0 0
* recording-related options */ 0 0 0
* recording-related options */ 0 0 0
* recording-related options */ 0 0 0
* recording-related options */ 0 0 0
* recording-related options */ 0 0 0
465 if ((mode == O_RDWR) || (mode == O_RDONLY)) {
466  
467 0 ## if (SvIV(*hv_fetch(towhich, "_actsense", 9, 0))) {
468 ###ifdef SNDCTL_SEQ_ACTSENSE_ENABLE
469 ## if (ioctl(seqfd, SNDCTL_SEQ_ACTSENSE_ENABLE, 0) == -1) {
470 0 ▶## hv_store(towhich, "_errstr", 7,
Branch: 1 branch
BranchTrueFalseTotal
## hv_store(towhich, "_errstr", 7, 0 0 0
471 ## newSVpvf("%s::init(): /dev/music ACTSENSE_ENABLE failed",
472 0 ## HvNAME(SvSTASH(towhich))), 0);
473 0 ## XSRETURN_NO;
474 ## }
475 ###else
476 ## hv_store(towhich, "_errstr", 7,
477 ## newSVpvf("%s::init(): 'actsense' option not available",
478 ## HvNAME(SvSTASH(towhich))), 0);
479 ## XSRETURN_NO;
480 ###endif
481 ## }
482 ##
483 ## if (SvIV(*hv_fetch(towhich, "_timing", 7, 0))) {
484 ###ifdef SNDCTL_SEQ_TIMING_ENABLE
485 ## if (ioctl(seqfd, SNDCTL_SEQ_TIMING_ENABLE, 0) == -1) {
486 ## hv_store(towhich, "_errstr", 7,
487 ## newSVpvf("%s::init(): /dev/music TIMING_ENABLE failed",
488 ## HvNAME(SvSTASH(towhich))), 0);
489 ## XSRETURN_NO;
490 ## }
491 ###else
492 ## hv_store(towhich, "_errstr", 7,
493 ## newSVpvf("%s::init(): 'timing' option not available",
494 ## HvNAME(SvSTASH(towhich))), 0);
495 ## XSRETURN_NO;
496 ###endif
497 ## }
498  
499 if (SvIV(*hv_fetch(towhich, "_realtime", 9, 0))) {
500 #ifdef SNDCTL_SEQ_RT_ENABLE
501 if (ioctl(seqfd, SNDCTL_SEQ_RT_ENABLE, 0) == -1) {
502 hv_store(towhich, "_errstr", 7,
503 newSVpvf("%s::init(): /dev/music RT_ENABLE failed",
504 HvNAME(SvSTASH(towhich))), 0);
505 XSRETURN_NO;
506 }
507 #else
508 hv_store(towhich, "_errstr", 7,
509 newSVpvf("%s::init(): 'realtime' option not available",
510 HvNAME(SvSTASH(towhich))), 0);
511 XSRETURN_NO;
512 #endif
513 }
514 SEQ_START_TIMER();
515 }
516 hv_store(towhich, "_initialized", 12, newSViv(1), 0);
517 XSRETURN_YES;
518 }
519  
520 void
521 close(mm)
522 SV * mm
523 PREINIT:
524 0 HV * towhich = (HV *)SvRV(mm);
525 CODE:
526 {
527 0 close(seqfd);
528 0 hv_store(towhich, "_initialized", 12, newSViv(0), 0);
529 }
530  
531 ############################################################################
532 ######################### reading from the device ##########################
533  
534 void
535 _readblock(mm)
536 SV * mm
537 PREINIT:
538 0 HV * towhich = (HV *)SvRV(mm);
539 0 int readbuf = SvIV(*hv_fetch(towhich, "_readbuf", 8, 0));
540 int l;
541 0 unsigned char midichars[readbuf];
542 CODE:
543 {
544 0 ▶ if ((l = read(seqfd, midichars, readbuf)) == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ((l = read(seqfd, midichars, readbuf)) == -1) { 0 0 0
545  
546 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
547 newSVpvf("%s::_readblock(): failed read on /dev/music",
548 HvNAME(SvSTASH(towhich))), 0);
549 0 XSRETURN_UNDEF;
550  
551 } else {
552  
553 0 ST(0) = sv_newmortal();
554 0 sv_setpvn(ST(0), midichars, l);
555  
556 }
557 }
558  
559 ##########################
560 ## Play an event structure
561  
562 void
563 playevents(mm, event_struct)
564 SV * mm
565 SV * event_struct
566 PREINIT:
567 0 HV * towhich = (HV *)SvRV(mm);
568 0 AV * events = (AV*)SvRV(event_struct);
569 AV * event;
570 /*
571 * here I break things up the declarations
572 * in order to describe the data I'm dealing with
573 */
574 int evs_index;
575 char * event_type;
576 int usecs_per_qn, bpm; /* tempo messages */
577 int timesig;
578 int chan, note, vel; /* note messages */
579 int controller, value; /* control messages */
580 int patch; /* 0 to 127 */
581 int wheel; /* -8192 to 8192 */
582 int sysex_len;
583 char * sysex_data;
584 0 int dtime = 0, time = 0, last = time;
585 0 int dev = SvIV(*hv_fetch(towhich, "_device", 7, 0));
586 CODE:
587 {
588 0 ▶ SEQ_START_TIMER(); /* doesn't hurt. */
Branch: 1 branch
BranchTrueFalseTotal
SEQ_START_TIMER(); /* doesn't hurt. */ 0 0 0
589 0 ▶ for (evs_index = 0; evs_index <= av_len(events); evs_index++) {
Branch: 1 branch
BranchTrueFalseTotal
for (evs_index = 0; evs_index <= av_len(events); evs_index++) { 0 0 0
590  
591 0 event = (AV*)SvRV(*av_fetch(events, evs_index, 0));
592  
593 0 ▶ if (av_len(event) < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) < 1) { 0 0 0
594 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
595 newSVpvf("%s::playevents(): %d elements in event (ought to have at least 2)",
596 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
597 0 XSRETURN_NO;
598 }
599  
600 0 event_type = SvPVX(*av_fetch(event, 0, 0));
601 0 dtime = SvIV(*av_fetch(event, 1, 0));
602  
603 0 ▶ if (dtime) {
Branch: 1 branch
BranchTrueFalseTotal
if (dtime) { 0 0 0
604 0 last = time;
605 0 time = time + dtime;
606 0 ▶ SEQ_WAIT_TIME(time);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_WAIT_TIME(time); 0 0 0
607 }
608  
609 0 ▶ if (strEQ(event_type, "note_off")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(event_type, "note_off")) { 0 0 0
610  
611 0 ▶ if (av_len(event) != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 4) { 0 0 0
612 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
613 newSVpvf("%s::playevents(): %d elements in note_off event",
614 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
615 0 XSRETURN_NO;
616 }
617  
618 0 chan = SvIV(*av_fetch(event, 2, 0));
619 0 note = SvIV(*av_fetch(event, 3, 0));
620 0 vel = SvIV(*av_fetch(event, 4, 0));
621  
622 0 ▶ SEQ_STOP_NOTE(dev, chan, note, vel);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_STOP_NOTE(dev, chan, note, vel); 0 0 0
623  
624 0 ▶ } else if (strEQ(event_type, "note_on")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "note_on")) { 0 0 0
625  
626 0 ▶ if (av_len(event) != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 4) { 0 0 0
627 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
628 newSVpvf("%s::playevents(): %d elements in note_on event",
629 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
630 0 XSRETURN_NO;
631 }
632  
633 0 chan = SvIV(*av_fetch(event, 2, 0));
634 0 note = SvIV(*av_fetch(event, 3, 0));
635 0 vel = SvIV(*av_fetch(event, 4, 0));
636  
637 0 ▶ SEQ_START_NOTE(dev, chan, note, vel);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_START_NOTE(dev, chan, note, vel); 0 0 0
638  
639 0 ▶ } else if (strEQ(event_type, "key_after_touch")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "key_after_touch")) { 0 0 0
640  
641 0 ▶ if (av_len(event) != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 4) { 0 0 0
642 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
643 newSVpvf("%s::playevents(): %d elements in key_after_touch event",
644 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
645 0 XSRETURN_NO;
646 }
647  
648 0 chan = SvIV(*av_fetch(event, 2, 0));
649 0 note = SvIV(*av_fetch(event, 3, 0));
650 0 vel = SvIV(*av_fetch(event, 4, 0));
651  
652 0 ▶ SEQ_KEY_PRESSURE(dev, chan, note, vel);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_KEY_PRESSURE(dev, chan, note, vel); 0 0 0
653  
654 0 ▶ } else if (strEQ(event_type, "control_change")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "control_change")) { 0 0 0
655  
656 0 ▶ if (av_len(event) != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 4) { 0 0 0
657 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
658 newSVpvf("%s::playevents(): %d elements in control_change event",
659 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
660 0 XSRETURN_NO;
661 }
662  
663 0 chan = SvIV(*av_fetch(event, 2, 0));
664 0 controller = SvIV(*av_fetch(event, 3, 0));
665 0 value = SvIV(*av_fetch(event, 4, 0));
666  
667 0 ▶ SEQ_CONTROL(dev, chan, controller, value);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_CONTROL(dev, chan, controller, value); 0 0 0
668  
669 0 ▶ } else if (strEQ(event_type, "patch_change")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "patch_change")) { 0 0 0
670  
671 0 ▶ if (av_len(event) != 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 3) { 0 0 0
672 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
673 newSVpvf("%s::playevents(): %d elements in patch_change event",
674 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
675 0 XSRETURN_NO;
676 }
677  
678 0 chan = SvIV(*av_fetch(event, 2, 0));
679 0 patch = SvIV(*av_fetch(event, 3, 0));
680  
681 0 ▶ SEQ_PGM_CHANGE(dev, chan, patch);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_PGM_CHANGE(dev, chan, patch); 0 0 0
682  
683 0 ▶ } else if (strEQ(event_type, "channel_after_touch")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "channel_after_touch")) { 0 0 0
684  
685 0 ▶ if (av_len(event) != 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 3) { 0 0 0
686 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
687 newSVpvf("%s::playevents(): %d elements in channel_after_touch event",
688 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
689 0 XSRETURN_NO;
690 }
691  
692 0 chan = SvIV(*av_fetch(event, 2, 0));
693 0 vel = SvIV(*av_fetch(event, 3, 0));
694  
695 0 ▶ SEQ_CHN_PRESSURE(dev, chan, vel);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_CHN_PRESSURE(dev, chan, vel); 0 0 0
696  
697 0 ▶ } else if (strEQ(event_type, "pitch_wheel_change")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "pitch_wheel_change")) { 0 0 0
698  
699 0 ▶ if (av_len(event) != 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 3) { 0 0 0
700 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
701 newSVpvf("%s::playevents(): %d elements in pitch_wheel_change event",
702 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
703 0 XSRETURN_NO;
704 }
705  
706 0 chan = SvIV(*av_fetch(event, 2, 0));
707 0 wheel = SvIV(*av_fetch(event, 3, 0)) + 8192;
708  
709 0 ▶ SEQ_BENDER(dev, chan, wheel);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_BENDER(dev, chan, wheel); 0 0 0
710  
711  
712 /*****************************************************
713 *
714 * Not doing anything with text events at present...
715 * Might include a feature to map filehandles to these
716 * events in a future version.
717 */
718 0 ▶ } else if (strEQ(event_type, "text_event")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event")) { 0 0 0
719 0 ▶ } else if (strEQ(event_type, "copyright_text_event")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "copyright_text_event")) { 0 0 0
720 0 ▶ } else if (strEQ(event_type, "track_name")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "track_name")) { 0 0 0
721 0 ▶ } else if (strEQ(event_type, "instrument_name")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "instrument_name")) { 0 0 0
722 0 ▶ } else if (strEQ(event_type, "lyric")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "lyric")) { 0 0 0
723 0 ▶ } else if (strEQ(event_type, "marker")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "marker")) { 0 0 0
724 0 ▶ } else if (strEQ(event_type, "cue_point")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "cue_point")) { 0 0 0
725 0 ▶ } else if (strEQ(event_type, "text_event_08")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_08")) { 0 0 0
726 0 ▶ } else if (strEQ(event_type, "text_event_09")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_09")) { 0 0 0
727 0 ▶ } else if (strEQ(event_type, "text_event_0a")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0a")) { 0 0 0
728 0 ▶ } else if (strEQ(event_type, "text_event_0b")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0b")) { 0 0 0
729 0 ▶ } else if (strEQ(event_type, "text_event_0c")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0c")) { 0 0 0
730 0 ▶ } else if (strEQ(event_type, "text_event_0d")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0d")) { 0 0 0
731 0 ▶ } else if (strEQ(event_type, "text_event_0e")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0e")) { 0 0 0
732 0 ▶ } else if (strEQ(event_type, "text_event_0f")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "text_event_0f")) { 0 0 0
733 0 ▶ } else if (strEQ(event_type, "end_track")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "end_track")) { 0 0 0
734 0 ▶ } else if (strEQ(event_type, "set_tempo")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "set_tempo")) { 0 0 0
735  
736 0 ▶ if (av_len(event) != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 2) { 0 0 0
737 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
738 newSVpvf("%s::playevents(): %d elements in set_tempo event",
739 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
740 0 XSRETURN_NO;
741 }
742  
743 0 usecs_per_qn = SvIV(*av_fetch(event, 2, 0));
744 /* bpm = (60000000 + (usecs_per_qn / 2)) / usecs_per_qn; */
745 0 bpm = 60000000 / usecs_per_qn;
746  
747 0 ▶ SEQ_SET_TEMPO(bpm);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_SET_TEMPO(bpm); 0 0 0
748  
749 0 ▶ } else if (strEQ(event_type, "smpte_offset")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "smpte_offset")) { 0 0 0
750 0 ▶ } else if (strEQ(event_type, "time_signature")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "time_signature")) { 0 0 0
751  
752 0 ▶ if (av_len(event) != 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(event) != 5) { 0 0 0
753 0 ▶ hv_store(towhich, "_errstr", 7,
Branch: 6 branches
BranchTrueFalseTotal
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
hv_store(towhich, "_errstr", 7, 0 0 0
754 newSVpvf("%s::playevents(): %d elements in time_signature event",
755 HvNAME(SvSTASH(towhich)), (av_len(event) + 1)), 0);
756 0 XSRETURN_NO;
757 }
758  
759 0 timesig = SvIV(*av_fetch(event, 2, 0)) << 24;
760 0 timesig |= SvIV(*av_fetch(event, 3, 0)) << 16;
761 0 timesig |= SvIV(*av_fetch(event, 4, 0)) << 8;
762 0 timesig |= SvIV(*av_fetch(event, 5, 0));
763  
764 0 ▶ SEQ_TIME_SIGNATURE(timesig);
Branch: 1 branch
BranchTrueFalseTotal
SEQ_TIME_SIGNATURE(timesig); 0 0 0
765  
766 0 ▶ } else if (strEQ(event_type, "key_signature")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "key_signature")) { 0 0 0
767 0 ▶ } else if (strEQ(event_type, "sequencer_specific")) { /* do nothing for now... */
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "sequencer_specific")) { /* do nothing for now... */ 0 0 0
768 0 ▶ } else if (strEQ(event_type, "raw_meta_event")) { /* do nothing for now... */
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "raw_meta_event")) { /* do nothing for now... */ 0 0 0
769 0 ▶ } else if (strEQ(event_type, "sysex_f0")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "sysex_f0")) { 0 0 0
770  
771 0 sysex_data = SvPVX(*av_fetch(event, 2, 0));
772 0 sysex_len = SvCUR(*av_fetch(event, 2, 0));
773 0 ▶ SEQ_SYSEX(dev, sysex_data, sysex_len);
Branch: 4 branches
BranchTrueFalseTotal
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
774  
775 0 ▶ } else if (strEQ(event_type, "sysex_f7")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "sysex_f7")) { 0 0 0
776  
777 0 sysex_data = SvPVX(*av_fetch(event, 2, 0));
778 0 sysex_len = SvCUR(*av_fetch(event, 2, 0));
779 0 ▶ SEQ_SYSEX(dev, sysex_data, sysex_len);
Branch: 4 branches
BranchTrueFalseTotal
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
SEQ_SYSEX(dev, sysex_data, sysex_len); 0 0 0
780  
781 0 ▶ } else if (strEQ(event_type, "song_position")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "song_position")) { 0 0 0
782 0 ▶ } else if (strEQ(event_type, "song_select")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "song_select")) { 0 0 0
783 0 ▶ } else if (strEQ(event_type, "tune_request")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strEQ(event_type, "tune_request")) { 0 0 0
784 0 } else if (strEQ(event_type, "raw_data")) { /* do nothing for now... */
785 }
786 }
787 0 XSRETURN_YES;
788 }
789  
790 void
791 dumpbuf(mm)
792 SV * mm
793 CODE:
794 0 SEQ_DUMPBUF();
« blib/lib/MIDI/Music.pm ↑ Summary