REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Sample for using BEEP to play sounds





 
/*                                                                    */
/* sample REXX file to show how to use BEEP for sounds                */
/*                                                                    */
/* This CMD plays "Axel F." using the speaker                         */
/*                                                                    */
/* Source: Found in a public news group                               */
/*                                                                    */

                    /* format of the data:                            */
                    /* tone, duration, tone, duration, ...            */
  Data = ' 676 460  804 340  676 230  676 110  902 230  676 230  602 230',
         ' 676 460 1012 340  676 230  676 110 1071 230 1012 230  804 230',
         ' 676 230 1012 230 1351 230  676 110  602 230  602 110  506 230',
         ' 758 230  676 460 32767 460',
         ' 338 110  301 230  253 230  225 230  676 460  804 340  676 230',
         ' 676 110  902 230  676 230  602 230  676 460 1012 340  676 230',
         ' 676 110 1071 230 1012 230  804 230  676 230 1012 230 1351 230',
         ' 676 110  602 230  602 110  506 230  758 230  676 460',
         ' 32767 920',
         ' 32767 690',
         ' 1012 230 1012 230 1012 110 1204 230 1204 230 1204 110 1136 230',
         ' 1136 230 32767 230',
         ' 1012 230 1012 230 1012 110 1204 230 1204 110 1136 230 1012 460',
         ' 32767 230',
         ' 804 230  804 230  804 230  804 230  902 110  902 230  902 230',
         ' 902 110  902 230 1012 230 1012 230 1012 230  902 110 1012 230',
         ' 1012 460 32767 460',
         ' 1012 230 1012 230 1012 110 1204 230 1204 230 1204 110 1136 230',
         ' 1136 230 32767 230',
         ' 1012 230 1012 230 1012 110 1204 230 1204 110 1136 230 1012 460',
         ' 32767 230',
         ' 804 230  804 230  804 230  804 230  902 110  902 230  902 230',
         ' 902 110  902 230 1012 230 1012 230 1012 230  902 110 1012 230',
         ' 1012 460 32767 460',
         ' 676 460  804 340  676 230  676 110  902 230  676 230  602 230',
         ' 676 460 1012 340  676 230  676 110 1071 230 1012 230  804 230',
         ' 676 230 1012 230 1351 230  676 110  602 230  602 110  506 230',
         ' 758 230  676 460 32767 690'


                    /* number of repeats                              */
  repeatNo = 1
                    /* create a stem with note and duration           */
  J = 0
  do I = 1 to Words( Data ) by 2
    J = J + 1
    Note.J = SubWord( Data, I, 1 )
    Duration.J = SubWord( Data, I + 1, 1 )
  end I

  do a = 1 to repeatNo
    do play = 1 to J
      Call Beep Note.play, Duration.play
    end /* do play = 1 to J */
  end /* do a = 1 to repeatNo */

exit 0

  

Inf-HTML End Run - Successful