home *** CD-ROM | disk | FTP | other *** search
- -----------------------------------------------------------------------------
-
- MLIB.C - C implementation of Play/R interface
-
- -----------------------------------------------------------------------------
- Copyright 1992, Kevin Weiner, All rights reserved
-
- Proprietary material - not for distribution
- -----------------------------------------------------------------------------
-
-
- The module mlib.c implements most of the Play/R API functions. Simply
- compile mlib, include mlib.h in your program, and link it with mlib.obj.
- See API.DOC for further information on the API functions, which in most
- cases have a one-to-one correspondence with the C versions. API.DOC also
- includes other important information on the driver, plus distribution
- licensing terms.
-
-
- ----------------------- Global variables defined ---------------------------
-
- char MidiDriverLoaded; /* 1 if driver is loaded, else 0 */
-
- int MID; /* Default device id */
-
-
- ---------------------- Initialization function -----------------------------
-
- char midiInit()
-
- Tests for presence of driver and does other initialization.
- Defines global variables MidiDriverLoaded and MID. Must be
- first mlib routine called. Returns 1 if successful, else 0.
-
-
- ------------------------ MIDI file functions -------------------------------
-
- void mfPause()
-
- Pauses MIDI file play.
-
-
- void mfContinue()
-
- Continues play after pausing.
-
-
- void mfPopup()
-
- Causes pop up window to appear. (Play/R)
-
-
- void mfRewind()
-
- Rewind to beginning of song and pause.
-
-
- byte mfPlay(char *name)
-
- Load specified song and start play.
- Return value = load status (see API function 6).
-
-
- void mfSongStat(char *playing, char *done, long *position,
- byte *songcount, byte *cursong)
-
- Gets song status:
- playing = 1 if play in progress, 0 if paused
- done = 1 if at end of song, else 0
- position = song position in milliseconds
- songcount = size of play list, 0 if none
- cursong = current song number in play list
-
-
- void mfFileStat(byte *stat, char *name)
-
- Gets file load status (see API function 6) and current file name.
-
-
- byte mfLoad(char *name)
-
- Load file but do not begin play.
- Return value = load status (see API function 6).
-
-
- void mfQuiet()
-
- Stops all sounding notes.
-
-
- void mfPopEnable(char stat)
-
- Enable (stat=1) or disable (stat=0) user initiated pop up.
- (Play/R only)
-
-
- void mfVolume(int adjust)
-
- Adjust song volume +/- 128 velocity units from initial value.
-
-
- void mfTimeMode(byte mode)
-
- Set timer stepping mode (1-3).
-
-
- void mfGetChan(int datatype, channels *chan)
-
- Get channel attributes. Returns an array of 16 one-byte channel
- attributes, their meaning depending on the value of datatype:
-
- "datatype" "chan" array contents
- -------------- --------------------------------------------
- 0 (chan_map) Output channel map - values from 0 to 15
-
- 1 (chan_ena) Channel enable flag - 1=enable, 0=disable
-
- 2 (chan_xpos) Channel transpose - 8-bit 2's comp (signed char)
-
-
- void mfSetChan(int datatype, channels *chan)
-
- Set channel attributes according to the specified byte array
- (chan) and attribute type (datatype). See mfGetChan.
-
-
- void mfSetPos(long time);
-
- Set song position to specified time in milliseconds.
-
-
- void mfSkipSong(byte n);
-
- Skip to song n in play list. If beyond end of list, skip to 1.
-
-
- void mfLoopMode(byte n);
-
- Set song looping mode: 0 = no looping
- 1 = loop current song
- 2 = loop play list (startup default)
-
-
- ---------------------- General MIDI functions ----------------------------
-
- int midiDevName(int dev, char *devname, char *devdesc)
-
- Gets 3-letter device designation and 20-character description
- for specified device number (starting at 1). Returns non-zero
- if device exists, else 0 if no more devices.
-
-
- void midiReset(int dev)
-
- Resets device to UART status.
-
-
- void midiPutBuffer(int dev, char *buf, unsigned int len)
-
- Writes a buffer (buf) of len bytes to device dev. May be used
- while MIDI file play is in progress (although play will be
- suspended until all the data is sent).
-
-
- void midiPutBuffer1(int dev, char *buf, unsigned int len)
-
- Same as midiPutBuffer, but uses direct calls to the output driver.
- This is more efficient for shorter messages, but MIDI file play must
- be stopped first using mfPause.
-
-
- word midiGetBuffer(int dev, char *buf, word max)
-
- Returns up to max bytes to buf from device dev. Function return
- value is number of bytes actually transferred.
-
-
- void far pascal midiPutByte(int dev, int data)
-
- Write a single MIDI data byte. MIDI file play should be suspended
- while using this routine.
-
-
- void far pascal midiInputReady(int dev)
-
- Test for input data waiting. Function returns 1 if data waiting, else 0.
-
-
- void far pascal midiGetByte(int dev, int far *data)
-
- Read a single MIDI byte. Function returns -1 if no data arrives
- within 200 ms. Use with midiInputReady for best results.
-
-
- void far pascal midiClearInput(int dev)
-
- Clear all unread data from device.
-
-
- void far pascal midiGetMessage ( int dev, messages far *msg, byte far *chan,
- byte far *data1, byte far *data2)
-
- Get a full MIDI message from specified device, returning message
- ordinal (enum type "messages" - see MLIB.H), channel, and two
- data bytes (one or both may be unused).
-
-
- void far pascal midiResend ( int dev )
-
- Resend data just read by midiGetMessage;
-
-
- void far pascal midiPutMessage ( int dev, messages msg, byte chan,
- byte data1, byte data2)
-
- Send a full MIDI message using specified device, message ordinal,
- channel, and two data bytes.
-
-
-
- ---------------------------- Misc. functions ----------------------------
-
- long far pascal msTimer()
-
- Return reference time in milliseconds.
-
-
- void midiRemove()
-
- Removes driver from memory if possible to do so.
-