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.
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
% 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
% configuration for the experiment.
......@@ -16,11 +16,6 @@
% 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
def.measurementProcedure = 'transformedUpDown'; % measurement procedure
def.intervalnum = 3; % number of intervals
......@@ -38,14 +33,14 @@ def.expvardescription = 'signal level'; % description of the tracking variable
% limits for experimental 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.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 90]; % 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
%def.exppar1 = [0 45 90]; % 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
% experimental parameter 2...N (independent variable)
% add here if required
......@@ -63,20 +58,20 @@ def.control_path = ''; % where to save control files
def.savefcn = 'default'; % function which writes results to disk
% samplerate and sound output
def.samplerate = 48000; % sampling rate in Hz
def.intervallen = 53234; % 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.presiglen = 100; % 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.samplerate = 44100; % sampling rate in Hz
def.intervallen = 1.1.*def.samplerate; % length of each signal-presentation interval 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 = round(.002 * def.samplerate); % length of signal leading the first 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
% computing
def.allowpredict = 0; % if 1 generate new stimuli during sound output if def.markinterval disabled
% def.markIntervalDelay = 0;
% tweaking
%def.keyboardResponseButtonMapping = {'a','s','d'};
%def.soundmexMark = 1;
%def.markinterval = 1;
def.markinterval = 0;
%def.internSoundCommand = 'sound';
%def.internSoundCommand = 'wavplay';
......
......@@ -26,21 +26,21 @@ global def
global work
global setup
addpath(genpath(def.hrirdir))
% conditions are specified in each run by:
% afc('main','experimentDOA','subject','5deg','ollo_female','white')
% Condition 1
switch work.userpar1
case '5deg'
setup.degdiff=5;
case '10deg'
setup.degdiff=10;
otherwise
error('condition not recognized');
end
% afc('main','experimentDOA','subject','135','10','ollo_female','white')
% Input argument 4
setup.ref_angle=str2double(work.userpar1);
% setup.ref_angle=def.exppar1;
% Input argument 5
setup.degdiff=str2double(work.userpar2);
% Condition 2
switch work.userpar2
% Input argument 6
switch work.userpar3
case 'ollo_female'
setup.filedir=[def.ollodir,'S01F_NO/'];
case 'ollo_male'
......@@ -49,14 +49,33 @@ otherwise
error('condition not recognized');
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
case 'babble'
setup.noise=audioread('.wav');
case 'cohnoise'
setup.noise=audioread('../coherentNoise_-160_Sig_inEar.wav');
case 'white'
n1=randn(10*def.samplerate,1);
n2=randn(10*def.samplerate,1);
setup.noise=[n1 n2];
for c=1:def.outputChannels
setup.noise(:,c)=randn(10*def.samplerate,1);
end
case 'diffuse'
setup.noise=audioread('../diffuseNoise_Sig_inEar.wav');
otherwise
error('condition not recognized');
end
......@@ -71,19 +90,6 @@ setup.level=40;
filePattern =[setup.filedir,'*.wav'];
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
\ 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
% the experiment 'experimentDOA'. It generates the stimuli which
......@@ -35,7 +35,8 @@ disp(num2str(work.expvaract))
% -------------CHOOSE HRIRS ----------------
% * find which reference angle is currently tested
% * 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;
plusorminus=round(rand);%0 or 1
if plusorminus==1
......@@ -54,19 +55,17 @@ fullWavFileName = fullfile([setup.filedir, baseWavFileName]);
[sig, fssig]=audioread(fullWavFileName);
% resample the signal
% [P,Q] = rat(def.samplerate/fssig);
% sig=resample(sig,P,Q);
sig=resample(sig,def.samplerate,fssig);
% resample the impulse response
[P,Q] = rat(fssig/def.samplerate);
hrir_ref=resample(hrir_ref,P,Q);
hrir_targ=resample(hrir_targ,P,Q);
hrir_ref=resample(hrir_ref,def.samplerate,hrir_fs);
hrir_targ=resample(hrir_targ,def.samplerate,hrir_fs);
% convolve signals with IRs
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));
% convolve speech signal with IRs
for c=1:def.outputChannels
sig_ref(:,c)=conv(sig,hrir_ref(:,c));
sig_targ(:,c)=conv(sig,hrir_targ(:,c));
end
%-------------- NOISE -----------------
......@@ -93,20 +92,19 @@ sig_targ=set_level(sig_targ, work.expvaract-work.currentCalLevel);
setup.hannlen = round(0.05*def.samplerate);
setup.window = hannfl(L,setup.hannlen,setup.hannlen);
% signal + noise
tref11=(sig_ref(:,1)+noise1(:,1)).* setup.window;
tref12=(sig_ref(:,2)+noise1(:,2)).* setup.window;
tref21=(sig_ref(:,1)+noise2(:,1)).* setup.window;
tref22=(sig_ref(:,2)+noise2(:,2)).* setup.window;
tuser1=(sig_targ(:,1)+noise3(:,1)).* setup.window;
tuser2=(sig_targ(:,2)+noise3(:,2)).* setup.window;
for c=1:def.outputChannels
tref1(:,c)=(sig_ref(:,c)+noise1(:,c)).* setup.window;
tref2(:,c)=(sig_ref(:,c)+noise2(:,c)).* setup.window;
tuser(:,c)=(sig_targ(:,c)+noise3(:,c)).* setup.window;
end
% pre-, post- and pausesignals (all zeros)
presig = zeros(def.presiglen,2);
postsig = zeros(def.postsiglen,2);
pausesig = zeros(def.pauselen,2);
presig = zeros(def.presiglen, def.outputChannels);
postsig = zeros(def.postsiglen, def.outputChannels);
pausesig = zeros(def.pauselen, def.outputChannels);
% 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.postsig = postsig; % must contain the postsignal
work.pausesig = pausesig; % must contain the pausesignal
......
......@@ -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
end
if unique(simwork.DOA)==1
response=3;
if length(unique(simwork.DOA))==1
response=randi(3);
else
where=simwork.DOA(1)-simwork.DOA(2:3);
if where(1)==where(2)
response=1;
elseif where(1)==0
response=3;
elseif where(1)==0
elseif where(2)==0
response=2;
elseif where(1)~=where(2)
response=randi(3);
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