home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / MUSIC.DEF < prev    next >
Text File  |  1989-05-28  |  3KB  |  65 lines

  1. DEFINITION MODULE Music;
  2.  
  3.     (********************************************************)
  4.     (*                            *)
  5.     (*        Module to play music.            *)
  6.     (*                            *)
  7.     (*  Programmer:        P. Moylan            *)
  8.     (*  Last edited:    28 May 1989            *)
  9.     (*  Status:                        *)
  10.     (*    Initial version working well.  Still testing.    *)
  11.     (*                            *)
  12.     (********************************************************)
  13.  
  14. PROCEDURE SetNoteDuration (D: CARDINAL);
  15.  
  16.     (* Sets the duration of each of the following notes, until further    *)
  17.     (* notice, to D milliseconds.  The precision of this setting is    *)
  18.     (* limited by the clock interrupt frequency used in module Timer;    *)
  19.     (* the resolution can be as poor as 1/9 second.  The duration can    *)
  20.     (* subsequently be modified by the * and / options (see below), or    *)
  21.     (* by another call to SetNoteDuration.                *)
  22.  
  23. PROCEDURE PlayMusic (notes: ARRAY OF CHAR);
  24.  
  25.     (* Plays the tune specified in array "notes".  The playing is done    *)
  26.     (* asynchronously; that is, this procedure returns before the music    *)
  27.     (* is over.  However, a return from this procedure does imply that    *)
  28.     (* array "notes" can be re-used or destroyed; the notes might not    *)
  29.     (* yet have been played, but the data necessary to play them have    *)
  30.     (* been processed and the necessary information stored.        *)
  31.  
  32. PROCEDURE WaitForMusicFinished;
  33.  
  34.     (* Blocks the calling task until there is no more music playing.    *)
  35.     (* This is a guard against things like premature task termination.    *)
  36.  
  37. (************************************************************************)
  38. (*                                    *)
  39. (*  In the "notes" argument to PlayMusic, the following options are    *)
  40. (*  accepted:                                *)
  41. (*    C D E F G A B    the usual notation for a note.            *)
  42. (*    b #        flat or sharp, modifying the previously given    *)
  43. (*             note.  There is no legality checking; for    *)
  44. (*             example, B# is illegal but the software does    *)
  45. (*             check for this.                *)
  46. (*    R        a rest.                        *)
  47. (*    *        double the duration of the following notes.    *)
  48. (*    /        halve the duration of the following notes.    *)
  49. (*    3        divide the duration of the following notes    *)
  50. (*             by 3.  The *, /, and 3 options take effect for    *)
  51. (*             all following notes, until the duration is    *)
  52. (*             modified again by one of these options or by    *)
  53. (*             an explicit call to SetNoteDuration.        *)
  54. (*    u        go up one octave.                *)
  55. (*    d        go down one octave.  In many cases the u and d    *)
  56. (*             options are not needed because PlayMusic    *)
  57. (*             chooses the appropriate octave based on the    *)
  58. (*             assumption that successive notes will be    *)
  59. (*             close to each other; but u and d can override    *)
  60. (*             this assumption.                *)
  61. (*                                    *)
  62. (************************************************************************)
  63.  
  64. END Music.
  65.