changeset 2592:89f787e2e90c

Merge branch 'vnext' into Dev_main # Conflicts: # tests/examples/mushra_example.xml
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Wed, 09 Nov 2016 13:49:45 +0000
parents 373b8ecf9476 (current diff) c0854362d09d (diff)
children 9bb878bf41d8
files js/core.js tests/examples/AB_example.xml tests/examples/APE_example.xml tests/examples/mushra_example.xml
diffstat 2 files changed, 122 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Sat Nov 05 11:21:54 2016 +0000
+++ b/js/core.js	Wed Nov 09 13:49:45 2016 +0000
@@ -1678,22 +1678,21 @@
             } else {
                 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]);
             }
+            var setTime = audioContext.currentTime;
             if (this.synchPlayback && this.loopPlayback) {
                 // Traditional looped playback
-                var setTime = audioContext.currentTime + specification.crossFade;
                 for (var i = 0; i < this.audioObjects.length; i++) {
                     this.audioObjects[i].play(audioContext.currentTime);
                     if (id == i) {
                         this.audioObjects[i].loopStart(setTime);
                     } else {
-                        this.audioObjects[i].loopStop(setTime);
+                        this.audioObjects[i].loopStop(setTime + specification.crossFade);
                     }
                 }
             } else {
-                var setTime = audioContext.currentTime + specification.crossFade;
                 for (var i = 0; i < this.audioObjects.length; i++) {
                     if (i != id) {
-                        this.audioObjects[i].stop(setTime);
+                        this.audioObjects[i].stop(setTime + specification.crossFade);
                     } else if (i == id) {
                         this.audioObjects[id].play(setTime);
                     }
@@ -1938,10 +1937,10 @@
             this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
             if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) {
                 this.metric.startListening(audioEngineContext.timer.getTestTime());
-                this.outputGain.gain.setValueAtTime(this.onplayGain, startTime);
+                this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, startTime + specification.crossFade);
                 this.interfaceDOM.startPlayback();
             } else {
-                this.outputGain.gain.setValueAtTime(0.0, startTime);
+                this.outputGain.gain.linearRampToValueAtTime(0.0, startTime);
             }
             if (audioEngineContext.loopPlayback) {
                 this.bufferNode.loopStart = this.specification.startTime || 0;
@@ -1961,7 +1960,7 @@
             this.bufferNode.stop(stopTime);
             this.bufferNode = undefined;
         }
-        this.outputGain.gain.setValueAtTime(0.0, stopTime);
+        this.outputGain.gain.linearRampToValueAtTime(0.0, stopTime);
         this.interfaceDOM.stopPlayback();
     };
 
--- a/python/generate_report.py	Sat Nov 05 11:21:54 2016 +0000
+++ b/python/generate_report.py	Wed Nov 09 13:49:45 2016 +0000
@@ -64,6 +64,10 @@
 gender = []
 age    = []
 
+# diagnostics
+browser  = []
+platform = []
+
 # get username if available
 for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
     user = os.environ.get(name)
@@ -162,6 +166,20 @@
         individual_table = '\n' # table with stats for this individual test file
         timeline_plots = '' # plots of timeline (movements and plays)
         
+        # diagnostics: browser
+        vendor = root.find("./navigator/vendor")
+        if vendor is not None and vendor.text is not None:
+            browser.append(vendor.text.replace(',',''))
+        else:
+            browser.append('UNAVAILABLE')
+
+        # diagnostics: platform
+        platform_tag = root.find("./navigator/platform")
+        if platform_tag is not None and platform_tag.text is not None:
+            platform.append(platform_tag.text.replace('_','\_'))
+        else:
+            platform_tag.append('UNAVAILABLE')
+
         # DEMO survey stats
         # get gender
         post_survey = root.find("./survey/[@location='post']")
@@ -535,6 +553,104 @@
         '''
 # problem: some people entered twice? 
 
+
+# pie chart of browser usage
+browsers = ['Google Inc.', 'Apple Computer Inc.', 'UNAVAILABLE']
+# TODO: get the above automatically
+browser_distribution = ''
+for item in browsers:
+    number = browser.count(item)
+    if number>0:
+        browser_distribution += str("{:.2f}".format((100.0*number)/len(browser)))+\
+                               '/'+item.capitalize()+' ('+str(number)+'),\n'
+
+body += r'''
+        % Pie chart of browser distribution
+        \def\angle{0}
+        \def\radius{3}
+        \def\cyclelist{{"orange","blue","red","green"}}
+        \newcount\cyclecount \cyclecount=-1
+        \newcount\ind \ind=-1
+        \begin{figure}[htbp]
+        \begin{center}\begin{tikzpicture}[nodes = {font=\sffamily}]
+        \foreach \percent/\name in {'''+\
+        browser_distribution+\
+        r'''} {\ifx\percent\empty\else               % If \percent is empty, do nothing
+        \global\advance\cyclecount by 1     % Advance cyclecount
+        \global\advance\ind by 1            % Advance list index
+        \ifnum6<\cyclecount                 % If cyclecount is larger than list
+          \global\cyclecount=0              %   reset cyclecount and
+          \global\ind=0                     %   reset list index
+        \fi
+        \pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list
+        \edef\color{\pgfmathresult}         %   and store as \color
+        % Draw angle and set labels
+        \draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius)
+          arc (\angle:\angle+\percent*3.6:\radius) -- cycle;
+        \node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%};
+        \node[pin=\angle+0.5*\percent*3.6:\name]
+          at (\angle+0.5*\percent*3.6:\radius) {};
+        \pgfmathparse{\angle+\percent*3.6}  % Advance angle
+        \xdef\angle{\pgfmathresult}         %   and store in \angle
+        \fi
+        };
+        \end{tikzpicture}
+        \caption{Representation of browsers across subjects}
+        \label{default}
+        \end{center}
+        \end{figure}
+        
+        '''
+
+# pie chart of platform usage
+platforms = ['Win32', 'Win64', 'MacIntel', 'Linux i686', 'Linux x86\_64', 'UNAVAILABLE']
+# TODO: get the above automatically # order alphabetically
+platform_distribution = ''
+for item in platforms:
+    number = platform.count(item)
+    if number>0:
+        platform_distribution += str("{:.2f}".format((100.0*number)/len(platform)))+\
+                               '/'+item.capitalize()+' ('+str(number)+'),\n'
+
+body += r'''
+        % Pie chart of browser distribution
+        \def\angle{0}
+        \def\radius{3}
+        \def\cyclelist{{"orange","blue","red","green","cyan"}}
+        \newcount\cyclecount \cyclecount=-1
+        \newcount\ind \ind=-1
+        \begin{figure}[htbp]
+        \begin{center}\begin{tikzpicture}[nodes = {font=\sffamily}]
+        \foreach \percent/\name in {'''+\
+        platform_distribution+\
+        r'''} {\ifx\percent\empty\else               % If \percent is empty, do nothing
+        \global\advance\cyclecount by 1     % Advance cyclecount
+        \global\advance\ind by 1            % Advance list index
+        \ifnum6<\cyclecount                 % If cyclecount is larger than list
+          \global\cyclecount=0              %   reset cyclecount and
+          \global\ind=0                     %   reset list index
+        \fi
+        \pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list
+        \edef\color{\pgfmathresult}         %   and store as \color
+        % Draw angle and set labels
+        \draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius)
+          arc (\angle:\angle+\percent*3.6:\radius) -- cycle;
+        \node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%};
+        \node[pin=\angle+0.5*\percent*3.6:\name]
+          at (\angle+0.5*\percent*3.6:\radius) {};
+        \pgfmathparse{\angle+\percent*3.6}  % Advance angle
+        \xdef\angle{\pgfmathresult}         %   and store in \angle
+        \fi
+        };
+        \end{tikzpicture}
+        \caption{Representation of platforms across subjects}
+        \label{default}
+        \end{center}
+        \end{figure}
+        
+        '''
+
+
 #TODO
 # time per page in function of number of fragments (plot)
 # time per participant in function of number of pages