-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_tones.m
More file actions
43 lines (30 loc) · 898 Bytes
/
gen_tones.m
File metadata and controls
43 lines (30 loc) · 898 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
clear
clc
close all
Fs = 96000;
tone_list = 4000:1000:25000;
duration = 15;
time_vec = 0:1/Fs:(30-1/Fs);
ramp_time = 100/1000; %10ms
ramp_per = (ramp_time/duration);
%window_func = tukeywin(Fs*duration,ramp_per);
%window_func = hamming(2.*Fs*duration);
noise = randn(size(time_vec));
noise = 0.01.*noise;
base_dir = pwd;
atten = floor(2^16.*10^(-0/20));
system(['"' base_dir '\nircmd.exe" setsysvolume ' num2str(atten) ' &']) %max volume = 16 bit
drawnow;
tone_store = cell(length(tone_list),1);
for idx = 1:length(tone_list)
tone_sig = sin(2.*pi.*tone_list(idx).*time_vec);
% tone_sig = tone_sig + noise;
% tone_sig = tone_sig./max(abs(tone_sig));
%
if tone_list(idx) < 10000
atten_fac = 10^(-20/20);
else
atten_fac = 1;
end
tone_store{idx} = audioplayer(atten_fac.*tone_sig,Fs);
end