home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
-
- Author: Fred Cassirer
- Date: January 24, 1987
-
- This program is placed in the public domain, and from what I understand
- that means anyone can do whatever they want with it. That's fine
- because they are fairly trivial anyway ... If you can get someone to pay
- you for them, you must be doing something right.
-
- ****************************************************************************/
- #include "stdio.h"
- #include "exec/types.h"
- #include "libraries/dos.h"
- #include "midi.h"
-
- extern int getmidi();
- extern void initmidi();
- extern void cleanup();
-
- /*
- Return time in ticks since last call. For the 1st call the result is
- undefined.
- */
-
- ULONG duration()
- {
- struct DateStamp dstmp;
- ULONG curticks,retval;
-
- static ULONG lastics;
-
- DateStamp(&dstmp);
-
- curticks = dstmp.ds_Tick + dstmp . ds_Minute * 60 * TICKS_PER_SECOND;
- retval = curticks - lastics;
- lastics = curticks;
- return(retval); /* 60th's of a second */
-
- }
-
- main()
- {
-
- int i=0;
- int midi_status,midi_note,midi_velocity;
- int midi_sysdata,midi_parmno,midi_setting;
-
- initmidi();
-
- GETMIDI(midi_status);
- duration(); /* Toss the 1st duration to the wind */
-
- for(;;) {
-
- switch (midi_status & 0xff0) {
-
- case NON_MIDI_EVENT:
- cleanup();
- exit(FALSE);
-
- case NOTE_OFF :
- case NOTE_ON :
- GETMIDI(midi_note);
- do {
- GETMIDI(midi_velocity);
- printf("%02x %04lx %02x %02x %02x ",TIMETAG
- ,duration()
- ,midi_status
- ,midi_note
- ,midi_velocity);
-
- i += 5;
- GETMIDI(midi_note);
- if ((i % 20) == 0) printf("\n");
- } while (!(midi_note & 0x80));
-
- midi_status = midi_note;
- break;
-
- case PITCHWHEEL:
- case PARAMETER:
-
- printf("%02x %04lx %02x ",TIMETAG,duration(),midi_status);
- i += 3; if ((i%20) == 0) printf("\n");
-
- GETMIDI(midi_parmno);
- do {
-
- GETMIDI(midi_setting);
- printf("%02x %02x ",midi_parmno,midi_setting);
- i += 2;
-
- GETMIDI(midi_parmno);
- if ((i % 20) == 0) printf("\n");
-
- } while (!(midi_parmno & 0x80));
-
- midi_status = midi_parmno;
- break;
-
- case SYSTEM_EXCLUSIVE:
-
- switch (midi_status) {
-
- case SYSTEM_EXCLUSIVE: /* Remember we masked off low nibble */
-
- printf("%02x %04lx %02x ",TIMETAG,duration(),midi_status);
- i += 3; if ((i%20) == 0) printf("\n");
-
- do {
- GETMIDI(midi_sysdata);
- printf("%02x ",midi_sysdata);
- } while ( (midi_sysdata != EOX) &&
- (midi_sysdata != ACTIVE_SENSING));
-
- default: GETMIDI(midi_status);
- break;
-
- } /* end inner switch */
-
- break;
-
- case PROGRAM: /* These two are followed by a single data byte */
- case CHANNEL_PRESSURE:
-
- case KEY_PRESSURE: /* Whereas this is followed by two. MIDI_DATA next
- time around will pick up the slack. */
-
- printf("%02x %04lx %02x ",TIMETAG,duration(),midi_status);
- i += 3; if ((i%20) == 0) printf("\n");
-
- GETMIDI(midi_sysdata);
- printf("%02x ",midi_sysdata);
- GETMIDI(midi_status);
- break;
-
- case MIDI_DATA: /* Data bytes for any of the above */
- default:
- printf("%02x ",midi_status);
-
- GETMIDI(midi_status);
- break;
-
- }
-
- }
-
- }
-
-