diff options
Diffstat (limited to 'theremine.m')
-rw-r--r-- | theremine.m | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/theremine.m b/theremine.m index 11f0dc0..a9b908b 100644 --- a/theremine.m +++ b/theremine.m @@ -61,18 +61,11 @@ while gesture_count < (1 * (const_frames_per_second - const_calc_offset)) frame = matleap_frame; handCount = size(frame.hands); - if isequal(zero_hands, handCount) - gesture_count = 0; - - % slowly lower volume if no hand is there - y_one = y_one * const_fade_speed; - y_two = y_two * const_fade_speed; - - % TODO - elseif isequal(one_hand, handCount) - % fade hand two out - y_two = y_two * const_fade_speed; - + % slowly decrease volume + y_one = y_one * const_fade_speed; + y_two = y_two * const_fade_speed; + + if isequal(one_hand, handCount) pos = frame.hands(1).palm.position; %pos = frame.hands(1).palm.stabilized_position; @@ -105,22 +98,20 @@ while gesture_count < (1 * (const_frames_per_second - const_calc_offset)) x_two = pos(1); y_two = pos(2); else - disp("That should not happen:"); - disp(handCount); - return; + % no hands, do nothing (or more than 2 (how?! :D)) + gesture_count = 0; end % play current sound [signal_one, offset_one] = get_theremin_sound_bit(x_one, y_one, offset_one, signal); [signal_two, offset_two] = get_theremin_sound_bit(x_two, y_two, offset_two, signal); full_signal = signal_one + signal_two; + if deviceWriter(full_signal(:)) ~= 0 disp("Buffer ran empty!"); end - complete_signal = [complete_signal full_signal]; - % enforce frame rate, leaving a bit of room for calculation - %java.lang.Thread.sleep((1/(const_frames_per_second - const_calc_offset)) * 1000); + complete_signal = [complete_signal full_signal]; end release(deviceWriter) |