Commit b331a830 authored by Joanna Luberadzka's avatar Joanna Luberadzka

started preparing the scripts for the afc experiment with distinguishing between angles

parent 0ebb9004
% example_cfg - example measurement configuration file -
% experimentDOA_cfg - example measurement configuration file -
%
% This matlab skript is called by afc_main when starting
% the experiment 'example'.
% example_cfg constructs a structure 'def' containing the complete
% the experiment 'experimentDOA_cfg'.
% experimentDOA_cfg constructs a structure 'def' containing the complete
% configuration for the experiment.
% To design an own experiment, e.g., 'myexperiment'
% make changes in this file and save it as 'myexperiment_cfg.m'.
% The default values of all parameters are defined in 'default_cfg.m'
%
% See also help example_set, example_user, afc_main
% See also help experimentDOA_set, experimentDOA_user, afc_main
%
% 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
......@@ -34,7 +39,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 30 60 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.exppar1description = 'reference angle';% description of the experimental parameter
......
......@@ -20,15 +20,17 @@
%
% See also help example_cfg, example_user, afc_main
function example_set
function experimentDOA_set
global def
global work
global setup
% make condition dependend entries in structure set
% conditions are specified in each run by:
% afc('main','experimentDOA','subject','5deg','female','babble')
switch work.condition
% Condition 1
switch work.userpar1
case '5deg'
setup.degdiff=5;
case '10deg'
......@@ -37,17 +39,58 @@ otherwise
error('condition not recognized');
end
% Condition 2
switch work.userpar2
case 'ollo_female'
setup.filedir=[def.ollodir,'S01F_NO/'];
case 'ollo_male'
setup.filedir=[def.ollodir,'S02M_NO/'];
otherwise
error('condition not recognized');
end
% Condition 3
switch work.condition
case 'babble'
setup.noise=audioread('.wav');
case 'white'
setup.noise=randn(2,10*def.samplerate);
otherwise
error('condition not recognized');
end
% define the calibration level (assume 90 dB SPL for 0 dB FS)
work.currentCalLevel = 100;
% % define signals in structure setup
% define signals in structure setup
% setup.modsine = sin([0:def.intervallen-1]'*2*pi*work.exppar1/def.samplerate);
% setup.hannlen = round(0.05*def.samplerate);
% setup.window = hannfl(def.intervallen,setup.hannlen,setup.hannlen);
setup.hannlen = round(0.05*def.samplerate);
setup.window = hannfl(def.intervallen,setup.hannlen,setup.hannlen);
% make a list of files from which one file should be
% randomly chosen in each trial
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
setup.HRIRs=cell(length(def.exppar1),1)
for k=1:lenght(setup.HRIRs)
%load the hrir for the reference angle
setup.HRIRs{k}.hrir_ref=loadHRIR('Anechoic', 80, 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', 80, 0, def.exppar1(k)+setup.degdiff,'in-ear')
setup.HRIRs{k}.hrir_refminus=loadHRIR('Anechoic', 80, 0, def.exppar1(k)-setup.degdiff,'in-ear')
end
setup.refsig
setup.sigplus
setup.sigminus
% eof
\ No newline at end of file
......@@ -27,7 +27,7 @@
%
% See also help example_cfg, example_set, afc_main
function example_user
function experimentDOA_user
global def
global work
......@@ -38,16 +38,64 @@ global setup
% One signal holds the target amplitude modulation.
% work.expvaract holds the current value of the tracking variable of the experiment.
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));
% Hanning windows
tref1 = tref1 .* setup.window;
tref2 = tref2 .* setup.window;
tuser = tuser .* setup.window;
% load a random wav file for this trial
numberOfFiles = length(setup.waveFiles);
fileToPlay = randi(numberOfFiles, 1);
baseWavFileName = setup.waveFiles(fileToPlay).name;
fullWavFileName = fullfile([def.ollodir, baseWavFileName]);
[sig fssig]=audioread(fullWavFileName);
% resample the signal
[P,Q] = rat(def.samplerate/fssig);
sig=resample(sig,P,Q);
% choose hrir:
% * find which reference angle is currently tested
% * randomly choose +or- 5or10 deg
indx=find(def.exppar==work.exppar1);
hrir_ref=setup.HRIRs{indx}.hrir_ref;
plusorminus=randi(2)
if plusorminus==1
hrir_targ=setup.HRIRs{indx}.hrir_refplus;
elseif plusorminus==2
hrir_targ=setup.HRIRs{indx}.hrir_refminus;
end
% convolve signals
sig_ref(1,:)=conv(sig(1,:),hrir_ref(1,:));
sig_ref(2,:)=conv(sig(2,:),hrir_ref(2,:));
sig_targ(1,:)=conv(sig(1,:),hrir_targ(1,:));
sig_targ(2,:)=conv(sig(1,:),hrir_targ(1,:));
%here scale the noise so that it has level according
% to the current tracking variable work.expvaract
% provide 3 randomly cut excerpts of noise
L=length(sig)+length(hrir_targ)-1;
sig_noise1=noise(randi(length(noise)):randi(length(noise))+L)
sig_noise2=noise(randi(length(noise)):randi(length(noise))+L)
sig_noise3=noise(randi(length(noise)):randi(length(noise))+L)
% 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));
tref11=(sig_ref(1,:)+sig_noise1).* setup.window;
tref12=(sig_ref(2,:)+sig_noise1).* setup.window;
tref21=(sig_ref(1,:)+sig_noise2).* setup.window;
tref22=(sig_ref(2,:)+sig_noise2).* setup.window;
tuser1=(sig_targ(1,:)+sig_noise3).* setup.window;
tuser2=(sig_targ(2,:)+sig_noise3).* setup.window;
% pre-, post- and pausesignals (all zeros)
......@@ -57,7 +105,7 @@ pausesig = zeros(def.pauselen,2);
% make required fields in work
work.signal = [tuser tuser tref1 tref1 tref2 tref2]; % left = right (diotic) first two columns holds the test signal (left right)
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
......
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