-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDemoAF_CriticalBand.m
More file actions
139 lines (123 loc) · 4.2 KB
/
DemoAF_CriticalBand.m
File metadata and controls
139 lines (123 loc) · 4.2 KB
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
%
% Demonstrations for introducting auditory filters
% DemoAF_CriticalBand
% Irino, T.
% Created: 9 Mar 2010
% Modified: 9 Mar 2010
% Modified: 11 Mar 2010
% Modified: 16 Mar 2010
% Modified: 7 Apr 2010
% Modified: 11 Apr 2010
% Modified: 10 May 2010 (Unicode for MATLAB 2010a)
% Modified: 27 May 2010
% 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)
%
% Reference:
% Houtsma, A.J.M., Rossing, T.D., Wagenaars, W.M.,
% "Auditory Demostrations," p.10, IPO/ASA CD, Philips, 1126-061,
% Sept., 1987.
%
%
%
DemoAF_MkProbeTone
%% %% PlaySnd with/without Masking noise
%% bwList = [4000, 1000, 250, 100, 10, 5];
bwList = [0 4000, 1000, 250, 100, 10];
for nBW = 1:length(bwList)
if nBW == 1, % 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;
else % with masking noise
disp(['------------------------']);
if nBW == 2,
if SwEnglish == 0,
disp('次に帯域雑音を重畳します。');
disp('帯域雑音の種類ごとに,何個聞こえるか答えてください。');
% making Bandpass noise and playback together
else
disp('Now the signal is masked with bandpass noise.');
disp('How many steps can you hear? ');
end;
end;
bw = bwList(nBW);
BPN = [];
if SwEnglish == 0,
disp(['帯域幅 ' int2str(bw) ' (Hz)']);
else
disp(['Bandwidth: ' int2str(bw) ' (Hz)']);
end;
AmpBPN = AmpPip*0.2;
fBand = [ max(0,fp-bw/2), fp+bw/2];
BPN = MkBPNoise(fs,fBand,length(pipStair)/fs*1000); % in ms
PlaySnd = AmpBPN*BPN + pipStair;
if max(abs(PlaySnd))> 1
error('Sound amp. exceeds the limit (1.0).');
end;
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); clf;
Nrsl = 2^16;
[frsp, freq] = freqz(PlaySnd(1:Nrsl),1,Nrsl,fs);
plot(freq,20*log10(abs(frsp)));
axis([0, fp*2.5, -20 80]);
xlabel('Frequency (Hz)');
ylabel('Level (dB)');
drawnow
if SwSound == 1,
% Play sound
ap = audioplayer(PlaySnd(:),fs);
playblocking(ap);
else
pause(3);
end;
close(NumFig);
% response collection
rsp = [];
while length(rsp) == 0,
rsp = input(StrAns);
end;
Resp1(nBW) = rsp;
disp(' ');
disp(' ');
end; % for nb = 0:length(bwList)
%%
figure(10); clf;
disp('Figure 10: Result')
[frList nsort] = sort(bwList); % sort order
RespPl = (Resp1(nsort) - Resp1(1))*(-5); % relative level from no masker
frListPl = [frList.^(0.3)]; % only for plot purpose. non-linear axis
plot(frListPl,RespPl,'*-');
set(gca,'Xtick',frListPl);
set(gca,'XtickLabel',frList);
ax = axis;
axis([ax(1:2), ax(3), ax(4)+5]);
xlabel('Noise bandwidth (Hz)');
ylabel('Degree of masking (dB)');
grid on;
DemoAF_PrintFig([DirWork 'DemoAF_Exp_CriticalBandThresh'],SwPrint);