summaryrefslogtreecommitdiffstats
path: root/theremine.m
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-12-06 13:41:04 +0100
committerNiklas Halle <niklas@niklashalle.net>2020-12-06 13:41:04 +0100
commiteb0349db0084736e92ec6ab7c7cb9db5fae18624 (patch)
tree4cbe0c8e498368dc2745227b3be4bd212c390be9 /theremine.m
parente5dd70fa6273c030c32336257ed630fe377de6fd (diff)
downloadwdti_project-eb0349db0084736e92ec6ab7c7cb9db5fae18624.tar.gz
wdti_project-eb0349db0084736e92ec6ab7c7cb9db5fae18624.zip
slight code cleanups
Diffstat (limited to 'theremine.m')
-rw-r--r--theremine.m27
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)