home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / SOUNDEFF.DEF < prev    next >
Text File  |  1991-01-30  |  2KB  |  57 lines

  1. DEFINITION MODULE SoundEffects;
  2.  
  3.     (****************************************************************)
  4.     (*                                *)
  5.     (*         Procedures to produce audible output.        *)
  6.     (*                                *)
  7.     (*  Note that this is a low-level output module, in that the    *)
  8.     (*  method of specifying note frequencies is defined in terms    *)
  9.     (*  of what is convenient for the hardware rather than what is    *)
  10.     (*  convenient for the user.  The higher-level features are    *)
  11.     (*  provided in module Music.                    *)
  12.     (*                                *)
  13.     (*    Programmer:    P. Moylan                *)
  14.     (*    Last edited:    28 May 1989                *)
  15.     (*                                *)
  16.     (*    Status:                            *)
  17.     (*    Seems to be working.                    *)
  18.     (*                                *)
  19.     (****************************************************************)
  20.  
  21. FROM Semaphores IMPORT
  22.     (* type *)    Semaphore;
  23.  
  24. TYPE Note = RECORD
  25.         period, duration: CARDINAL;
  26.         END (*RECORD*);
  27.  
  28.     (* The "period" field of a note record specifies the note frequency    *)
  29.     (* indirectly, by specifying a divisor for the 1.193 MHz main clock    *)
  30.     (* frequency.  The "duration" is measured in milliseconds.        *)
  31.  
  32. PROCEDURE Play (VAR (*IN*) playdata: ARRAY OF Note;
  33.             VAR (*INOUT*) done: Semaphore);
  34.  
  35.     (* Adds the array to the list of music queued up waiting to be    *)
  36.     (* played.  The actual playing occurs automatically, after the end    *)
  37.     (* of anything earlier in the queue.  The output is asynchronous,    *)
  38.     (* in the sense that we return from this procedure before the    *)
  39.     (* playing is over, and perhaps even before it has started.  The    *)
  40.     (* array playdata must remain undisturbed until the caller receives    *)
  41.     (* a Signal on semaphore "done".  That is, the caller must perform    *)
  42.     (* a Wait(done) before re-using or destroying the playdata.  Note    *)
  43.     (* that a procedure return will destroy playdata if it happens to    *)
  44.     (* be a local variable of that procedure.                *)
  45.  
  46.     (* A duration code of 0 indicates the end of the data, in cases    *)
  47.     (* where the data do not fill the entire array.            *)
  48.  
  49.     (* A period code of 1, with a nonzero duration, produces silence    *)
  50.     (* for the requested duration.                    *)
  51.  
  52. PROCEDURE Beep;
  53.  
  54.     (* Produces a short "beep" noise.    *)
  55.  
  56. END SoundEffects.
  57.