diff listeningTest/multiComp/MpushIc.m @ 0:4fd284285159

Adding listening test plus some helpful functions and scripts.
author Brecht <b.deman@qmul.ac.uk>
date Thu, 24 Apr 2014 23:53:31 +0100
parents
children 5e72201496c8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/listeningTest/multiComp/MpushIc.m	Thu Apr 24 23:53:31 2014 +0100
@@ -0,0 +1,58 @@
+function MpushIc(hf)
+
+sel=get(hf,'selectiontype');
+dat=get(hf,'userdata');
+drag=dat.drag;
+
+obj=get(gcf,'currentobject');
+sndId=get(obj,'userdata');
+
+switch sel
+    
+    case 'normal'
+        % BRECHT: log plays in response log
+        fidInd=['responses/' dat.sesDat.id,'_',dat.sesDat.sesScript];
+        fid=fopen(fidInd,'a');
+        fprintf(fid,'%i ', sndId);
+        dat.playVec(sndId,1) = 1; % check sample as 'played'
+        set(hf,'userdata',dat); % write dat away already here (avoid 'not all sounds played')
+        
+        set(dat.hIcon,'backgroundcolor',[.6 .9 .6]); % all icons turn green
+        if(obj<=dat.nbScale*(dat.nbSnd+4)+1) % value depends on number of sounds (avoid 'Stop Audio' becoming red)
+            set(obj,'backgroundcolor','r');
+        end
+        playSound(dat.sesDat.cuSndList(sndId));
+        
+        
+    case 'alt'		% right mouse (ctrl+button)
+        if drag
+            drag=0;
+        else
+            if dat.test.sndRef
+                if ~isempty(find(dat.test.sndRef==sndId))
+                    return
+                end
+            end
+            drag=1;
+        end
+        
+    case 'open'		% double-click % ?
+        % BRECHT: log plays in response log
+        fid=['responses/' dat.sesDat.id,'_',dat.sesDat.sesScript];
+        fprintf(fid,'%i', sndId);
+        dat.vector(sndId,1) = 1; % check sample as 'played'
+        
+        obj=get(gcf,'currentobject');
+        set(dat.hIcon,'backgroundcolor',[.6 .9 .6]);
+        set(obj,'backgroundcolor','r');
+        playSound(dat.sesDat.cuSndList(get(obj,'userdata')));
+        
+end
+
+saveMultiComp(hf);
+
+try % in case audio is still playing when finishing
+    dat.drag=drag;
+    set(hf,'userdata',dat);
+catch err
+end
\ No newline at end of file