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 >
Wrap
Text File
|
2005-10-31
|
2KB
|
70 lines
class oz'track {
proc oz'track {this} {
set ($this,playing) 0
set ($this,filename) 0
}
proc property {this args} {
set optstring {
{volume "1"}
{crosstime "1"}
}
array set v [cmdline::getopt $args $optstring]
set ($this,volume) $v(volume)
set ($this,crosstime) $v(crosstime)
}
proc play {this args} {
set optstring {
{repeat "0"}
{noplay}
}
array set v [cmdline::getopt $args $optstring]
set filename [cmdline::getarg $args $optstring]
if {[oz'valid? $($this,playing)] && $v(repeat?)} {
oz'sound::property $($this,playing) -repeat $v(repeat)
}
if $v(noplay?) return
if {$($this,filename) == $filename && [oz'valid? $($this,playing)]} return
stop $this
if {$filename != "silence"} {
set ($this,filename) $filename
set ($this,playing) [new oz'sound $filename]
oz'sound::property $($this,playing) -volume 0 -repeat $v(repeat)
oz'sound::fadeto $($this,playing) $($this,volume) $($this,crosstime)
oz'sound::play $($this,playing)
}
}
proc stop {this} {
if [oz'valid? $($this,playing)] {oz'sound::fadeto $($this,playing) 0 $($this,crosstime)}
set ($this,playing) 0
set ($this,filename) ""
}
}
namespace eval wq'track {
proc play {track args} {
oz'event {eval "oz'track::play $track $args"}
}
}
set music_track [new oz'track]
oz'track::property $music_track \
-volume $config::music::volume \
-crosstime $config::music::crosstime
set ambient_track [new oz'track]
oz'track::property $ambient_track \
-volume $config::ambient2d::volume \
-crosstime $config::ambient2d::crosstime