home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 19 / AACD19.BIN / AACD / Programming / AWNP / AWNP-Docs / Demos / sound.rx < prev    next >
Encoding:
Text File  |  2000-10-04  |  2.0 KB  |  84 lines

  1. /*Sound use example*/
  2.  
  3. /* a little setup*/
  4. soundobj=''
  5. volume=48
  6.  
  7. /* build the gui*/
  8. call open(ca,'awnpipe:test/xc')
  9. call topipe('"Sound Player" defg fh v m ')
  10. call topipe('bitmap fn "speaker.ilbm" trans')
  11. volumegad=topipe('slider ui v minn 0 maxn 64 s 48 dis 1')
  12. call topipe('layout si so')
  13. newgad=topipe('button gt "Select Sound"')
  14. playgad=topipe('button gt "Play" dis 1')
  15. stopgad=topipe('button gt "Stop" dis 1')
  16. quitgad=topipe('button gt "Quit"')
  17. call topipe('le')
  18. call topipe('bitmap fn "wave.ilbm" trans')
  19. freqgad=topipe('slider ui v minn 1 maxn 1000 s 32 flip dis 1')
  20. call topipe('layout si so b 0')
  21. call topipe('space')
  22. call topipe('label gt "Volume changes only take place*nimmediately under ADOS 3.5" ')
  23. call topipe('space')
  24. call topipe('le')
  25. filegad=topipe('getfile asl ')
  26. call topipe('open')
  27. /* main loop*/
  28. do while ~eof(ca)
  29.   call topipe('con')
  30.   in= readln(ca)
  31.   parse var in in1 in2 in3 in4 in5 .
  32.   if in1='gadget' then call gadget()
  33.   if in1='close' then do
  34.     exit
  35.   end
  36. end
  37. exit
  38.  
  39. gadget:
  40. if in2=newgad then do
  41.   call writeln(ca,'id 'filegad' s 1')
  42. parse value readln(ca) with ok '"' filename '"'
  43. if ok=0 then return(0)
  44. call writeln(ca,'define sound volume 'volume' fn "'filename'"')
  45. parse value readln(ca) with ok newsoundobj
  46. if ok~='ok' then return
  47. if soundobj~='' then call topipe('id 'soundobj' freesound')
  48. soundobj=newsoundobj
  49. period=x2d(topipe('id 'soundobj' get 800011f8'))
  50. call topipe('id 'freqgad' s 'period' ref ')
  51. call topipe('id 0 dis 0 ref')
  52. end
  53. if in2=quitgad then do
  54.   exit
  55. end
  56. if in2=playgad then do
  57. call topipe('id 'soundobj' s 2 volume 'volume' period 'period)
  58. end
  59. if in2=stopgad then do
  60. call topipe('id 'soundobj' freesound')
  61. soundobj=topipe('define sound fn "'filename'"')
  62. end
  63. if in2=volumegad then do
  64. volume=in3
  65. call topipe('id 'soundobj' volume 'in3)
  66. end
  67. if in2=freqgad then do
  68. period=in3+1
  69. call topipe('id 'soundobj' s 2 period 'period)
  70. end
  71. return(0)
  72.  
  73.  
  74. topipe:
  75. parse arg out
  76. call writeln(ca,out)
  77. res=readln(ca)
  78. parse var res res1 res2 .
  79. if res1='ok' then return(res2)
  80. say 'error from: 'out
  81. say '  responce: ' res
  82. exit
  83.  
  84.