home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / mplayer.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-06  |  10KB  |  252 lines

  1. {*      MPLAYER.PAS
  2.  *
  3.  * Module Player definitions
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. *}
  13.  
  14.  
  15. unit MPlayer;
  16.  
  17.  
  18. interface
  19.  
  20.  
  21. const
  22.     MPHDRSIZE = 1084;                   { header size needed for
  23.                                           ModulePlayer.Identify() }
  24.  
  25. {****************************************************************************\
  26. *       enum mpStatus
  27. *       -------------
  28. * Description:  Module Player status
  29. \****************************************************************************}
  30.  
  31. const
  32.     mpUnInitialized = 0;
  33.     mpInitialized = 1;
  34.     mpPlaying = 2;
  35.     mpStopped = 3;
  36.  
  37.  
  38.  
  39. {****************************************************************************\
  40. *       enum modIDNumbers
  41. *       -----------------
  42. * Description:  mpModule ID numbers
  43. \****************************************************************************}
  44.  
  45. const
  46.     idS3M = 0;                          { Scream Tracker 3 module }
  47.     idMOD = 1;                          { Protracker module }
  48.  
  49.  
  50.  
  51. {****************************************************************************\
  52. *       struct mpChanInfo
  53. *       -----------------
  54. * Description:  Module Player data structure for dump.
  55. \****************************************************************************}
  56.  
  57. type
  58.     mpChanInfo = Record
  59.         flags : byte;                   { bits 0-4 - UNDEFINED
  60.                                           bit 5 - new note and/or instrument
  61.                                           bit 6 - new volume (S3M)
  62.                                           bit 7 - command }
  63.         note : byte;                    { note number }
  64.         instrument : byte;              { instrument number }
  65.         volume : byte;                  { playing volume }
  66.         command : char;                 { command number }
  67.         infobyte : byte;                { command infobyte }
  68.         volumebar : byte;               { "fake" volume bar }
  69.         commandname : pointer;          { Pointer to command name string,
  70.                                           ASCIIZ }
  71.     end;
  72.  
  73.     PmpChanInfo = ^mpChanInfo;
  74.     mpChanInfoArray = array[0..31] of mpChanInfo;
  75.     PmpChanInfoArray = ^mpChanInfoArray;
  76.  
  77.  
  78.  
  79.  
  80. {****************************************************************************\
  81. *       struct mpInformation
  82. *       --------------------
  83. * Description:  Module Player information structure.
  84. \****************************************************************************}
  85.  
  86. type
  87.     mpInformation = Record
  88.         numChannels : word;             { number of channels. MUST be set by
  89.                                           the routine calling
  90.                                           MP^.GetInformation() }
  91.         setFrame : word;                { 1 if "set frame", 0 if not }
  92.         speed : word;                   { playing speed }
  93.         BPM : word;                     { playing BPM tempo }
  94.         pos : word;                     { current playing position }
  95.         pattern : word;                 { current pattern number }
  96.         row : word;                     { current row number }
  97.         loopCnt : word;                 { song loop counter }
  98.         chans : PmpChanInfoArray;       { pointer to channel data structures.
  99.                                           MUST be allocated by the routine
  100.                                           calling MP->GetInformation() }
  101.     end;
  102.  
  103.     PmpInformation = ^mpInformation;
  104.  
  105.  
  106.  
  107.  
  108. {****************************************************************************\
  109. *       struct mpInstrument
  110. *       -------------------
  111. * Description:  Module Player instrument structure in memory
  112. \****************************************************************************}
  113.  
  114. type
  115.     mpInstrument = Record
  116.         fileName : array[0..12] of char; { DOS file name, ASCIIZ }
  117.         iname : array[0..31] of char;   { instrument name, ASCIIZ }
  118.         sample : pointer;               { pointer to sample data or NULL
  119.                                           if not available (no sample /
  120.                                           deallocated) }
  121.         length : word;                  { sample length }
  122.         loopStart : word;               { sample loop start }
  123.         loopEnd : word;                 { sample loop end }
  124.         looping : byte;                 { 1 if looping sample, 0 if not }
  125.         volume : byte;                  { sample default playing volume }
  126.         c2Rate : longint;               { C2 sampling rate }
  127.         finetune : byte;                { Sample default finetune value }
  128.         sdInstHandle : word;            { Sound Device instrument handle for
  129.                                           this instrument or 0 if not added
  130.                                           to Sound Device instrument list }
  131.     end;
  132.  
  133.     PmpInstrument = ^mpInstrument;
  134.  
  135.  
  136.  
  137.  
  138. {****************************************************************************\
  139. *       struct mpPattern
  140. *       ----------------
  141. * Description:  Module Player pattern structure in memory
  142. \****************************************************************************}
  143.  
  144. type
  145.     mpPattern = Record
  146.         length : word;                  { pattern data length in bytes }
  147.         data : array [0..0] of byte;    { actual pattern data }
  148.     end;
  149.  
  150.     PmpPattern = ^mpPattern;
  151.  
  152.  
  153.  
  154.  
  155. type
  156.     byteArray = array [0..8192] of byte;
  157.     PmpPatternArray = array [0..8192] of PmpPattern;
  158.     mpInstrumentArray = array [0..256] of mpInstrument;
  159.  
  160.  
  161. {****************************************************************************\
  162. *       struct mpModule
  163. *       ---------------
  164. * Description:  General Module structure. See MPLAYER.TXT for documentation
  165. \****************************************************************************}
  166.  
  167. type
  168.     mpModule = Record
  169.         ID : array [0..3] of char;      { Module identifier }
  170.         IDnum : word;                   { ID number (0=S3M, 1=MOD) }
  171.         songName : array [0..31] of char; { song name, ASCIIZ }
  172.         songLength : word;              { number of orders }
  173.         numInsts : word;                { number of instruments }
  174.         numPatts : word;                { number of patterns }
  175.         numChans : word;                { number of channels }
  176.         flags : word;                   { S3M player flags }
  177.         masterVol : byte;               { master volume }
  178.         speed : byte;                   { initial speed }
  179.         tempo : byte;                   { initial BPM tempo }
  180.         masterMult : byte;              { master multiplier }
  181.         stereo : byte;                  { 1 = stereo, 0 = mono }
  182.         chanSettings : array [0..31] of byte; { channel settings for 32 chns }
  183.         orders : ^byteArray;            { pointer to pattern orders }
  184.         insts : ^mpInstrumentArray;     { pointer to instrument datas }
  185.         patterns : ^PmpPatternArray;    { pointer to array of pattern
  186.                                           pointers }
  187.         pattEMS : ^byteArray;           { one byte for each pattern - 1 if
  188.                                           pattern in EMS, 0 if not }
  189.         instsUsed : ^byteArray;         { one byte for each instrument - 1 if
  190.                                           instrument is used, 0 if not }
  191.     end;
  192.  
  193.     PmpModule = ^mpModule;
  194.  
  195.  
  196.  
  197.  
  198. {****************************************************************************\
  199. *       struct ModulePlayer
  200. *       -------------------
  201. * Description:  Module Player structure. See MPLAYER.TXT for documentation
  202. \****************************************************************************}
  203.  
  204. type
  205.     Pinteger = ^integer;
  206.     Pword = ^word;
  207.     Pchar = ^char;
  208.     PPmpModule = ^PmpModule;
  209.  
  210.     mpIdentify = function(header : pointer; recognized : Pinteger) : integer;
  211.     mpInit = function(SD : pointer) : integer;
  212.     mpClose = function : integer;
  213.     mpLoadModule = function(fileName : Pchar; SD : pointer;
  214.         module : PPmpModule) : integer;
  215.     mpFreeModule = function(module : PmpModule; SD : pointer) : integer;
  216.     mpPlayModule = function(module : PmpModule; firstSDChannel, numChannels,
  217.         loopStart, loopEnd : word) : integer;
  218.     mpStopModule = function : integer;
  219.     mpSetInterrupt = function : integer;
  220.     mpRemoveInterrupt = function : integer;
  221.     mpPlay = function : integer;
  222.     mpSetPosition = function(pos : word) : integer;
  223.     mpGetInformation = function(info : PmpInformation) : integer;
  224.     mpSetMasterVolume = function(volume : byte) : integer;
  225.  
  226.     ModulePlayer = Record
  227.         Status : word;
  228.         UpdRate : word;
  229.  
  230.         Identify : mpIdentify;
  231.         Init : mpInit;
  232.         Close : mpClose;
  233.         LoadModule : mpLoadModule;
  234.         FreeModule : mpFreeModule;
  235.         PlayModule : mpPlayModule;
  236.         StopModule : mpStopModule;
  237.         SetInterrupt : mpSetInterrupt;
  238.         RemoveInterrupt : mpRemoveInterrupt;
  239.         Play : mpPlay;
  240.         SetPosition : mpSetPosition;
  241.         GetInformation : mpGetInformation;
  242.         SetMasterVolume : mpSetMasterVolume;
  243.     end;
  244.  
  245.     PModulePlayer = ^ModulePlayer;
  246.  
  247.  
  248. implementation
  249.  
  250.  
  251. END.
  252.