--[[ xStream 02.2008 ]] class "stereo_sound" function stereo_sound:__init() self.both = nil self.end_time=nil end function stereo_sound:initialize(sound,lvl) if self.both then self:stop() end self.both = sound_object(sound) self.end_time = nil if not self.both then abort("stereo_sound:initialize: Cannot open sound file "..sound) end if lvl then self:set_volume(lvl) end end function stereo_sound:play() if not db.actor then return end self.both:play(db.actor,0, sound_object.s2d) self.end_time = time_global() + self.both:length() return self.end_time end function stereo_sound:play_at_time(time, sound, lvl) self.end_time = nil self.both:attach_tail(sound) if lvl then self:set_volume(lvl) end self.both_tail = sound_object(sound) if not self.both_tail then abort("stereo_sound:initialize: Cannot open sound file "..sound) end self.end_time = time + self.both_tail:length() return self.end_time end function stereo_sound:playing() return self.both and self.both:playing() end function stereo_sound:update(vol) if vol and self:playing() then self:set_volume(vol)end end function stereo_sound:stop() if self.both and self.both:playing() then self.both:stop() end end function stereo_sound:length() return self.both and self.both:length() or 1 end function stereo_sound:set_volume(num) if self.both then self.both.volume=num end end