Permalink
Browse files

keep running smoothly if loop is dropped in while playing

  • Loading branch information...
adamflorin committed Nov 11, 2011
1 parent bb5bcdb commit d1035e797495724d7eb297cd23755dec70290a74
Showing with 11 additions and 2 deletions.
  1. +11 −2 ruby/loom/player/loop.rb
View
@@ -30,20 +30,29 @@ def set_generator_parameter_with_loop(key, parameter)
end
end
+ #
+ #
+ def init_loop
+ @gesture_history = []
+ @gesture_history_index = 0
+ end
+
#
#
def clear_events_with_loop
clear_events_without_loop
- @gesture_history = []
- @gesture_history_index = 0
+ init_loop
end
# returns event array--might be new events or rescheduled (looped) old ones
#
def generate_gesture_with_loop(now)
loop_len = @loop_len.generate.to_i.constrain(1..16)
+ # if it was dropped in while playing
+ init_loop if @gesture_history.nil?
+
# if we're in loop mode and have a sufficient backlog
if @loop_on and @gesture_history.size >= loop_len

0 comments on commit d1035e7

Please sign in to comment.