home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2006 April / SGP.iso / dema / Keepsake-Demo-en-li-v1.0.exe / res / bin / prime / oz'track.tcl < prev    next >
Text File  |  2005-10-31  |  2KB  |  70 lines

  1. class oz'track {
  2.     proc oz'track {this} {
  3.         set ($this,playing)   0
  4.         set ($this,filename)  0
  5.     }
  6.  
  7.     proc property {this args} {
  8.         set optstring {
  9.             {volume    "1"}
  10.             {crosstime "1"}
  11.         }
  12.         
  13.         array set v [cmdline::getopt $args $optstring]
  14.  
  15.         set ($this,volume)    $v(volume)
  16.         set ($this,crosstime) $v(crosstime)
  17.     }
  18.     
  19.     proc play {this args} {
  20.         set optstring {
  21.             {repeat "0"}
  22.             {noplay}
  23.         }
  24.         
  25.         array set v [cmdline::getopt $args $optstring]
  26.         set filename [cmdline::getarg $args $optstring]
  27.  
  28.         if {[oz'valid? $($this,playing)] && $v(repeat?)} {
  29.             oz'sound::property $($this,playing) -repeat $v(repeat)
  30.         }
  31.  
  32.         if $v(noplay?) return
  33.         
  34.         if {$($this,filename) == $filename && [oz'valid? $($this,playing)]} return
  35.         stop $this
  36.  
  37.         if {$filename != "silence"} {
  38.             set ($this,filename) $filename
  39.             set ($this,playing) [new oz'sound $filename]
  40.  
  41.             oz'sound::property $($this,playing) -volume 0 -repeat $v(repeat)
  42.             oz'sound::fadeto   $($this,playing) $($this,volume) $($this,crosstime)
  43.             oz'sound::play     $($this,playing)
  44.         }
  45.     }
  46.  
  47.     proc stop {this} {
  48.         if [oz'valid? $($this,playing)] {oz'sound::fadeto $($this,playing) 0 $($this,crosstime)}
  49.         set ($this,playing) 0
  50.         set ($this,filename) ""
  51.     }
  52. }
  53.  
  54. namespace eval wq'track {
  55.     proc play {track args} {
  56.         oz'event {eval "oz'track::play $track $args"}
  57.     }
  58. }
  59.  
  60. set music_track [new oz'track]
  61. oz'track::property $music_track \
  62.     -volume    $config::music::volume \
  63.     -crosstime $config::music::crosstime
  64.  
  65. set ambient_track [new oz'track]
  66. oz'track::property $ambient_track \
  67.     -volume    $config::ambient2d::volume \
  68.     -crosstime $config::ambient2d::crosstime
  69.  
  70.