Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DOA4Seminars
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joanna Luberadzka
DOA4Seminars
Commits
e659f4ce
Commit
e659f4ce
authored
Nov 14, 2017
by
Joanna Luberadzka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some changes which might have ruined things
parent
e6100f38
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
20 deletions
+147
-20
afc/compute_snr_signals.m
afc/compute_snr_signals.m
+2
-5
afc/experimentDOA_cfg.m
afc/experimentDOA_cfg.m
+3
-2
afc/experimentDOA_set.m
afc/experimentDOA_set.m
+4
-8
afc/experimentDOA_user.m
afc/experimentDOA_user.m
+3
-5
afc/experimentDOA_user2.m
afc/experimentDOA_user2.m
+135
-0
No files found.
afc/compute_snr_signals.m
View file @
e659f4ce
...
...
@@ -7,9 +7,9 @@ function [sig, noise]=compute_snr_signals(SNR,signal,noise,L_sig)
% what is the rms level of the original signal
L_old
=
20
*
log10
(
rms
(
signal
)/(
2
*
10
^-
5
));
L_old
=
20
*
log10
(
rms
(
signal
(:,
1
)
+
signal
(:,
2
)
)/(
2
*
10
^-
5
));
% change the level to desired level
v_signal_new
=
signal
*
10
^
((
L_sig
-
L_old
)/
20
);
v_signal_new
=
signal
.
*
10
^
((
L_sig
-
L_old
)/
20
);
% compute gain for the noise
P_sig
=
sum
(
mean
(
v_signal_new
.^
2
));
...
...
@@ -21,7 +21,4 @@ G=sqrt(G/P_noise);
noise
=
noise
*
G
;
sig
=
v_signal_new
;
% L_sig=20*log10(rms(sig)/(2*10^-5));
% L_noise=20*log10(rms(noise)/(2*10^-5));
end
\ No newline at end of file
afc/experimentDOA_cfg.m
View file @
e659f4ce
...
...
@@ -31,7 +31,8 @@ def.reversalnum = 6; % number of reversals in measurement phase
def
.
repeatnum
=
1
;
% number of repeatitions of the experiment
% experimental variable (result of procedure yields dependent variable)
def
.
startvar
=
50
;
% starting value of the tracking variable
def
.
startvar
=
40
;
% starting value of the tracking variable
def
.
expvarunit
=
'dB'
;
% unit of the tracking variable
def
.
expvardescription
=
'signal level'
;
% description of the tracking variable
...
...
@@ -42,7 +43,7 @@ def.terminate = 1; % terminate execution on min/maxvar hit: 0 = warning, 1 =
def
.
endstop
=
3
;
% Allows x nominal levels higher/lower than the limits before terminating (if def.terminate = 1)
% experimental parameter (independent variable)
def
.
exppar1
=
[
0
45
9
0
];
% vector containing experimental parameters for which the exp is performed
def
.
exppar1
=
[
45
90
0
];
% vector containing experimental parameters for which the exp is performed
def
.
exppar1unit
=
'deg'
;
% unit of experimental parameter
def
.
exppar1description
=
'reference angle'
;
% description of the experimental parameter
...
...
afc/experimentDOA_set.m
View file @
e659f4ce
...
...
@@ -54,19 +54,16 @@ switch work.condition
case
'babble'
setup
.
noise
=
audioread
(
'.wav'
);
case
'white'
setup
.
noise
=
randn
(
2
,
10
*
def
.
samplerate
);
n
=
randn
(
10
*
def
.
samplerate
,
1
);
setup
.
noise
=
[
n
n
];
otherwise
error
(
'condition not recognized'
);
end
% define the calibration level (assume 90 dB SPL for 0 dB FS)
work
.
currentCalLevel
=
90
;
setup
.
level
=
50
;
% define signals in structure setup
% setup.modsine = sin([0:def.intervallen-1]'*2*pi*work.exppar1/def.samplerate);
work
.
currentCalLevel
=
90
;
setup
.
level
=
40
;
% make a list of files from which one file should be
% randomly chosen in each trial
...
...
@@ -87,5 +84,4 @@ for k=1:length(setup.HRIRs)
setup
.
HRIRs
{
k
}
.
hrir_refminus
=
loadHRIR
(
'Anechoic'
,
80
,
0
,
def
.
exppar1
(
k
)
-
setup
.
degdiff
,
'in-ear'
)
end
% eof
\ No newline at end of file
afc/experimentDOA_user.m
View file @
e659f4ce
...
...
@@ -50,11 +50,9 @@ fullWavFileName = fullfile([setup.filedir, baseWavFileName]);
% resample the signal
[
P
,
Q
]
=
rat
(
def
.
samplerate
/
fssig
);
sig
=
resample
(
sig
,
P
,
Q
);
% sig=sig.*10^((sig_level - work.currentCalLevel)/20);
L_rms
=
(
20
*
log10
(
rms
(
sig
(:,
1
)
+
sig
(:,
2
))/(
2
*
10
^-
5
)));
L_des
=
work
.
expvaract
;
sig
=
sig
*
10
^
((
L_des
-
L_rms
)/
20
);
L_rms_check1
=
(
20
*
log10
(
rms
(
sConf
.
sig11
(:,
1
)
+
sConf
.
sig11
(:,
2
))/(
2
*
10
^-
5
)));
sig_level
=
work
.
expvaract
;
sig
=
sig
.*
10
^
((
sig_level
-
work
.
currentCalLevel
)/
20
);
...
...
afc/experimentDOA_user2.m
0 → 100644
View file @
e659f4ce
% example_user - stimulus generation function of experiment 'example' -
%
% This function is called by afc_main when starting
% the experiment 'example'. It generates the stimuli which
% are presented during the experiment.
% The stimuli must be elements of the structure 'work' as follows:
%
% work.signal = def.intervallen by 2 times def.intervalnum matrix.
% The first two columns must contain the test signal
% (column 1 = left, column 2 = right) ...
%
% work.presig = def.presiglen by 2 matrix.
% The pre-signal.
% (column 1 = left, column 2 = right).
%
% work.postsig = def.postsiglen by 2 matrix.
% The post-signal.
% ( column 1 = left, column 2 = right).
%
% work.pausesig = def.pausesiglen by 2 matrix.
% The pause-signal.
% (column 1 = left, column 2 = right).
%
% To design an own experiment, e.g., 'myexperiment',
% make changes in this file and save it as 'myexperiment_user.m'.
% Ensure that the referenced elements of structure 'work' are existing.
%
% See also help example_cfg, example_set, afc_main
function
experimentDOA_user
global
def
global
work
global
setup
% 1000 ... 4000 Hz bandlimited Gaussian noise
% The experiment is meant to be 3-interval 3-alternative forced choice, so we need 3 signals.
% One signal holds the target amplitude modulation.
% work.expvaract holds the current value of the tracking variable of the experiment.
% load a random wav file for this trial
numberOfFiles
=
length
(
setup
.
waveFiles
);
fileToPlay
=
randi
(
numberOfFiles
,
1
);
baseWavFileName
=
setup
.
waveFiles
(
fileToPlay
)
.
name
;
fullWavFileName
=
fullfile
([
setup
.
filedir
,
baseWavFileName
]);
[
sig
fssig
]
=
audioread
(
fullWavFileName
);
% resample the signal
[
P
,
Q
]
=
rat
(
def
.
samplerate
/
fssig
);
sig
=
resample
(
sig
,
P
,
Q
);
% sig_level=work.expvaract;
% sig=sig.*10^((sig_level - work.currentCalLevel)/20);
% choose hrir:
% * find which reference angle is currently tested
% * randomly choose +or- 5or10 deg
def
.
exppar1
;
indx
=
find
(
def
.
exppar1
==
work
.
exppar1
);
hrir_ref
=
setup
.
HRIRs
{
indx
}
.
hrir_ref
.
data
;
plusorminus
=
randi
(
2
);
if
plusorminus
==
1
hrir_targ
=
setup
.
HRIRs
{
indx
}
.
hrir_refplus
.
data
;
elseif
plusorminus
==
2
hrir_targ
=
setup
.
HRIRs
{
indx
}
.
hrir_refminus
.
data
;
end
% convolve signals
sig_ref
(:,
1
)
=
conv
(
sig
,
hrir_ref
(:,
1
));
sig_ref
(:,
2
)
=
conv
(
sig
,
hrir_ref
(:,
2
));
sig_targ
(:,
1
)
=
conv
(
sig
,
hrir_targ
(:,
1
));
sig_targ
(:,
2
)
=
conv
(
sig
,
hrir_targ
(:,
2
));
% noise_level=setup.level;
% *10^((noise_level - work.currentCalLevel)/20);
% provide 3 randomly cut excerpts of noise
noise
=
setup
.
noise
;
L
=
length
(
sig
)
+
length
(
hrir_targ
)
-
1
;
start1
=
randi
(
length
(
noise
)
-
L
);
noise1
=
noise
(
start1
+
1
:
start1
+
L
,:);
start2
=
randi
(
length
(
noise
)
-
L
);
noise2
=
noise
(
start2
+
1
:
start2
+
L
,:);
start3
=
randi
(
length
(
noise
)
-
L
);
noise3
=
noise
(
start3
+
1
:
start3
+
L
,:);
% LEVELS: here scale the noise so that it has level according
% to the current tracking variable work.expvaract
% tref1 = real(ifft(scut(fft(randn(def.intervallen,1)),1000,4000,def.samplerate))) * 10^((setup.level - work.currentCalLevel)/20);
% tref2 = real(ifft(scut(fft(randn(def.intervallen,1)),1000,4000,def.samplerate))) * 10^((setup.level - work.currentCalLevel)/20);
% tuser = real(ifft(scut(fft(randn(def.intervallen,1)),1000,4000,def.samplerate))) * 10^((setup.level - work.currentCalLevel)/20) .* ... // holds the target signal
% (1 + (10^(work.expvaract/20) * setup.modsine));
%window
setup
.
hannlen
=
round
(
0.05
*
def
.
samplerate
);
setup
.
window
=
hannfl
(
L
,
setup
.
hannlen
,
setup
.
hannlen
);
SNR
=
work
.
expvaract
-
setup
.
level
;
[
sig_ref1
,
noise_ref1
]
=
compute_snr_signals
(
SNR
,
sig_ref
,
noise1
,
work
.
expvaract
-
work
.
currentCalLevel
);
tref11
=
(
sig_ref1
(:,
1
)
+
noise_ref1
(:,
1
))
.*
setup
.
window
;
tref12
=
(
sig_ref1
(:,
2
)
+
noise_ref1
(:,
2
))
.*
setup
.
window
;
[
sig_ref2
,
noise_ref2
]
=
compute_snr_signals
(
SNR
,
sig_ref
,
noise2
,
work
.
expvaract
-
work
.
currentCalLevel
);
tref21
=
(
sig_ref2
(:,
1
)
+
noise_ref2
(:,
1
))
.*
setup
.
window
;
tref22
=
(
sig_ref2
(:,
2
)
+
noise_ref2
(:,
2
))
.*
setup
.
window
;
[
sig_targ
,
noise_targ
]
=
compute_snr_signals
(
SNR
,
sig_ref
,
noise3
,
work
.
expvaract
-
work
.
currentCalLevel
);
tuser1
=
(
sig_targ
(:,
1
)
+
noise_targ
(:,
1
))
.*
setup
.
window
;
tuser2
=
(
sig_targ
(:,
2
)
+
noise_targ
(:,
2
))
.*
setup
.
window
;
% pre-, post- and pausesignals (all zeros)
presig
=
zeros
(
def
.
presiglen
,
2
);
postsig
=
zeros
(
def
.
postsiglen
,
2
);
pausesig
=
zeros
(
def
.
pauselen
,
2
);
% make required fields in work
work
.
signal
=
[
tuser1
tuser2
tref11
tref12
tref21
tref22
];
% left = right (diotic) first two columns holds the test signal (left right)
work
.
presig
=
presig
;
% must contain the presignal
work
.
postsig
=
postsig
;
% must contain the postsignal
work
.
pausesig
=
pausesig
;
% must contain the pausesignal
% eof
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment