~ubuntu-branches/debian/jessie/bristol/jessie

« back to all changes in this revision

Viewing changes to libbristolmidi/midiParse.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-11-10 12:21:04 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091110122104-432yau0haobyl122
Tags: 0.40.6-1
* Adopting this (Closes: #546954).
* Create new bristol-data runtime package, it will contain application's
  architecture-indipendent data files.
* Drop all patches, now useless.
* Switch to debhelper 7.
* debian/copyright: Update according to DEP-5 spec.
* debian/bristol.1: Fix little spelling mistake.
* Replace patch system, from dpatch to quilt.
* Add 01-spelling_errors.patch patch to fix spelling-error-in-binary.
* debian/rules: dh_makeshlibs doesn't touch shlibs/symbols file, libraries
  under /usr/lib/bristol/ are private.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
3
 *  Diverse Bristol midi routines.
4
 
 *  Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2008
 
4
 *  Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2009
5
5
 *
6
6
 *
7
7
 *   This program is free software; you can redistribute it and/or modify
22
22
 
23
23
/*#define DEBUG */
24
24
 
 
25
#include <sys/time.h>
 
26
#include <time.h>
25
27
#include <string.h>
26
28
 
27
29
#include <bristolmidi.h>
49
51
 
50
52
        switch (msg->command & MIDI_COMMAND_MASK) {
51
53
                case MIDI_NOTE_ON:
52
 
                        printf("%s ch %i: %i, velocity %i\n", eventNames[command],
 
54
                        printf("%s (%i) ch %i: %i, velocity %i\n", eventNames[command],
 
55
                                msg->sequence,
53
56
                                msg->channel, msg->params.key.key,  msg->params.key.velocity);
54
57
                        break;
55
58
                case MIDI_NOTE_OFF:
56
 
                        printf("%s ch %i: %i, velocity %i\n", eventNames[command],
 
59
                        printf("%s (%i) ch %i: %i, velocity %i\n", eventNames[command],
 
60
                                msg->sequence,
57
61
                                msg->channel, msg->params.key.key,  msg->params.key.velocity);
58
62
                        break;
59
63
                case MIDI_POLY_PRESS:
60
 
                        printf("%s ch %i: key %i, pressure %i\n", eventNames[command],
61
 
                                msg->channel,
 
64
                        printf("%s (%i) ch %i: key %i, pressure %i\n", eventNames[command],
 
65
                                msg->sequence, msg->channel,
62
66
                                msg->params.pressure.key,  msg->params.pressure.pressure);
63
67
                        break;
64
68
                case MIDI_CONTROL:
65
69
                        if (controllerName[msg->params.controller.c_id] == NULL)
66
 
                                printf("%s ch %i: c_id %i, c_val %i\n", eventNames[command],
 
70
                                printf("%s (%i) ch %i: c_id %i, c_val %i\n",
 
71
                                        eventNames[command],
 
72
                                        msg->sequence,
67
73
                                        msg->channel,
68
74
                                        msg->params.controller.c_id,
69
75
                                        msg->params.controller.c_val);
70
76
                        else
71
 
                                printf("%s ch %i: %s, value %i\n", eventNames[command],
 
77
                                printf("%s (%i) ch %i: %s, value %i\n", eventNames[command],
 
78
                                        msg->sequence,
72
79
                                        msg->channel,
73
80
                                        controllerName[msg->params.controller.c_id],
74
81
                                        msg->params.controller.c_val);
75
82
                        break;
76
83
                case MIDI_PROGRAM:
77
 
                        printf("%s ch %i: p_id %i\n", eventNames[command],
 
84
                        printf("%s (%i) ch %i: p_id %i\n", eventNames[command],
 
85
                                msg->sequence,
78
86
                                msg->channel, msg->params.program.p_id);
79
87
                        break;
80
88
                case MIDI_CHAN_PRESS:
81
 
                        printf("%s ch %i: pressure %i\n", eventNames[command],
 
89
                        printf("%s (%i) ch %i: pressure %i\n", eventNames[command],
 
90
                                msg->sequence,
82
91
                                msg->channel, msg->params.channelpress.pressure);
83
92
                        break;
84
93
                case MIDI_PITCHWHEEL:
85
 
                        printf("%s ch %i: msb %i, lsb %i\n", eventNames[command],
 
94
                        printf("%s (%i) ch %i: msb %i, lsb %i\n", eventNames[command],
 
95
                                msg->sequence,
86
96
                                msg->channel, msg->params.pitch.msb, msg->params.pitch.lsb);
87
97
                        break;
88
98
        }
268
278
                bmidi.dev[dev].lastcommand);
269
279
#endif
270
280
 
271
 
        msg->timestamp = (time_t) 0;
 
281
        gettimeofday(&(msg->timestamp), 0);
 
282
 
272
283
        /*
273
284
         * We have enough message capacity, put information into the message buffer
274
285
         * and return.
276
287
        msg->command = bmidi.dev[dev].lastcommand;
277
288
        msg->channel = bmidi.dev[dev].lastchan;
278
289
 
 
290
        msg->sequence = bmidi.dev[dev].sequence++;
 
291
 
279
292
        if (p1 != 0xff)
280
293
        {
281
294
                msg->params.key.key = p1;
282
295
                msg->params.key.velocity = p2;
283
296
        }
 
297
 
 
298
        switch (msg->command) {
 
299
                case MIDI_NOTE_OFF:
 
300
                case MIDI_NOTE_ON:
 
301
                case MIDI_POLY_PRESS:
 
302
                case MIDI_CONTROL:
 
303
                case MIDI_PITCHWHEEL:
 
304
                        msg->params.bristol.msgLen = 3;
 
305
                        break;
 
306
                case MIDI_PROGRAM:
 
307
                case MIDI_CHAN_PRESS:
 
308
                        msg->params.bristol.msgLen = 2;
 
309
                        break;
 
310
        }
284
311
}
285
312
 
286
313
static int
334
361
                default:
335
362
                        break;
336
363
        }
 
364
 
337
365
        return(0);
338
366
}
339
367
 
374
402
                        (buff[index] & MIDI_STATUS_MASK))
375
403
                 */
376
404
                if (buff[index] & MIDI_STATUS_MASK)
377
 
                {
378
405
                        parseCommand(buff[index], dev);
379
 
                } else {
 
406
                else {
380
407
                        switch (bmidi.dev[dev].lastcommand)
381
408
                        {
382
409
                                /*
387
414
                                        buildOneMsg(buff[index], -1, dev, msg);
388
415
                                        return(parsed + 1);
389
416
                                /*
390
 
                                 * Looking for two more bytes, if there are there.
 
417
                                 * Looking for two more bytes, if they are there.
391
418
                                 */
392
419
                                case MIDI_NOTE_ON:
393
420
                                case MIDI_CONTROL:
408
435
                                         */
409
436
                                        if ((index + 1) == BRISTOL_MIDI_BUFSIZE)
410
437
                                        {
411
 
                                                if (buff[0] & MIDI_STATUS_MASK) {
 
438
                                                if (buff[0] & MIDI_STATUS_MASK)
412
439
                                                        break;
413
 
                                                } else
 
440
                                                else
414
441
                                                        buildOneMsg(buff[index], buff[0], dev, msg);
415
442
                                        } else {
416
 
                                                if (buff[index+1] & MIDI_STATUS_MASK) {
 
443
                                                if (buff[index+1] & MIDI_STATUS_MASK)
417
444
                                                        break;
418
 
                                                } else
 
445
                                                else
419
446
                                                        buildOneMsg(buff[index], buff[index+1], dev, msg);
420
447
                                        }
421
448
 
489
516
                 */
490
517
                if ((index+=1) > BRISTOL_MIDI_BUFSIZE)
491
518
                        index = 0;
 
519
 
492
520
                parsed++;
493
521
        }
 
522
 
494
523
        return(parsed);
495
524
}
496
525