home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / MADH Pascal 4.5 / Libraries & Interfaces / RDriver.p < prev    next >
Encoding:
Text File  |  1997-03-18  |  20.3 KB  |  552 lines  |  [TEXT/CWIE]

  1. {
  2. ********************                        ***********************
  3.  
  4.     Player PRO 4.5x -- MAD Music Driver Definition -
  5.  
  6.     Library Version 4.5
  7.  
  8.     To use with MADH Library for CodeWarrior
  9.  
  10.     Antoine ROSSET
  11.     16 Tranchees
  12.     1206 GENEVA
  13.     SWITZERLAND
  14.  
  15.     Thank you for your interest in PlayerPRO !
  16.  
  17.     FAX:            (+41 22) 346 11 97
  18.     PHONE:         (+41 79) 203 74 62
  19.     Internet: rosset@dial.eunet.ch
  20.  
  21.  
  22.     Ported to Pascal by Federico Filipponi (March 1997)
  23.     e-mail:    fedefil@fub.it
  24.                     fedefil@kagi.com
  25.     
  26.     Based on a previous work by Matthias Wuttke
  27.     e-mail: wuttke@stein.teuto.de
  28.                     matthias@kagi.com
  29.  
  30. ********************                        ***********************
  31. }
  32.  
  33. unit RDriver;
  34.  
  35. interface
  36.  
  37. {$ALIGN MAC68K}
  38.  
  39.     uses
  40.         Files, Retrace, Sound, Types, 
  41.         MAD;
  42.  
  43. {
  44. ********************                        ***********************
  45. ***                         Driver structure definition (constants)        ***
  46. ********************                        ***********************
  47. }
  48.     const
  49.         NUMBER_NOTES = 96;
  50.         NOFINETUNE = 8363;
  51.         MIN_VOLUME = 0;
  52.         MAX_VOLUME = 64;
  53.         MAXTRACK = 32;        
  54.         MAXINSTRU = 64;
  55.         MAXSAMPLE = 25;
  56.         MAXPATTERN = 200;
  57.         MAXPATTERNSIZE = 900;
  58.         MAX_ARP = 3;
  59.         MAXPLUG = 40;
  60.         
  61. {
  62. ********************                        ***********************
  63. ***                         Error messages                         ***
  64. ********************                        ***********************
  65. }
  66.         MADNeedMemory = -1;
  67.         MADReadingErr    = -2;
  68.         MADIncompatibleFile = -3;
  69.         MADLibraryNotInitialized = -4;
  70.         MADParametersErr = -5;
  71.         MADUnknowErr = -6;
  72.         MADSoundManagerErr = -7;
  73.         MADOrderNotImplemented = -8;
  74.         MADFileNotSupportedByThisPlug    = -9;
  75.         MADCannotFindPlug = -10;
  76.         
  77. {
  78. ********************                        ***********************
  79. ***                  Driver Settings definition    (constants)                ***
  80. ********************                        ***********************
  81. }
  82.         ASCSoundDriver = 1;                { MAC ONLY }
  83.         AWACSoundDriver = 2;            { MAC ONLY }
  84.         MIDISoundDriver = 3;            { MAC ONLY }
  85.         SoundManagerDriver = 4;        { MAC ONLY You should use only SoundManagerDriver for full compatibility ! }
  86.         QK25SoundDriver = 5;            { MAC ONLY }
  87.         DigiDesignSoundDriver = 6;{ MAC ONLY }
  88.         BeOSSoundDriver = 7;            { BE ONLY when using with BeOS compatible systems ! - NOT FOR MAC }
  89.         DirectSound95NT = 8;            { WINDOWS 95/NT ONLY when using with PC compatible systems ! - NOT FOR MAC }
  90.         Wave95NT = 9;                            { WINDOWS 95/NT ONLY when using with PC compatible systems ! - NOT FOR MAC }
  91.         NoHardwareDriver = 10;        { NO HARDWARE CONNECTION, will not produce any sound }
  92.  
  93.         MonoOutPut = 1;
  94.         StereoOutPut = 2;
  95.         DeluxeStereoOutPut = 3;
  96.         PolyPhonic = 4;                        { Do NOT use it ! Standard hardware doesn't support it ! }
  97.  
  98. {
  99. ********************                        ***********************
  100. ***                        EFFECTS ID                            ***
  101. ********************                        ***********************
  102. }
  103.         arpeggioE = 0;
  104.         downslideE = 1;
  105.         upslideE = 2;
  106.         portamentoE = 3;
  107.         vibratoE = 4;
  108.         portaslideE = 5;
  109.         vibratoslideE = 6;
  110.         nothingE = 7;
  111.         offsetE = 9;
  112.         slidevolE = 10;
  113.         fastskipE = 11;
  114.         volumeE = 12;
  115.         skipE = 13;
  116.         extendedE = 14;
  117.         speedE = 15;
  118.  
  119. {
  120. ********************                        ***********************
  121. ***                Channel structure definition                    ***
  122. ********************                        ***********************
  123. }
  124.     type
  125.         Channel = record
  126.             ID: LongInt;                    { Channel ID - 0 to 31 }
  127.  
  128.             begPtr: Ptr;                  { Sample Data Ptr - Beginning of data }
  129.             maxPtr: Ptr;                    { Sample Data Ptr - End of data }
  130.             curPtr: Ptr;                    { Sample Data Ptr - Current position }
  131.             sizePtr: LongInt;            { Sample Size in bytes }
  132.             
  133.             amp: LongInt;                    { Sample amplitude: 8 or 16 bits }
  134.             
  135.             loopBeg: LongInt;            { Loop Beginning }
  136.             loopSize: LongInt;        { Loop Size }
  137.             
  138.             ins: LongInt;                    { Current Instrument ID }
  139.             insOld: LongInt;            { Previous Instrument ID played on this channel }
  140.             samp: LongInt;                { Current Sample ID }
  141.             
  142.             fineTune: LongInt;        { Finetune }
  143.             
  144.             note: LongInt;                { Note }
  145.             noteOld: LongInt;            { Previous note played on this channel }
  146.             
  147.             period: LongInt;            { Current period }
  148.             periodOld: LongInt;        { Previous period played on this channel }
  149.             
  150.             vol: LongInt;                    { Channel vol (0 to 64) }
  151.             cmd: LongInt;                    { Command }
  152.             arg: Byte;                        { Argument of command }
  153.             volcmd: Byte;                    { Volume Command }
  154.             
  155.             arp: array [0..(MAX_ARP - 1)] of LongInt;        { Used for arpeggio command }
  156.             arpindex: LongInt;        { Used for arpeggio command }
  157.             
  158.             viboffset: LongInt;        { Used for vibrato command }
  159.             vibdepth: LongInt;        { Used for vibrato command }
  160.             vibrate: LongInt;            { Used for vibrato command }
  161.             
  162.             slide: LongInt;                { Used for slideUp and slideDown command }
  163.             
  164.             pitchgoal: LongInt;        { Used for portamento command }
  165.             pitchrate: LongInt;        { Used for portamento command }
  166.             
  167.             volumerate: LongInt;    { Used for slideVolume command }
  168.             
  169.             oldArg: array [0..15] of LongInt;
  170.  
  171.             samplePtr: Ptr;                { Used internaly by MADPlaySoundData & MADPlaySndHandle }
  172.             
  173.             {}
  174.             
  175.             KeyOn: Boolean;
  176.             a: Integer;
  177.             b: Integer;
  178.             p: Integer;
  179.             volEnv: LongInt;
  180.             volFade: LongInt;
  181.             
  182.             lAC: LongInt;
  183.             
  184.             prevPtr: Ptr;
  185.             lastWord, curLastWord: LongInt;
  186.             curLevel: LongInt;
  187.             
  188.             prevVol, curPrevVol: LongInt;
  189.             
  190.             {}
  191.             
  192.             GEffect: Boolean;
  193.             GPat, GReader: Integer;
  194.         end;
  195.     ChannelPtr = ^Channel;
  196.  
  197. {
  198. ********************                        ***********************
  199. ***         Music description - used in Import/Export filter    ***
  200. ********************                        ***********************
  201. }
  202.     MADPartition = record
  203.         header: MADSpecPtr;        { Music Header - See 'MAD.p' }
  204.         partition: array [0..(MAXPATTERN - 1)] of PatDataPtr;        { Patterns }
  205.         sample: array [0..(MAXINSTRU - 1), 0..(MAXSAMPLE - 1)] of sDataPtr;        { Instruments }    
  206.     end;
  207.     MADPartitionPtr = ^MADPartition;
  208.  
  209. {
  210. ********************                        ***********************
  211. ***                  Driver Settings definition                ***
  212. ********************                        ***********************
  213. }
  214.     MADDriverSettings = record
  215.         numChn: Integer;                                { Active tracks from 2 to 32, automatically setup when a new music is loaded }
  216.         outPutBits: Integer;                        { 8 or 16 Bits }
  217.         outPutRate: UnsignedLong;                { Fixed number, by example : rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz }
  218.         outPutMode: Integer;                        { MonoOutPut, StereoOutPut or DeluxeStereoOutPut ? }
  219.         driverMode: Integer;                        { ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver }
  220.         antiAliasing: Boolean;                    { Use AntiAliasing filter ? true/false }
  221.         repeatMusic: Boolean;                        { If music finished, repeat it or stop. }
  222.         sysMemory: Boolean;                            { Allocate memory in Application Heap (false) or in System Heap (true) }
  223.         Interpolation: Boolean;                    { Sound Interpolation active? true/false }
  224.         MicroDelay: Boolean;                        { Micro delay active? Used only in DeluxeStereoOutPut outPutMode. }
  225.         MicroDelaySize: LongInt;                { Micro delay duration (in ms, max 1 sec = 1000 ms) }
  226.         surround: Boolean;                            { Surround effect active? true/false }
  227.         Reverb: Boolean;                                { Reverb effect active? true/false }
  228.         ReverbSize: LongInt;                        { Reverb delay duration (in ms, min = 25 ms, max 1 sec = 1000 ms) }
  229.         ReverbStrength: LongInt;                { Reverb strength in % (0 <-> 70) }
  230.         TickRemover: Boolean;                        { Remove volume/sample/loop ticks. }
  231.     end;
  232.     MADDriverSettingsPtr = ^MADDriverSettings;
  233.  
  234. {
  235. ******************************************************************
  236. ******************* MUSICS IMPORT/EXPORT PLUGS  *****************
  237.  
  238.      Protocol Version 2.3
  239.  
  240.      To use with PlayerPRO for CodeWarrior
  241.  
  242.     Your main function have to be in this form:
  243.     OSErr main(     OSType order,
  244.                     Ptr AlienFileName,
  245.                     MADPartition *MadFile,
  246.                     PPInfoRec *info,
  247.                     MADDriverSettings *DriverParam);
  248.  
  249.     Actual plug have to support these orders:
  250.  
  251.     order: 'TEST':    check the AlienFile to see if your Plug really supports it.
  252.     order: 'IMPT':    convert the AlienFile into a MADPartition. You have to allocate MADPartition.
  253.     order: 'INFO':    Fill PPInfoRec structure.
  254.     order: 'EXPT':    Convert the MADPartition into AlienFile. You have to create the AlienFile.
  255.                     Don't delete the MADPartition Structure after conversion !!
  256.  
  257.     An IMPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO'
  258.     An EXPORT plug have to support these orders: 'EXPT'
  259.      An IMPORT/EXPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO', 'EXPT'
  260.  
  261.     About Resources:
  262.  
  263.     Your Plug should have: Creator: 'SNPL', Type: 'IMPL' - MAC ONLY
  264.  
  265.     Your Plug have to have these resources - MAC ONLY:
  266.  
  267.     - One segment CODE 1000 with 68k Code
  268.     - One segment PPCC 1000 with PPC Code (OPTIONAL: if PlayerPRO in PPC cannot find it, it will use the CODE 1000 resource)
  269.     - One STR# resource :
  270.  
  271.         1 string: which kind of files your plug support (OSType value!!! 4 char) By example: 'STrk', '669 ', etc...
  272.         2 string: what does your Plug: EXPL : only Export files, IMPL : only Import Files, EXIM : import AND export.
  273.         3 string: string that will be used in Import and Export menu of PlayerPRO
  274.         4 string: Copyright string of this plug.
  275.  
  276. ********************                        ***********************
  277. }
  278.     PPInfoRec = record
  279.         internalFileName: packed array [0..59] of Char;
  280.         formatDescription: packed array [0..59] of Char;
  281.         
  282.         totalPatterns: LongInt;
  283.         partitionLength: LongInt;
  284.         
  285.         totalTracks: Integer;
  286.         totalInstruments: Integer;
  287.         
  288.         signature: OSType;
  289.         
  290.         fileSize: LongInt;
  291.     end;
  292.     PPInfoRecPtr = ^PPInfoRec;
  293.  
  294. {
  295. ********************                        ***********************
  296. ***             Informations about Plugs: ThePlug[]                ***
  297. ********************                        ***********************
  298. }
  299.     PlugInfo = record
  300.         IOPlug: Handle;                                                { Plug CODE }
  301.         MenuName: Str63;                                            { Plug name }
  302.         AuthorString: Str63;                                    { Plug author }
  303.         theFile: FSSpec;                                            { Location of plug file }
  304.         theType: packed array [0..4] of Char;    { OSType of file support }
  305.         mode: OSType;                                                    { Mode support : Import +/ Export }
  306.         hasPPCCode: Boolean;                                    { Is Plug FAT? }
  307.     end;
  308.     PlugInfoPtr = ^PlugInfo;
  309.     
  310. {
  311. ********************                        ***********************
  312. ***         Global structure : PlayerPRO variables                ***
  313. ********************                        ***********************
  314. }
  315.     MADDriverRec = record
  316.         IDType: LongInt;                                                                        { IDType = 'MADD' -- READ ONLY -- }
  317. {
  318.         **********************
  319.         ** Public variables **
  320.         **********************
  321. }
  322.         DriverSettings: MADDriverSettings;                                    { Driver SetUp -- READ ONLY -- }
  323.  
  324.         {**  Current music in memory, loaded with RLoadMusic() by example **}
  325.  
  326.         header: MADSpecPtr;        { MAD Header  -- READ ONLY -- }
  327.         partition: array [0..(MAXPATTERN - 1)] of PatDataPtr;        { Patterns    -- READ ONLY -- }
  328.         sample: array [0..(MAXINSTRU - 1), 0..(MAXSAMPLE - 1)] of sDataPtr;        { Instruments -- READ ONLY -- }    
  329.         
  330.         {**  Drivers variables **}
  331.         
  332.         chan: array [0..(MAXTRACK - 1)] of Channel;                    { Current driver channels -- READ ONLY -- }
  333.         musicEnd: Boolean;                                                                    { Is music playing finished? -- READ ONLY -- }
  334.         Tube: array [0..(MAXTRACK - 1)] of Integer;                    { Used in 'Tracks View' Window - View menu  }
  335.         PartitionReader: Integer;                                                        { Current position in pattern (0...64) }
  336.         Pat: Integer;                                                                                { Current ID Pattern, see 'Patterns list' }
  337.         PL: Integer;                                                                                { Current position in partition, see 'Partition list' }
  338.         VolExt: array [0..(MAXTRACK - 1)] of Integer;                { was long! Volumes settings for each track, see 'Adaptators' window. from 0 to 64 }
  339.         VolGlobal: LongInt;                                                                    { Global SOFTWARE volume (This is NOT Mac hardware volume!) from 0 to 64 }
  340.         speed: Integer;                                                                            { Current speed, see speed Effect }
  341.         finespeed: Integer;                                                                    { Current finespeed, see speed Effect }
  342.         InstruTube: array [0..(MAXINSTRU - 1)] of Integer;    { Used in 'Instrument View' Window - View menu }
  343.         VExt: Integer;                                                                            { External music speed, see 'Adaptators' window. 80 = normal }
  344.         FreqExt: Integer;                                                                        { External music pitch, see 'Adaptators' window. 80 = normal }
  345.         Reading: Boolean;                                                                        { Reading indicator }
  346.         LeftRight: array [0..(MAXTRACK - 1)] of Integer;        { Left/Right % for Deluxe Driver }
  347.         MusicChannelPP: SndChannelPtr;                                            { MAC ONLY The SndChannelPtr to apply SndDoCommand, etc. }
  348.                                                                                                                 { ONLY available if you are using SoundManager driver }
  349.  
  350.         {** Plugs Import/Export variables **}
  351.  
  352.         ThePlug: PlugInfoPtr;                                                                { Pointer to Plugs code & infos }
  353.         TotalPlug: Integer;                                                                    { no. of Plugs in pointer ThePlug }
  354.  
  355.         {** Private variables - Not documented **}
  356.         {* DO NOT MODIFY OR USE these variables *}
  357.  
  358.         MIN_PITCH, MAX_PITCH: LongInt;
  359.         smallcounter, trackDiv: Integer;
  360.         FREQBASE: LongInt;
  361.         InstruActif: array [0..(MAXINSTRU - 1)] of Integer;
  362.         SysHeapPtr, Vol, IntDataPtr, OscilloWavePtr: Ptr;
  363.         JumpToNextPattern, endPattern, MADPlay: Boolean;
  364.         ASCBUFFER: LongInt;
  365.         BufSize: LongInt;
  366.         VSYNC, BufCounter, BytesToGenerate: LongInt;
  367.         vibrato_table: array [0..63] of Integer;
  368.         MIDIPortRefNum, gOutNodeRefNum: Integer;
  369.         InstuNoOld: array [0..(MAXTRACK - 1)] of Integer;
  370.         NoteOld: array [0..(MAXTRACK - 1)] of Integer;
  371.         VelocityOld: array [0..(MAXTRACK - 1)] of Integer;
  372.         TrackLineReading: array [0..(MAXTRACK - 1)] of Boolean;
  373.         OverShoot: Ptr;
  374.         DASCBuffer: LongIntPtr;
  375.         DASCBuffer8: IntegerPtr;
  376.         VBLA5: LongInt;
  377.         mytab: array [0..11] of LongInt;
  378.         MDelay: LongInt;
  379.         RDelay: LongInt;
  380.         ReverbPtr: Ptr;
  381.         TheHeader: SndDoubleBufferHeader;        { MAC ONLY }
  382.         pseudoChanAWAC: SndChannelPtr;            { MAC ONLY }
  383.         VBL: VBLTask;                                                { MAC ONLY }
  384.     end;
  385.     MADDriverRecPtr = ^MADDriverRec;
  386.  
  387.  
  388. {
  389. ******************************************************************
  390. ***************** MUSIC RESOURCE TYPE IDENTIFIER *****************
  391.  
  392.     The type MADResType is used instead of ResType in the 
  393.     MADLoadMusicRsrc function.
  394.     This because, when generating 68k code, the type ResType, which
  395.     corresponds to a PACKED ARRAY [1..4] OF CHAR, is ALWAYS passed
  396.     as a pointer (It's a C function, after all).
  397.     To have it passed the right way, it must be a 4-bytes long type,
  398.     like an UnsignedLong. When calling MADLoadMusicRsrc, the ResType 
  399.     parameter must be passed as MADResType, like in the following example:
  400.     
  401.     rsrcType := MADResType(rsrcType); (where rsrcType is of type ResType)
  402.     err := MADLoadMusicRsrc(rsrcType, 1);
  403.     
  404.     This affects 68k code only. When generating PPC code, ResType can
  405.     be used normally.
  406.  
  407. ******************************************************************
  408. }
  409. {$IFC GENERATING68K}
  410.     MADResType = UnsignedLong;
  411. {$ELSEC}
  412.     MADResType = ResType;
  413. {$ENDC}
  414.  
  415. {
  416. ******************************************************************
  417. ********************** PLUG TYPE IDENTIFIER **********************
  418.  
  419.     The type MADPlugTypePtr is used instead of OSTypePtr in many of 
  420.     the following functions (for compatibility with platforms other 
  421.     than the Mac OS).
  422.     The type conversion from OSType (4 bytes) to MADPlugType (5 bytes) 
  423.     is obtained with a call to the OSType2MADPlugType procedure (see 
  424.     the file Example.p for an example of its use).
  425.     As an alternative, you can obtain the plug type directly in the 
  426.     right format by calling, for example, the MADMusicIdentifyFSp 
  427.     function.
  428.  
  429. ******************************************************************
  430. }
  431. MADPlugType = packed array [0..4] of Char;
  432. MADPlugTypePtr = ^MADPlugType;
  433.  
  434. {
  435. ******************************************************************
  436. ***************                       FUNCTIONS                            ****************
  437. ******************************************************************
  438. }
  439.  
  440.     function MADGetMADDriverPtr: MADDriverRecPtr;        { Get MADDriver structure pointer. }
  441.     C; EXTERNAL;
  442.     
  443.     function MADInitLibrary(PlugsFolderName: CStringPtr; SysMemory: Boolean): OSErr;    { Library initialisation, you have to CALL this function if you want to use other functions & variables }
  444.      C; EXTERNAL;
  445.     function MADDisposeLibrary: OSErr;                            { Close Library, close music, close driver, free all memory }
  446.      C; EXTERNAL;
  447.  
  448.     procedure MADGetBestDriver(DriverInitParam: MADDriverSettingsPtr);    { Found and identify the current Mac sound hardware and fill DriverInitParam }
  449.      C; EXTERNAL;
  450.     function MADCreateDriver(DriverInitParam: MADDriverSettingsPtr): OSErr;        { Music Driver initialization and memory allocation }
  451.      C; EXTERNAL;
  452.     function MADDisposeDriver: OSErr;                                { Dispose the music driver, use it after RInitMusic() }
  453.      C; EXTERNAL;
  454.  
  455.     function MADStartDriver: OSErr;                                    { NEW - Activate the sound generating procedure (interruption) }
  456.      C; EXTERNAL;
  457.     function MADStopDriver: OSErr;                                    { NEW - DESActivate the sound generating procedure (interruption) }
  458.      C; EXTERNAL;
  459.  
  460.     function MADPlayMusic: OSErr;                                        { NEW - Read and play current music in memory - Call MADStartInterruption BEFORE }
  461.      C; EXTERNAL;
  462.     function MADStopMusic: OSErr;                                        { NEW - Stop reading current music in memory }
  463.      C; EXTERNAL;
  464.  
  465.     function MADReset: OSErr;                                                { Reset the current music at the start position }
  466.      C; EXTERNAL;
  467.     function MADGetMusicStatus(var fullTime, curTime: LongInt): OSErr;    { Get informations about music position and duration }
  468.      C; EXTERNAL;
  469.  
  470.     function MADSetHardwareVolume(theVol: LongInt): OSErr;        { 0...64, Mac HARDWARE volume, see MADDriver->VolGlobal for SOFTWARE volume }
  471.      C; EXTERNAL;
  472.     function MADGetHardwareVolume: LongInt;                                        { Return HARDWARE volume, see MADDriver->VolGlobal for SOFTWARE volume }
  473.      C; EXTERNAL;
  474.  
  475.     function MADLoadMusicRsrc(IDName: MADResType; IDNo: Integer): OSErr;    { Load a MAD Rsrc into memory }
  476.      C; EXTERNAL;
  477.     function MADLoadMusicPtr(myPtr: Ptr): OSErr;                            { Load a MAD Ptr into memory, you can DisposPtr your Ptr after this call }
  478.      C; EXTERNAL;
  479.     function MADLoadMusicPartition(aPartition: MADPartitionPtr): OSErr;        { Load a MAD partition into memory }
  480.      C; EXTERNAL;
  481.  
  482.     function MADLoadMusicFilePString(plugType: MADPlugTypePtr; fName: Str255): OSErr;            { Load a music file with plug }
  483.      C; EXTERNAL;
  484.     function MADLoadMusicFileCString(plugType: MADPlugTypePtr; fName: CStringPtr): OSErr;    { Load a music file with plug }
  485.      C; EXTERNAL;
  486.     function MADLoadMusicFSpFile(plugType: MADPlugTypePtr; theSpec: FSSpecPtr): OSErr;        { Load a music file with plug }
  487.      C; EXTERNAL;
  488.  
  489.     function MADMusicIdentifyPString(plugType: MADPlugTypePtr; pName: Str255): OSErr;            { Identify what kind of music format is pName file. }
  490.      C; EXTERNAL;
  491.     function MADMusicIdentifyCString(plugType: MADPlugTypePtr; cName: CStringPtr): OSErr;    { Identify what kind of music format is cName file. }
  492.      C; EXTERNAL;
  493.     function MADMusicIdentifyFSp(plugType: MADPlugTypePtr; theSpec: FSSpecPtr): OSErr;        { Same as above but with a FSSpec pointer }
  494.      C; EXTERNAL;
  495.  
  496.     function MADPlugAvailable(plugType: MADPlugTypePtr): Boolean;            { Is plug 'plugType' available? }
  497.      C; EXTERNAL;
  498.  
  499.     function MADDisposeMusic: OSErr;                                { Dispose the current music }
  500.      C; EXTERNAL;
  501.  
  502.     procedure    MADChangeTracks(i: Integer);                    { Change current tracks number of the music driver }
  503.      C; EXTERNAL;
  504.     procedure    MADCleanDriver(intDriver: MADDriverRecPtr);            { Clean the driver : stop playing sounds }
  505.      C; EXTERNAL;
  506.  
  507.     function GetMADCommand(    position: Integer;            { Extract a Command from a PatData structure }
  508.                                                     channel: Integer;
  509.                                                      aPatData: PatDataPtr): CmdPtr;
  510.      C; EXTERNAL;
  511.  
  512.     function MADPlaySndHandle(sound: Handle;                        { Handle to a 'snd ' handle, by ex: GetResource('snd ', 128); }
  513.                                                         chan: LongInt;                        { channel ID on which to play sound }
  514.                                                         note: LongInt): OSErr;        { note: 0 to NUMBER_NOTES or 0xFF: play sound at his normal sampleRate Khz }
  515.      C; EXTERNAL;
  516.  
  517.     function MADPlaySoundData(soundPtr: Ptr;                        { Sound Pointer to data }
  518.                                                         size: LongInt;                        { Sound size in bytes }
  519.                                                         channel: LongInt;                    { channel ID on which to play sound }
  520.                                                         note: LongInt;                        { note: 0 to NUMBER_NOTES or 0xFF: play sound at 22 Khz }
  521.                                                         amplitude: LongInt;                { 8 or 16 bits }
  522.                                                         loopBeg: LongInt;                    { loop beginning }
  523.                                                         loopSize: LongInt;                { loop size in bytes }
  524.                                                         rate: UnsignedLong): OSErr;        { sample rate of the sound data, by ex: rate22khz }
  525.      C; EXTERNAL;
  526.  
  527.     function MADPlaySoundDataSYNC(soundPtr: Ptr;                { Sound Pointer to data }
  528.                                                                 size: LongInt;                { Sound size in bytes }
  529.                                                                 channel: LongInt;            { channel ID on which to play sound }
  530.                                                                 note: LongInt;                { note: 0 to NUMBER_NOTES or 0xFF: play sound at 22 Khz }
  531.                                                                 amplitude: LongInt;        { 8 or 16 bits }
  532.                                                                 loopBeg: LongInt;            { loop beginning }
  533.                                                                 loopSize: LongInt;        { loop size in bytes }
  534.                                                                 rate: UnsignedLong): OSErr;{ sample rate of the sound data, by ex: rate22khz }
  535.      C; EXTERNAL;
  536.  
  537.     procedure OSType2MADPlugType(theType: OSType; var thePlug: MADPlugType);
  538.  
  539. implementation
  540.     
  541. {    Used to convert from OSType (4 bytes) to MADPlugType (5 bytes) }
  542.     procedure OSType2MADPlugType(theType: OSType; var thePlug: MADPlugType);
  543.         type
  544.             UnsignedLongPtr = ^UnsignedLong;
  545.     begin
  546.         UnsignedLongPtr(@thePlug)^ := UnsignedLongPtr(@theType)^;
  547.         thePlug[4] := Char(0);
  548.     end;
  549.  
  550. {$ALIGN RESET}
  551.  
  552. end.