diff multithreshold 1.46/nextStimulus.m @ 22:45f28c49461e master

removing duplicate changes
author Ray Meddis <rmeddis@essex.ac.uk>
date Mon, 13 Jun 2011 18:21:05 +0100
parents 8c7a18d89610
children 02aa9826efe0
line wrap: on
line diff
--- a/multithreshold 1.46/nextStimulus.m	Mon Jun 13 18:13:29 2011 +0100
+++ b/multithreshold 1.46/nextStimulus.m	Mon Jun 13 18:21:05 2011 +0100
@@ -82,7 +82,7 @@
 end
 
 set(handles.textMSG,'BackgroundColor','w', 'ForegroundColor', 'b')
-            
+
 % Now the serious business of crafting and presenting the stimulus
 errormsg= stimulusMakeAndPlay (handles);
 
@@ -314,6 +314,23 @@
     targetLevel=-100;	% no target
 end
 
+% ----------------------------- calibration of sound output
+calibrationCorrectiondB=stimulusParameters.calibrationdB;
+if calibrationCorrectiondB<-50
+    if maskerFrequency==targetFrequency
+        load 'calibrationFile'  % calibrationFrequency calibrationAttenutation
+        idx=find(calibrationFrequency==targetFrequency);
+        if isempty(idx)
+            error('Calibration bty file; frequency not found')
+        else
+            calibrationCorrectiondB=calibrationAttenutation(idx)
+        end
+    else
+        error('calibration by file requested but masker frequency is not the same as target')
+    end
+end
+
+
 % -------------------------------------- Checks on excessive signal level
 
 % clipping is relevant only for soundcard use (not modelling)
@@ -329,7 +346,7 @@
 switch experiment.ear
     case {'left', 'right', 'diotic',...
             'dichotic', 'dioticLeft', 'dichoticRight'}
-        clippingLevel=91+stimulusParameters.calibrationdB;
+        clippingLevel=91+calibrationCorrectiondB;
         soundCardMinimum=clippingLevel-20*log10(2^24);
     otherwise
         clippingLevel=inf;
@@ -366,7 +383,7 @@
             withinRuns.forceThreshold=NaN;
             return
         end
-                
+        
     case 'targetLevel'
         upperLevel=stimulusParameters.WRVlimits(2);
         lowerLevel=stimulusParameters.WRVlimits(1);
@@ -376,7 +393,7 @@
                     num2str(max(targetLevel, cueTargetLevel)) ...
                     ')  is too high ***'];
                 withinRuns.forceThreshold=upperLevel;
-            withinRuns.forceThreshold=NaN;
+                withinRuns.forceThreshold=NaN;
                 return
             end
             if max(targetLevel, cueTargetLevel)< lowerLevel
@@ -384,7 +401,7 @@
                     num2str(max(targetLevel, cueTargetLevel)) ...
                     ')  is too low ***'];
                 withinRuns.forceThreshold=lowerLevel;
-            withinRuns.forceThreshold=NaN;
+                withinRuns.forceThreshold=NaN;
                 return
             end
             if max(targetLevel, cueTargetLevel)> clippingLevel
@@ -392,10 +409,10 @@
                     num2str(max(targetLevel, cueTargetLevel)) ...
                     ')  is clipping ***'];
                 withinRuns.forceThreshold=upperLevel;
-            withinRuns.forceThreshold=NaN;
+                withinRuns.forceThreshold=NaN;
                 return
             end
-        end    
+        end
     case 'maskerDuration'
         % this is odd! but harmless
         if max(maskerDuration, cueMaskerDuration)> ...
@@ -493,7 +510,7 @@
 backgroundType=stimulusParameters.backgroundType;
 switch stimulusParameters.backgroundType
     case {'noiseDich', 'pinkNoiseDich'}
-%     case 'Dich'
+        %     case 'Dich'
         % dich means put the background in the ear opposite to the target
         backgroundType=backgroundType(1:end-4);
         switch targetEar
@@ -503,7 +520,7 @@
                 backgroundEar=1;
         end
     otherwise
-%             case {'none','noise', 'pinkNoise', 'TEN','babble'}
+        %             case {'none','noise', 'pinkNoise', 'TEN','babble'}
         backgroundEar=targetEar;
 end
 
@@ -515,9 +532,9 @@
 globalStimParams.dt=dt;
 stimulusParameters.dt=dt; % for use later
 
-% calibration of sound output
-correctiondB=stimulusParameters.calibrationdB;
-globalStimParams.audioOutCorrection=10^(correctiondB/20);
+
+
+globalStimParams.audioOutCorrection=10^(calibrationCorrectiondB/20);
 % the output will be reduced by this amount in stimulusCreate
 % i.e.  audio=audio/globalStimParams.audioOutCorrection
 % A 91 dB level will yield a peak amp of 1 for calibration=0
@@ -680,7 +697,7 @@
             'backgrounds and maskers'...
             filesep 'ten.wav'];
         [tenNoise, FS]=wavread(fileName);
-
+        
         tenNoise=resample(tenNoise, globalStimParams.FS, FS);
         stimComponents(backgroundEar,componentNo).type='file';
         stimComponents(backgroundEar,componentNo).stimulus=tenNoise';
@@ -705,8 +722,8 @@
             +stimulusParameters.maskerDuration;
         stimulusParameters.testTargetEnds=...
             stimulusParameters.testTargetBegins+withinRuns.variableValue;
-%     case 'SRT'
-%         set(handles.editdigitInput,'visible','off')
+        %     case 'SRT'
+        %         set(handles.editdigitInput,'visible','off')
     otherwise
         stimulusParameters.testTargetBegins=targetDelay;
         stimulusParameters.testTargetEnds=targetDelay+targetDuration;