annotate docs/Instructions/BuildingInterface.tex @ 1942:4988c805ff9e

Update to WAC paper references
author Dave Moffat <me@davemoffat.com>
date Thu, 24 Sep 2015 09:49:01 +0100
parents
children
rev   line source
me@1942 1 \documentclass[11pt, oneside]{article} % use "amsart" instead of "article" for AMSLaTeX format
me@1942 2 \usepackage[margin=2cm]{geometry} % See geometry.pdf to learn the layout options. There are lots.
me@1942 3 \geometry{letterpaper} % ... or a4paper or a5paper or ...
me@1942 4 %\geometry{landscape} % Activate for rotated page geometry
me@1942 5 \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
me@1942 6 \usepackage{graphicx} % Use pdf, png, jpg, or eps§ with pdflatex; use eps in DVI mode
me@1942 7 % TeX will automatically convert eps --> pdf in pdflatex
me@1942 8
me@1942 9 \usepackage{listings} % Source code
me@1942 10 \usepackage{amssymb}
me@1942 11 \usepackage{cite}
me@1942 12 \usepackage{hyperref} % Hyperlinks
me@1942 13
me@1942 14
me@1942 15 \graphicspath{{img/}} % Relative path where the images are stored.
me@1942 16
me@1942 17 \title{Building your own Interface for\\ Web Audio Evaluation Tool}
me@1942 18 \author{Nicholas Jillings}
me@1942 19 \date{} % Activate to display a given date or no date
me@1942 20
me@1942 21 \begin{document}
me@1942 22 \maketitle
me@1942 23
me@1942 24 \section{Introduction}
me@1942 25 This guide will help you to construct your own interface on top of the WAET (Web Audio Evaluation Tool) engine. The WAET engine resides in the core.js file, this contains prototype objects to handle most of the test creation, operation and data collection. The interface simply has to link into this at the correct points.
me@1942 26
me@1942 27 \subsection{Nodes to familiarise}
me@1942 28 Core.js handles several very important nodes which you should become familiar with. The first is the Audio Engine, initialised and stored in variable 'AudioEngineContext'. This handles the playback of the web audio nodes as well as storing the 'AudioObjects'. The 'AudioObjects' are custom nodes which hold the audio fragments for playback. These nodes also have a link to two interface objects, the comment box if enabled and the interface providing the ranking. On creation of an 'AudioObject' the interface link will be nulled, it is up to the interface to link these correctly.
me@1942 29
me@1942 30 The specification document will be decoded and parsed into an object called 'specification'. This will hold all of the specifications various nodes. The test pages and any pre/post test objects are processed by a test state which will proceed through the test when called to by the interface. Any checks (such as playback or movement checks) are to be completed by the interface before instructing the test state to proceed. The test state will call the interface on each page load with the page specification node.
me@1942 31
me@1942 32 \subsection{Modifying Core.js}
me@1942 33 Whilst there is very little code actually needed, you do need to instruct core.js to load your interface file when called for from a specification node. There is a function called 'loadProjectSpecCallback' which handles the decoding of the specification and setting any external items (such as metric collection). At the very end of this function there is an if statement, add to this list with your interface string to link to the source. There is an example in there for both the APE and MUSHRA tests already included. Note: Any updates to core.js in future work will most likely overwrite your changes to this file, so remember to check your interface is still here after any update that interferes with core.js.
me@1942 34 Any further files can be loaded here as well, such as css styling files. jQuery is already included.
me@1942 35
me@1942 36 \section{Building the Interface}
me@1942 37 Your interface file will get loaded automatically when the 'interface' attribute of the setup node matches the string in the 'loadProjectSpecCallback' function. The following functions must be defined in your interface file.
me@1942 38 \begin{itemize}
me@1942 39 \item \texttt{loadInterface} - Called once when the document is parsed. This creates any necessary bindings, such as to the metric collection classes and any check commands. Here you can also start the structure for your test such as placing in any common nodes (such as the title and empty divs to drop content into later).
me@1942 40 \item \texttt{loadTest(audioHolderObject)} - Called for each page load. The audioHolderObject contains a specification node holding effectively one of the audioHolder nodes.
me@1942 41 \item \texttt{resizeWindow(event)} - Handle for any window resizing. Simply scale your interface accordingly. This function must be here, but can me an empty function call.
me@1942 42 \end{itemize}
me@1942 43
me@1942 44 \subsection{loadInterface}
me@1942 45 This function is called by the interface once the document has been parsed since some browsers may parse files asynchronously. The best method is simply to put 'loadInterface()' at the top of your interface file, therefore when the JavaScript engine is ready the function is called.
me@1942 46
me@1942 47 By default the HTML file has an element with id "topLevelBody" where you can build your interface. Make sure you blank the contents of that object. This function is the perfect time to build any fixed items, such as the page title, session titles, interface buttons (Start, Stop, Submit) and any holding and structure elements for later on.
me@1942 48
me@1942 49 At the end of the function, insert these two function calls: testState.initialise() and testState.advanceState();. This will actually begin the test sequence, including the pre-test options (if any are included in the specification document).
me@1942 50
me@1942 51 \subsection{loadTest(audioHolderObject)}
me@1942 52 This function is called on each new test page. It is this functions job to clear out the previous test and set up the new page. Use the function audioEngineContext.newTestPage(); to instruct the audio engine to prepare for a new page. "audioEngineContext.audioObjects = [];" will delete any audioObjects, interfaceContext.deleteCommentBoxes(); will delete any comment boxes and interfaceContext.deleteCommentQuestions(); will delete any extra comment boxes specified by commentQuestion nodes.
me@1942 53
me@1942 54 This function will need to instruct the audio engine to build each fragment. Just passing the constructor each element from the audioHolderObject will build the track, audioEngineContext.newTrack(element) (where element is the audioHolderObject audio element). This will return a reference to the constructed audioObject. Decoding of the audio will happen asynchronously.
me@1942 55
me@1942 56 You also need to link audioObject.interfaceDOM with your interface object for that audioObject. The interfaceDOM object has a few default methods. Firstly it must start disabled and become enabled once the audioObject has decoded the audio (function call: enable()). Next it must have a function exportXMLDOM(), this will return the xml node for your interface, however the default is for it to return a value node, with textContent equal to the normalised value. You can perform other functions, but our scripts may not work if something different is specified (as it will breach our results specifications). Finally it must also have a method getValue, which returns the normalised value.
me@1942 57
me@1942 58 It is also the job the interfaceDOM to call any metric collection functions necessary, however some functions may be better placed outside (for example, the APE interface uses drag and drop, therefore the best way was to call the metric functions from the dragEnd function, which is called when the interface object is dropped). Metrics based upon listening are handled by the audioObject. The interfaceDOM object must manage any movement metrics. For a list of valid metrics and their behaviours, look at the project specification document included in the repository/docs location. The same goes for any checks required when pressing the submit button, or any other method to proceed the test state.
me@1942 59
me@1942 60 \end{document}