home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / RxCD / Examples / intro.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-09-23  |  2.0 KB  |  105 lines

  1. /* Plays first 4 seconds of each track */
  2.  
  3. l="rxcd.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  4. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  5.  
  6. else cdName=
  7. parm.0.value="cd0"
  8. parm.1.value=4
  9.  
  10. secs=parm.0.value
  11. if ~ReadArgs("DEVICE,SECS/K/N") then do
  12.     call PrintFault()
  13.     exit
  14. end
  15.  
  16. signal on halt
  17. signal on break_c
  18.  
  19. cdName=parm.0.value
  20. secs=parm.1.value
  21. if secs<0 | secs>9 then do
  22.     say "Error invalid value '"secs"' for SECS"
  23.     exit
  24. end
  25.  
  26. cd = CDCreate(cdName)
  27. if cd=0 then do
  28.     say "Error for ["cdName"]:" GetRxCDString(RC)
  29.     exit
  30. end
  31.  
  32. if CDInfo(cd,"db","info")=0 then iscd=(info.PeripheralType==5)
  33. else iscd=0
  34. if ~iscd then do
  35.     say "Error: ["cdName"] is not a cd device"
  36.     exit
  37. end
  38.  
  39. if CDModeSense(cd,"db","MS")=0 then isdatacdin=(and(ms.mediumtype,2)=0)
  40. else isdatacdin=0
  41. if isdatacdin then do
  42.     say "Error: there is no audio cd in ["cdName"]"
  43.     exit
  44. end
  45.  
  46. res = CDTOC(cd,"db",'toc')
  47. if res~=0 then do
  48.     say "Error: can't read TOC of ["cdName"]"
  49.     exit
  50. end
  51.  
  52. say
  53. say "---- Intro ----"
  54. say "    Device:" cdName
  55. say "    Tracks:" toc.Num
  56. say "FirstTrack:" toc.FirstTrack
  57. say " LastTrack:" toc.LastTrack
  58. say " StartAddr:" toc.StartAddr
  59. say "   EndAddr:" toc.EndAddr
  60. say "   CDDB ID:" toc.ID
  61. say "[press cltr-c to exit]"
  62. say
  63. say "Initializing..."
  64.  
  65. ctrl_c=2**12
  66. tim = CreateTimer()
  67. ts = TimerSignal(tim)
  68. do i=0 to toc.num-1
  69.     if ~toc.i.Audio then iterate
  70.  
  71.     if CDPlay10(cd,"db",toc.i.StartAddr,secs*75)~=0 then signal ChangeStatus()
  72.  
  73.     call SayTrack(i,0)
  74.     do j=1 to secs
  75.         call StartTimer(tim,1)
  76.         recv = Wait(or(ts,ctrl_c))
  77.         if and(recv,ctrl_c)>0 then signal break_c
  78.         call SayTrack(i,j)
  79.     end
  80. end
  81. say "B"x || "Done.                                               "
  82. exit
  83.  
  84. FNum:
  85. parse arg n
  86.     return right("00" || n,2)
  87.  
  88. SayTrack:
  89. parse arg i,j
  90.     say "B"x || "Track#"toc.i.track i+1"/"toc.Num "("FNum(toc.i.Min)":"FNum(toc.i.Sec)") [00:0"j"]"
  91.     return
  92.  
  93. ChangeStatus:
  94.     if CDModeSense(cd,"db","MS")=0 then isdatacdin=(and(ms.mediatype,2)~=0)
  95.     else isdatacdin=0
  96.     if ~isdatacdin then do
  97.         say "Error: there is no audio cd in ["cdName"]"
  98.         exit
  99.     end
  100.  
  101. halt:
  102. break_c:
  103.     exit
  104.  
  105.