Commit 50c9b8e6 authored by Joanna Luberadzka's avatar Joanna Luberadzka

added noise condition, noise signals, corrected detect function in the model

parent 77688e90
% autoexec_cfg generated by Configure AFC. Add your local preferences here. % autoexec_cfg generated by Configure AFC. Add your local preferences here.
def.language = 'EN'; def.language = 'EN';
% % directory with hrir data base:
% def.hrirdir='/home/hgproc/project/data/HRIRdatabase/';
%
% % directory with ollo data base:
% def.ollodir='/home/hgproc/project/data/OLLO2.0_NO/';
% directory with hrir data base:
def.hrirdir='/media/joanna/daten/user/joanna/Data/HRIR_HendrikKayser/';
% directory with ollo data base:
def.ollodir='/media/joanna/daten/user/joanna/Data/my_OLLO/OLLO_data/OLLO2.0_NO/';
addpath(def.hrirdir)
% Avoid warning about additional variables
def.variableCheck = 0;
% experimentDOA_cfg - example measurement configuration file - % experimentDOAMHA_cfg - example measurement configuration file -
% %
% This matlab skript is called by afc_main when starting % This matlab skript is called by afc_main when starting
% the experiment 'experimentDOA_cfg'. % the experiment 'experimentDOA_cfg'.
% %
% afc('main','experimentDOA','joa','10deg','ollo_male','white'); % afc('main','experimentDOA','joa',90,5,'ollo_male','noproc','white');
% %
% experimentDOA_cfg constructs a structure 'def' containing the complete % experimentDOA_cfg constructs a structure 'def' containing the complete
% configuration for the experiment. % configuration for the experiment.
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
% Copyright (c) 1999-2013 Stephan Ewert. % Copyright (c) 1999-2013 Stephan Ewert.
% directory with hrir data base:
def.hrirdir='/media/joanna/daten/user/joanna/Data/HRIR_HendrikKayser/';
% directory with ollo data base:
def.ollodir='/media/joanna/daten/user/joanna/Data/my_OLLO/OLLO_data/OLLO2.0_NO/';
% general measurement procedure % general measurement procedure
def.measurementProcedure = 'transformedUpDown'; % measurement procedure def.measurementProcedure = 'transformedUpDown'; % measurement procedure
def.intervalnum = 3; % number of intervals def.intervalnum = 3; % number of intervals
...@@ -38,14 +33,14 @@ def.expvardescription = 'signal level'; % description of the tracking variable ...@@ -38,14 +33,14 @@ def.expvardescription = 'signal level'; % description of the tracking variable
% limits for experimental variable % limits for experimental variable
def.minvar = -100; % minimum value of the tracking variable def.minvar = -100; % minimum value of the tracking variable
def.maxvar = 100; % maximum value of the tracking variable def.maxvar = 55; % maximum value of the tracking variable
def.terminate = 1; % terminate execution on min/maxvar hit: 0 = warning, 1 = terminate def.terminate = 1; % terminate execution on min/maxvar hit: 0 = warning, 1 = terminate
def.endstop = 3; % Allows x nominal levels higher/lower than the limits before terminating (if def.terminate = 1) def.endstop = 3; % Allows x nominal levels higher/lower than the limits before terminating (if def.terminate = 1)
% experimental parameter (independent variable) % experimental parameter (independent variable)
def.exppar1 = [0 45 90]; % vector containing experimental parameters for which the exp is performed %def.exppar1 = [0 45 90]; % vector containing experimental parameters for which the exp is performed
def.exppar1unit = 'deg'; % unit of experimental parameter %def.exppar1unit = 'deg'; % unit of experimental parameter
def.exppar1description = 'reference angle';% description of the experimental parameter %def.exppar1description = 'reference angle';% description of the experimental parameter
% experimental parameter 2...N (independent variable) % experimental parameter 2...N (independent variable)
% add here if required % add here if required
...@@ -63,20 +58,20 @@ def.control_path = ''; % where to save control files ...@@ -63,20 +58,20 @@ def.control_path = ''; % where to save control files
def.savefcn = 'default'; % function which writes results to disk def.savefcn = 'default'; % function which writes results to disk
% samplerate and sound output % samplerate and sound output
def.samplerate = 48000; % sampling rate in Hz def.samplerate = 44100; % sampling rate in Hz
def.intervallen = 53234; % length of each signal-presentation interval in samples (might be overloaded in 'expname_set') def.intervallen = 1.1.*def.samplerate; % length of each signal-presentation interval in samples (might be overloaded in 'expname_set')
def.pauselen = 22050; % length of pauses between signal-presentation intervals in samples (might be overloaded in 'expname_set') def.pauselen = def.samplerate/2; % length of pauses between signal-presentation intervals in samples (might be overloaded in 'expname_set')
def.presiglen = 100; % length of signal leading the first presentation interval in samples (might be overloaded in 'expname_set') def.presiglen = round(.002 * def.samplerate); % length of signal leading the first presentation interval in samples (might be overloaded in 'expname_set')
def.postsiglen = 100; % length of signal following the last presentation interval in samples (might be overloaded in 'expname_set') def.postsiglen = def.presiglen; % length of signal following the last presentation interval in samples (might be overloaded in 'expname_set')
def.bits = 16; % output bit depth: 8 or 16 see def.externSoundCommand for 32 bits def.bits = 16; % output bit depth: 8 or 16 see def.externSoundCommand for 32 bits
% computing % computing
def.allowpredict = 0; % if 1 generate new stimuli during sound output if def.markinterval disabled def.allowpredict = 0; % if 1 generate new stimuli during sound output if def.markinterval disabled
% def.markIntervalDelay = 0;
% tweaking % tweaking
%def.keyboardResponseButtonMapping = {'a','s','d'}; %def.keyboardResponseButtonMapping = {'a','s','d'};
%def.soundmexMark = 1; %def.soundmexMark = 1;
%def.markinterval = 1; def.markinterval = 0;
%def.internSoundCommand = 'sound'; %def.internSoundCommand = 'sound';
%def.internSoundCommand = 'wavplay'; %def.internSoundCommand = 'wavplay';
......
...@@ -26,21 +26,21 @@ global def ...@@ -26,21 +26,21 @@ global def
global work global work
global setup global setup
addpath(genpath(def.hrirdir))
% conditions are specified in each run by: % conditions are specified in each run by:
% afc('main','experimentDOA','subject','5deg','ollo_female','white') % afc('main','experimentDOA','subject','135','10','ollo_female','white')
% Condition 1 % Input argument 4
switch work.userpar1 setup.ref_angle=str2double(work.userpar1);
case '5deg' % setup.ref_angle=def.exppar1;
setup.degdiff=5;
case '10deg' % Input argument 5
setup.degdiff=10; setup.degdiff=str2double(work.userpar2);
otherwise
error('condition not recognized');
end
% Condition 2
switch work.userpar2 % Input argument 6
switch work.userpar3
case 'ollo_female' case 'ollo_female'
setup.filedir=[def.ollodir,'S01F_NO/']; setup.filedir=[def.ollodir,'S01F_NO/'];
case 'ollo_male' case 'ollo_male'
...@@ -49,14 +49,33 @@ otherwise ...@@ -49,14 +49,33 @@ otherwise
error('condition not recognized'); error('condition not recognized');
end end
% Condition 3
% create a cell array which has the same lenght as
% the number of referece angles that we want to test
if iscell(setup.ref_angle);setup.ref_angle=cell2mat(setup.ref_angle);end
setup.HRIRs=cell(length(setup.ref_angle),1); % [0 45 90];
for k=1:length(setup.HRIRs)
def.outputChannels=2;
%load the hrir for the reference angle
setup.HRIRs{k}.hrir_ref=loadHRIR('Anechoic', 300, 0, setup.ref_angle(k),'in-ear')
%load the hrirs for the angle 5° away from the reference angle
setup.HRIRs{k}.hrir_refplus=loadHRIR('Anechoic', 300, 0, setup.ref_angle(k)+setup.degdiff,'in-ear')
setup.HRIRs{k}.hrir_refminus=loadHRIR('Anechoic', 300, 0, setup.ref_angle(k)-setup.degdiff,'in-ear')
end
% Condition 4
switch work.condition switch work.condition
case 'babble' case 'cohnoise'
setup.noise=audioread('.wav'); setup.noise=audioread('../coherentNoise_-160_Sig_inEar.wav');
case 'white' case 'white'
n1=randn(10*def.samplerate,1); for c=1:def.outputChannels
n2=randn(10*def.samplerate,1); setup.noise(:,c)=randn(10*def.samplerate,1);
setup.noise=[n1 n2]; end
case 'diffuse'
setup.noise=audioread('../diffuseNoise_Sig_inEar.wav');
otherwise otherwise
error('condition not recognized'); error('condition not recognized');
end end
...@@ -71,19 +90,6 @@ setup.level=40; ...@@ -71,19 +90,6 @@ setup.level=40;
filePattern =[setup.filedir,'*.wav']; filePattern =[setup.filedir,'*.wav'];
setup.waveFiles = dir(filePattern); setup.waveFiles = dir(filePattern);
% add path with the hrir data base
addpath(genpath(def.hrirdir))
% create a cell array which has the same lenght as
% the number of referece angles that we want to test
if iscell(def.exppar1);def.exppar1=cell2mat(def.exppar1);end
setup.HRIRs=cell(length(def.exppar1),1); % [0 45 90];
for k=1:length(setup.HRIRs)
%load the hrir for the reference angle
setup.HRIRs{k}.hrir_ref=loadHRIR('Anechoic', 300, 0, def.exppar1(k),'in-ear')
%load the hrirs for the angle 5° away from the reference angle
setup.HRIRs{k}.hrir_refplus=loadHRIR('Anechoic', 300, 0, def.exppar1(k)+setup.degdiff,'in-ear')
setup.HRIRs{k}.hrir_refminus=loadHRIR('Anechoic', 300, 0, def.exppar1(k)-setup.degdiff,'in-ear')
end
% eof % eof
\ No newline at end of file
% experimentDOA_user - stimulus generation function of experiment 'example' - % experimentDOAMHA_user - stimulus generation function of experiment 'example' -
% %
% This function is called by afc_main when starting % This function is called by afc_main when starting
% the experiment 'experimentDOA'. It generates the stimuli which % the experiment 'experimentDOA'. It generates the stimuli which
...@@ -35,7 +35,8 @@ disp(num2str(work.expvaract)) ...@@ -35,7 +35,8 @@ disp(num2str(work.expvaract))
% -------------CHOOSE HRIRS ---------------- % -------------CHOOSE HRIRS ----------------
% * find which reference angle is currently tested % * find which reference angle is currently tested
% * randomly choose +or- 5° or 10° % * randomly choose +or- 5° or 10°
indx=find(def.exppar1==work.exppar1); indx=1;%find(def.exppar1==work.exppar1);
hrir_fs=setup.HRIRs{indx}.hrir_ref.fs;
hrir_ref=setup.HRIRs{indx}.hrir_ref.data; hrir_ref=setup.HRIRs{indx}.hrir_ref.data;
plusorminus=round(rand);%0 or 1 plusorminus=round(rand);%0 or 1
if plusorminus==1 if plusorminus==1
...@@ -54,19 +55,17 @@ fullWavFileName = fullfile([setup.filedir, baseWavFileName]); ...@@ -54,19 +55,17 @@ fullWavFileName = fullfile([setup.filedir, baseWavFileName]);
[sig, fssig]=audioread(fullWavFileName); [sig, fssig]=audioread(fullWavFileName);
% resample the signal % resample the signal
% [P,Q] = rat(def.samplerate/fssig); sig=resample(sig,def.samplerate,fssig);
% sig=resample(sig,P,Q);
% resample the impulse response % resample the impulse response
[P,Q] = rat(fssig/def.samplerate); hrir_ref=resample(hrir_ref,def.samplerate,hrir_fs);
hrir_ref=resample(hrir_ref,P,Q); hrir_targ=resample(hrir_targ,def.samplerate,hrir_fs);
hrir_targ=resample(hrir_targ,P,Q);
% convolve signals with IRs % convolve speech signal with IRs
sig_ref(:,1)=conv(sig,hrir_ref(:,1)); for c=1:def.outputChannels
sig_ref(:,2)=conv(sig,hrir_ref(:,2)); sig_ref(:,c)=conv(sig,hrir_ref(:,c));
sig_targ(:,1)=conv(sig,hrir_targ(:,1)); sig_targ(:,c)=conv(sig,hrir_targ(:,c));
sig_targ(:,2)=conv(sig,hrir_targ(:,2)); end
%-------------- NOISE ----------------- %-------------- NOISE -----------------
...@@ -93,20 +92,19 @@ sig_targ=set_level(sig_targ, work.expvaract-work.currentCalLevel); ...@@ -93,20 +92,19 @@ sig_targ=set_level(sig_targ, work.expvaract-work.currentCalLevel);
setup.hannlen = round(0.05*def.samplerate); setup.hannlen = round(0.05*def.samplerate);
setup.window = hannfl(L,setup.hannlen,setup.hannlen); setup.window = hannfl(L,setup.hannlen,setup.hannlen);
% signal + noise % signal + noise
tref11=(sig_ref(:,1)+noise1(:,1)).* setup.window; for c=1:def.outputChannels
tref12=(sig_ref(:,2)+noise1(:,2)).* setup.window; tref1(:,c)=(sig_ref(:,c)+noise1(:,c)).* setup.window;
tref21=(sig_ref(:,1)+noise2(:,1)).* setup.window; tref2(:,c)=(sig_ref(:,c)+noise2(:,c)).* setup.window;
tref22=(sig_ref(:,2)+noise2(:,2)).* setup.window; tuser(:,c)=(sig_targ(:,c)+noise3(:,c)).* setup.window;
tuser1=(sig_targ(:,1)+noise3(:,1)).* setup.window; end
tuser2=(sig_targ(:,2)+noise3(:,2)).* setup.window;
% pre-, post- and pausesignals (all zeros) % pre-, post- and pausesignals (all zeros)
presig = zeros(def.presiglen,2); presig = zeros(def.presiglen, def.outputChannels);
postsig = zeros(def.postsiglen,2); postsig = zeros(def.postsiglen, def.outputChannels);
pausesig = zeros(def.pauselen,2); pausesig = zeros(def.pauselen, def.outputChannels);
% make required fields in work % 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.signal = [tuser tref1 tref2];% left = right (diotic) first two columns holds the test signal (left right)
work.presig = presig; % must contain the presignal work.presig = presig; % must contain the presignal
work.postsig = postsig; % must contain the postsignal work.postsig = postsig; % must contain the postsignal
work.pausesig = pausesig; % must contain the pausesignal work.pausesig = pausesig; % must contain the pausesignal
......
...@@ -14,16 +14,18 @@ for i=1:def.intervalnum ...@@ -14,16 +14,18 @@ for i=1:def.intervalnum
simwork.DOA(i) = eval([work.vpname '_preproc(simwork.tmpSig(:,2*i-1:2*i))']); % actual sig processing simwork.DOA(i) = eval([work.vpname '_preproc(simwork.tmpSig(:,2*i-1:2*i))']); % actual sig processing
end end
if unique(simwork.DOA)==1 if length(unique(simwork.DOA))==1
response=3; response=randi(3);
else else
where=simwork.DOA(1)-simwork.DOA(2:3); where=simwork.DOA(1)-simwork.DOA(2:3);
if where(1)==where(2) if where(1)==where(2)
response=1; response=1;
elseif where(1)==0 elseif where(1)==0
response=3; response=3;
elseif where(1)==0 elseif where(2)==0
response=2; response=2;
elseif where(1)~=where(2)
response=randi(3);
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment