-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_cursor_frequency.m
31 lines (29 loc) · 1021 Bytes
/
map_cursor_frequency.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function freq = map_cursor_frequency(cursor, fb_mapping, low_target)
%{
function to map a value of cursor to a frequency
Auditory feedback calculation
freq = a*exp(b*(cursor_trunc-cursor_min))
freq_min = a = a*exp(0)
freq_max = a*exp(b*(cursor_max-cursor_min))
b = log(freq_max/a)/(cursor_max-cursor_min)
param: cursor_min, cursor_max
%}
%%
%Handle target -> freq:
if low_target
%This means cursor up makes auditory freq go down:
cursor = -cursor;
cursor_min = -fb_mapping.cursor_max;
cursor_max = -fb_mapping.cursor_min;
else
%This means cursor up makes auditory freq go up:
cursor_min = fb_mapping.cursor_min;
cursor_max = fb_mapping.cursor_max;
end
%%
cursor_trunc = max(cursor, cursor_min);
cursor_trunc = min(cursor_trunc, cursor_max);
freq = fb_mapping.a*exp(fb_mapping.b*(cursor_trunc-cursor_min));
freq = double(freq);
% h = figure;
% plot(cursor, freq);