-
Notifications
You must be signed in to change notification settings - Fork 1
/
DemoAF_NotchedNoise.m
151 lines (131 loc) · 4.76 KB
/
DemoAF_NotchedNoise.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
%
% Demonstrations for introducting auditory filters
% DemoAF_NotchedNoise
% Irino, T.
% Created: 9 Mar 2010
% Modified: 9 Mar 2010
% Modified: 11 Mar 2010
% Modified: 16 Mar 2010
% Modified: 7 Apr 2010
% Modified: 10 May 2010 (Unicode)
% Modified: 11 Jun 2010 (Figure number)
% Modified: 25 May 2015 (sound --> audioplayer+playblocking, MATLAB2013a-)
% Modified: 25 May 2015 (introduction of SwPrint)
% Modified: 1 Jul 2020 (octaveでoptimizationができるように)
% Modified: 2 Jul 2020 (debug, StrAns)
%
%
%
DemoAF_MkProbeTone
%% Parameter settings
ParamNN.fs = fs;
ParamNN.fp = fp;
ParamNN.FreqBand = 0.4*fp;
ParamNN.FreqLowMax = [1:-0.1:0.5]*fp;
ParamNN.FreqLowMin = ParamNN.FreqLowMax-ParamNN.FreqBand;
ParamNN.FreqUppMin = [1:0.1:1.5]*fp;
ParamNN.FreqUppMax = ParamNN.FreqUppMin+ParamNN.FreqBand;
ParamNN.FreqNotchWidth = ParamNN.FreqUppMin-ParamNN.FreqLowMax;
%% Note: The following setting depends on your audio settings.
%% These are dummy values for Demonstration purpose.
ParamNN.N0 = 40; % Noise level. it is dummy value!
ParamNN.FloorLevel = 30; % Dummy floor level for consistency.
%% %% PlaySnd with/without Masking noise
for nb = 0:length(ParamNN.FreqLowMax)
if nb == 0, % no masking noise
disp(' ');
if SwEnglish == 0,
disp('5dBずつ減衰するプローブ音系列を2回再生します。');
disp('何個聞こえるか答えてください。');
else
disp('You will hear 2000-Hz tone in several descreasing steps of 5 dBs.');
disp('Count how many steps you can hear.');
disp('Series are presented twice.');
end;
PlaySnd = pipStair;
numResp = length(ParamNN.FreqLowMax)+1;
else
disp(['------------------------']);
if nb == 1,
if SwEnglish == 0,
disp('次にノッチ雑音を重畳します。');
disp('ノッチ雑音の種類ごとに,何個聞こえるか答えてください。');
else
disp('Now the signal is masked with notched noise.');
disp('How many steps can you hear?');
end;
end;
BPN1 = [];
BPN2 = [];
if SwEnglish == 0,
disp(['ノッチ幅 ' int2str(ParamNN.FreqNotchWidth(nb)) ...
'(Hz)']);
else
disp(['Notch width: ' int2str(ParamNN.FreqNotchWidth(nb)) ...
'(Hz)']);
end;
% making Bandpass noise and playback together
AmpBPN = AmpPip;
fBand1 = [ParamNN.FreqLowMin(nb), ParamNN.FreqLowMax(nb)];
BPN1 = MkBPNoise(fs,fBand1,length(pipStair)/fs*1000); % in ms
fBand2 = [ParamNN.FreqUppMin(nb), ParamNN.FreqUppMax(nb)];
BPN2 = MkBPNoise(fs,fBand2,length(pipStair)/fs*1000); % in ms
PlaySnd = AmpBPN*(BPN1+BPN2) + pipStair;
if max(abs(PlaySnd))> 1
error('Sound amp. exceeds the limit (1.0).');
end;
numResp = nb;
end;
%% %% Playback & collect response
NumFig = 11;
StrAns ='Steps >> '; % default for SwSound == 0
if SwSound == 1,
if SwEnglish == 0,
kk = input('リターンで再生開始 >> ');
disp(['再生中... (Figure ' int2str(NumFig) ' にスペクトル表示中)']);
StrAns ='聞こえた数 >> ';
else
kk = input('Start by return >> ');
disp(['Playing now... (Spectrum is shown in Figure ' int2str(NumFig) '.)']);
StrAns ='Steps >> ';
end;
end; % if SwSound == 1,
% %% plot Spectrogram of the initial part
figure(NumFig);
Nrsl = 2^16;
[frsp, freq] = freqz(PlaySnd(1:Nrsl),1,Nrsl,fs);
plot(freq,20*log10(abs(frsp)));
axis([0, fp*2.5, -40 80]);
axis([0, fp*2.5, -20 80]);
xlabel('Frequency (Hz)');
ylabel('Level (dB)');
drawnow
if SwSound == 1,
% obsolete sound(PlaySnd(:),fs);
ap = audioplayer(PlaySnd(:),fs);
playblocking(ap);
else
pause(3);
end;
close(NumFig);
% response collection
rsp = [];
while length(rsp) == 0,
rsp = input(StrAns);
end;
Resp1(numResp) = rsp;
disp(' ');
disp(' ');
end; % for nb = 0:length(ParamNN.FreqLowMax)
%% %% plot notchwidth vs. ProbeLevel
figure(12);
disp('Figure 12: Result')
ProbeLevel = (Resp1(1:length(ParamNN.FreqNotchWidth)) - Resp1(end))*(-5);
ProbeLevel = ProbeLevel + ParamNN.FloorLevel;
plot(ParamNN.FreqNotchWidth,ProbeLevel,'*-');
xlabel('Notch bandwidth (Hz)');
ylabel('Degree of masking (dB)');
ax = axis;
axis([ax(1:2), ax(3)-5, ax(4)+5]);
grid on;
DemoAF_PrintFig([DirWork 'DemoAF_Exp_NotchNoiseThreshMeaure'],SwPrint);