home *** CD-ROM | disk | FTP | other *** search
/ Kids Cube / 2_Music.iso / mel / plarray.pas < prev    next >
Pascal/Delphi Source File  |  1992-07-27  |  2KB  |  84 lines

  1. {
  2.   PLARRAY.PAS unit, Copyright 1990,91 by A.A.Efros.
  3.   This unit is a part of MELODY MASTER v2.1 Programmer Support Files.
  4.   It is used to play music in Turbo Pascal 4.0 and up. The music is
  5.   generated using MELODY MASTER's output to "TP array".
  6.  
  7.   INSTRUCTIONS:
  8.     1. Run MELODY MASTER main program (MM.EXE or MMCGA.EXE).
  9.     2. Load (F3) the melody you want.
  10.     3. Output (F7) the melody choosing "TP array" option.
  11.     4. Exit MELODY MASTER (Alt-X).
  12.     5. Edit this file so the include statement {$I ...} will have
  13.        the name of your music file.
  14.     6. Include PLARRAY unit in the "uses" section of YOUR program.
  15.     7. When you want the music to be played, call PlayArray procedure
  16.        with one of parameters: Legato1, Legato2, Normal, or Staccato.
  17.        This would determine the style the music will be played in.
  18.  
  19.   SAMPLE PROGRAM:
  20.  
  21.     program Sample;
  22.     uses
  23.        Your_units, PlArray;
  24.     . . .
  25.     begin
  26.       . . .
  27.       PlayArray(Staccato);
  28.       . . .
  29.     end.
  30. }
  31.  
  32. unit PlArray;
  33.  
  34. INTERFACE
  35.  
  36. uses crt;
  37. type
  38.   StyleType = (Legato1, Legato2, Normal, Staccato);
  39.  
  40. procedure PlayArray(Style : StyleType);
  41.  
  42. IMPLEMENTATION
  43.  
  44. {$I FILENAME.PAS} { <--- Put the file name of your music here! }
  45.  
  46. procedure PlayArray(Style : StyleType);
  47. var
  48.   i : integer;
  49. begin
  50.   for i := 1 to MAX do
  51.   begin
  52.     if (Melody[i,1] = 0)
  53.     then
  54.       begin
  55.         NoSound;
  56.         Delay(Melody[i,2]);
  57.       end
  58.     else
  59.       begin
  60.         sound(Melody[i,1]);
  61.         case Style of
  62.           Legato1 : delay(Melody[i,2]);
  63.           Legato2 : begin
  64.                       delay(Melody[i,2]);
  65.                       NoSound;
  66.                     end;
  67.            Normal : begin
  68.                       delay(Round(Melody[i,2] * 0.875));
  69.                       NoSound;
  70.                       delay(Round(Melody[i,2] * 0.125));
  71.                     end;
  72.          Staccato : begin
  73.                       delay(Round(Melody[i,2] * 0.75));
  74.                       NoSound;
  75.                       delay(Round(Melody[i,2] * 0.25));
  76.                     end;
  77.         end;
  78.       end;
  79.   end;
  80.   NoSound;
  81. end;
  82.  
  83. end.
  84.