home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / sound.seq < prev    next >
Text File  |  1989-09-21  |  2KB  |  38 lines

  1. \ SOUND.SEQ             Some Sound Experiments
  2.  
  3. comment:
  4.  
  5.   A simple sound generator for F-PC, programs the timer chip for the
  6. proper frequency, then enables the tone to the speaker for "duration"
  7. number of tenths of a second.
  8.  
  9. comment;
  10.  
  11. \ port addresses pulled from:
  12. \        "The Peter Norton Programmer's Guide to the IBM-PC"
  13.  
  14. 66 constant timerdata           \ timer data port
  15. 67 constant timerctrl           \ timer control port
  16. 97 constant tonegate            \ tone gate
  17.  
  18.                                                 \ freq     = frequency in Hz
  19. : tone          ( freq duration -- )            \ duration = tenths of sec
  20.                 >r                              \ save duration
  21.                 182 timerctrl pc!               \ prepare for new frequency
  22.                 1193280. rot um/mod nip                 \ calculate timer vals
  23.                 256 /mod swap                           \ for desired freq.
  24.                 timerdata pc! timerdata pc!             \ set counter values
  25.                 tonegate pc@ $03 or  tonegate pc!       \ tone on
  26.                 r> tenths                               \ for duration
  27.                 tonegate pc@ $FC and tonegate pc! ;     \ tone off
  28.  
  29.   1 value beepduration          \ time in tenths of a second for BEEP
  30. 500 value beepfreq              \ frequency of BEEP in Hz.
  31.  
  32. : newbeep       ( -- )
  33.                 beepfreq beepduration tone ;
  34.  
  35. ' newbeep is beep               \ install NEWBEEP into BEEP defered word
  36.  
  37.  
  38.