home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / sndpas.zip / PMANCVT.PAS < prev    next >
Pascal/Delphi Source File  |  1990-06-17  |  2KB  |  51 lines

  1. {Convert PianoMan tunes (*.MUZ files) to interrupt music format}
  2.  
  3. program PManCvt;
  4.  
  5. type
  6.   FiledNote = RECORD            {format of PianoMan note records}
  7.                 O,NS:  BYTE;
  8.                 D:  WORD;
  9.               end;
  10.  
  11. const
  12.   NoteName:  array[0..15] of STRING[2] = (    {note number to name conv.}
  13.   '00','CN','CS','DN','DS','EN','FN','FS',
  14.   'GN','GS','AN','AS','BN','00','00','00' );
  15.  
  16. var
  17.   filenm:  STRING;            {name of input file}
  18.   fp1:  FILE of FiledNote;        {input file}
  19.   fp2:  TEXT;                {output file}
  20.   Note:  FiledNote;            {current note record}
  21.   ArraySize,                {size of source file}
  22.   DurDiv,                {note duration divisor}
  23.   i:  WORD;
  24.  
  25. begin
  26.   WriteLn('PianoMan .MUZ file to SoundPas data array converter');
  27.   WriteLn;
  28.   Write('Enter name of file to convert:  ');
  29.   ReadLn(filenm);                {get input file name}
  30.   Write('Enter duration divisor:  ');
  31.   ReadLn(DurDiv);
  32.   Assign(fp1,filenm);                {open PianoMan file}
  33.   Reset(fp1);
  34.   ArraySize := FileSize(fp1);            {set size of data array}
  35.   Assign(fp2,'pman.dat');
  36.   ReWrite(fp2);                    {open output file}
  37.   Seek(fp1,9);                    {skip file header}
  38.   WriteLn(fp2,'pman:  array[1..',(ArraySize-9)*2+1,'] of BYTE = (');
  39.   for i := 9 to ArraySize - 1 do begin        {now convert each record}
  40.     Read(fp1,Note);
  41.     if Note.NS and $F0 = 13*16 then        {if rest...}
  42.       Write(fp2,Note.D div DurDiv,',000,')
  43.     else                    {else, if note...}
  44.       Write(fp2,Note.D div DurDiv,',',NoteName[Note.NS shr 4],Note.O,',');
  45.     if i mod 8 = 0 then WriteLn(fp2);        {include newlines}
  46.   end;
  47.   WriteLn(fp2,'0 );');                {end the array}
  48.   Close(fp1);
  49.   Close(fp2);
  50. end.
  51.