lib/xi/clock.rb in xi-lang-0.1.4 vs lib/xi/clock.rb in xi-lang-0.1.5

- old
+ new

@@ -62,10 +62,18 @@ def seconds_per_cycle @mutex.synchronize { 1.0 / @cps } end + def current_time + Time.now.to_f - @init_ts + @latency + end + + def current_cycle + current_time * cps + end + def inspect "#<#{self.class.name}:#{"0x%014x" % object_id} " \ "cps=#{cps.inspect} #{playing? ? :playing : :stopped}>" end @@ -78,10 +86,10 @@ end end def do_tick return unless playing? - now = Time.now.to_f - @init_ts + @latency + now = self.current_time cps = self.cps @streams.each { |s| s.notify(now, cps) } rescue => err error(err) end