home *** CD-ROM | disk | FTP | other *** search
- -----------------------------------------------------------------------------
-
- MLIB.PAS - Pascal implementation of Play/R interface
-
- -----------------------------------------------------------------------------
- Copyright 1992, Kevin Weiner, All rights reserved
-
- Proprietary material - not for distribution
- -----------------------------------------------------------------------------
-
-
- The unit mlib.pas implements most of the Play/R API functions. Simply
- include mlib in your program's uses clause. See API.DOC for further
- information on the API functions, which in most cases have a one-to-one
- correspondence with the Pascal versions. API.DOC also includes other
- important information on the driver, plus distribution licensing terms.
-
-
-
- ----------------------- Global variables defined ---------------------------
-
- MidiDriverLoaded: boolean; {true if driver is loaded, else false}
-
- MID: integer; {Default device id number}
-
-
- ----------------------------- Initialization -------------------------------
-
- The mlib unit automatically tests for the presence of the driver
- and does other initialization. It defines the global variables
- MidiDriverLoaded and MID.
-
-
- ------------------------ MIDI file functions -------------------------------
-
- procedure mfPause;
-
- Pauses MIDI file play.
-
-
- procedure mfContinue;
-
- Continues play after pausing.
-
-
- procedure mfPopup;
-
- Causes pop up window to appear. (Play/R)
-
-
- procedure mfRewind;
-
- Rewind to beginning of song and pause.
-
-
- function mfPlay(name: string): integer;
-
- Load specified song and start play.
- Return value = load status:
- 0 = File loaded successfully
- 1 = File not found
- 2 = Not MIDI file format
- 3 = Unexpected end of file
- 4 = Format not supported
- 5 = Track not found
- 6 = I/O error reading file
- 7 = Not enough memory
- 8 = Unsupported time base
- 255 = Nothing loaded
-
-
- procedure mfSongStat(var playing, done: boolean; var position: longint;
- var songcount, cursong: byte);
-
- Gets song status:
- playing = true if play in progress, false if paused
- done = true if at end of song, else false
- position = song position in milliseconds
- songcount = size of play list, 0 if none
- cursong = current song number in play list
-
-
- procedure mfFileStat(var stat: byte; var name: string);
-
- Gets file load status (see mfPlay) and current file name.
-
-
- function mfLoad(name: string): integer;
-
- Load file but do not begin play.
- Return value = load status (see mfPlay).
-
-
- procedure mfQuiet;
-
- Stops all sounding notes.
-
-
- procedure mfPopEnable(stat: boolean);
-
- Enable (stat=true) or disable (stat=false) user initiated pop up.
- (Play/R only)
-
-
- procedure mfVolume(adjust: integer);
-
- Adjust song volume +/- 128 velocity units from initial value.
-
-
- procedure mfTimeMode(mode: integer);
-
- Set timer stepping mode (1-3). See "Timing Considerations" in the
- file API.DOC for further info.
-
-
- procedure mfGetChan(datatype: integer; var chan: channels);
-
- Get channel attributes. Returns an array of 16 channel (channels
- type is defined as an array of bytes) 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 (if greater
- than 127, subtract 256 to get signed value;
- when setting, use lo() to get low order byte of
- signed integer).
-
- Note: chan_map, chan_ena, and chan_xpos are predefined constants.
-
-
- procedure mfSetChan(datatype: integer; chan: channels);
-
- Set channel attributes according to the specified array
- (chan) and attribute type (datatype). See mfGetChan.
-
-
- procedure mfSetPos(time: longint);
-
- Set song position to specified time in milliseconds. If time is
- negative, skip forward abs(time) milliseconds.
-
-
- procedure mfSkipSong(n: byte);
-
- Skip to song n in play list. If beyond end of list, skip to 1.
-
-
- procedure mfLoopMode(n: byte);
-
- Set song looping mode: 0 = no looping
- 1 = loop current song
- 2 = loop play list (startup default)
-
-
- ---------------------- General MIDI functions ----------------------------
-
- function midiDevName(dev: integer; var devname: string;
- var devdesc: string): integer;
-
- 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.
-
-
- procedure midiReset(dev: integer);
-
- Resets device to UART status.
-
-
- procedure midiPutBuffer(dev: integer; bufptr: pointer; len: word);
-
- Writes a buffer pointed to by bufptr 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).
-
-
- procedure midiPutBuffer1(dev: integer; bufptr: pointer; len: word);
-
- 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.
-
-
- procedure midiGetBuffer(dev: integer; bufptr: pointer; max: word;
- var recv: word);
-
- Returns up to max bytes to buffer pointed to by bufptr from device
- dev. Function return value is number of bytes actually transferred.
-
-
- procedure midiPutByte(dev, data: integer);
-
- Write a single MIDI data byte. MIDI file play should be suspended
- while using this routine.
-
-
- function midiInputReady(dev: integer): boolean;
-
- Test for input data waiting. Function returns true if data waiting,
- else false.
-
-
- procedure midiGetByte(dev: integer; var data: integer);
-
- Read a single MIDI byte. Returns -1 if no data arrives
- within 200 ms. Use with midiInputReady for best results.
-
-
- procedure midiClearInput(dev: integer);
-
- Clear all unread data from device.
-
- procedure midiGetMessage(dev: integer; var msg: messages;
- var chan, data1, data2: byte);
-
- Get a full MIDI message from specified device, returning message
- class (enumerated type "messages" - see MIDI.INC), channel, and two
- data bytes (one or both may be unused).
-
-
- procedurel midiResend(dev: integer);
-
- Resend data just read by midiGetMessage;
-
- procedure midiPutMessage(dev: integer; msg: messages;
- chan, data1, data2: byte);
-
- Send a full MIDI message using specified device, message type (see
- MIDI.INC), channel (0-based), and up to two data bytes.
-
-
- ---------------------------- Misc. functions ----------------------------
-
- function msTimer: longint;
-
- Return reference time in milliseconds.
-
-
- procedure midiRemove;
-
- Removes driver from memory if possible to do so.
-
- =========
-