home *** CD-ROM | disk | FTP | other *** search
- /*====================== A MIDI SHARE TOOL (© GRAME 92) =====================
-
- NAME
- MidiClock -- a very simple MidiShare MPW tool
-
- SYNOPSIS
- MidiClock [-delay <d>]
- User type <q/Q> to quit
-
- DESCRIPTION
- "SendNote" open a MidiShare session, create and send a single note, and
- then close the MidiShare session
-
- ===============================================================================*/
-
-
- #include <String.h>
- #include <StdLib.h>
- #include <Stdio.h>
- #include <MidiShare.h>
-
-
- #define nil 0
- #define true 1
- #define false 0
-
-
- //_______________________________________________________________________
- long lopt (char *argv[], char *name, long def)
- {
- int i;
- for (i=0; argv[i]; i++) if (!strcmp(argv[i], name)) return atoi(argv[i+1]);
- return def;
- }
-
-
- //_______________________________________________________________________
-
- void wait(long d)
- { d += MidiGetTime();
- while (MidiGetTime() < d);
- }
-
-
- //_______________________________________________________________________
-
- pascal void Clocker (long date, short refNum, long delay, long a2, long a3)
- {
- MidiSendIm (refNum, MidiNewEv(typeClock));
- MidiCall (Clocker, date+delay, refNum, delay, a2, a3);
- }
-
- //_______________________________________________________________________
-
- main( int /*argc*/, char *argv[])
- {
- short ref;
- char c;
-
- ref = MidiOpen("\pMidiClock"); // open a MidiShare session
- MidiConnect(ref, 0, true); // connect to physical Midi outputs
- Clocker(MidiGetTime(), ref, lopt(argv, "-delay", 1), 0, 0);
-
- while ((c = getchar()) && c != 'q' && c != 'Q'); // wait user press Q or q
-
- MidiClose (ref); // close the MidiShare session
- }
-
-