# HG changeset patch # User Nicholas Jillings # Date 1428487063 -3600 # Node ID b7b85431df500a524d184dc344e2aa35ee935afc # Parent 31a8cd5ddf757b36e30c06fe4b68f7cd3036e5ad Written parts for Implementation. Small correction to project.xml (no more sampleRateExplicit tag). diff -r 31a8cd5ddf75 -r b7b85431df50 docs/ProjectSpecificationDocument.pdf Binary file docs/ProjectSpecificationDocument.pdf has changed diff -r 31a8cd5ddf75 -r b7b85431df50 docs/ResultsSpecificationDocument.pdf Binary file docs/ResultsSpecificationDocument.pdf has changed diff -r 31a8cd5ddf75 -r b7b85431df50 docs/SMC15/smc2015template.tex --- a/docs/SMC15/smc2015template.tex Wed Apr 08 09:45:24 2015 +0100 +++ b/docs/SMC15/smc2015template.tex Wed Apr 08 10:57:43 2015 +0100 @@ -161,12 +161,43 @@ \section{Implementation}\label{sec:implementation} -[Nick???] +%[Nick???] -section on overall architecture\\ +%section on overall architecture\\ -section with overview of the structure of the input and output files, perhaps with graph or table +%section with overview of the structure of the input and output files, perhaps with graph or table +The tool runs entirely inside the browser through the new HTML5 Web Audio API. The API is supported by most major web browsers (except Internet Explorer) and allows for constructing a chain of audio processing elements to produce a high quality, real time signal process to manipulate audio streams. The API supports multi-channel processing and has an accurate playback timer for precise scheduled playback control. The web audio API is controlled through the browser JavaScript and is therefore highly controllable. The Web Audio API processing is all controlled in a separate thread to the main JavaScript thread, meaning there is no blocking due to real time processing. + +\subsection{Architecture}\label{sec:architecture} + +The web tool itself is split into several files to operate: +\begin{itemize} +\item apeTool.html: The main index file to load the scripts, this is the file the browser must request to load +\item core.js: Contains functions and objects to manage the audio control, audio objects for testing and loading of files +\item ape.js: Parses setup files to create the interface as instructed, following the same style chain as the MATLAB APE Tool. +\end{itemize} + +The HTML file loads the core.js file with it along with a few other ancillary files (such as the jQuery javascript extensions), the browser JavaScript begins to execute the on page instructions, which gives the URL of the test setup XML document (outlined in the next section). The core.js parses this document and executes the function in ape.js to build the web page with the given audio files. The reason for separating these two files is to allow for further interface designs (such as Mushra or A-B tests) to be used, which would still require the same underlying core functions outlined in core.js + +The ape.js file has only two main functions: \texttt{loadInterface(xmlDoc)} and \texttt{interfaceXMLSave()}. The first function is called to build the interface once the setup document has been loaded. This includes creating the slider interface to rate the tracks and creating the comment boxes bellow. The bars in the slider ranking at the top of the page are randomly spaced. It also instructs the audio engine in the core.js to create the audio objects. The audio objects are custom built audio nodes built on the web audio API. They consist of a bufferSourceNode (a node which holds a buffer of audio samples for playback) and a gainNode. These are then connected to the audioEngine (itself a custom web audio node) containing a gainNode (where the various audio Objects connect to) for summation before passing the output to the destination Node, a fixed node created where the browser then passes the audio information to the system sound device. + +When an audioObject is created, the URL of the audio sample to load is given to it. This is downloaded into the browser asynchronously using the XMLHttpRequest object. This allows for downloading of any file into the JavaScript environment for further processing. It is particularly useful for the web audio API because it supports downloading of files in their binary form, allowing a perfect copy. Once the asynchronous download is complete, the file is then decoded using the web audio API offline decoder. This uses the browser available decoding schemes to decode the audio files into raw float32 arrays, which are in-turn passed to the relevant audioObject bufferSourceNode for playback. + +Browsers support various audio file formats and are not consistent in any format. One sure format that all browsers support is the WAV format. Although not a compact, web friendly format, most transport systems are of a high enough bandwidth this should not be a problem. However one problem is that of sample rate. On loading, the browser uses the sample rate assigned by the system sound device. The browser does not have the ability to request a different sound rate. Therefore the default operation when an audio file is loaded with a different sample rate to that of the system is to convert the sample rate. To provide a check for this, the desired sample rate can be supplied with the setup XML and checked against. If the sample rates do not match, a browser alert window is shown asking for the sample rate to be correctly adjusted. This happens before any loading or decoding of audio files. Only once the sample rates match will the system actually fetch any files, keeping down requests for the larger files until they are actually needed. + +During playback, the playback nodes loop indefinitely until playback is stopped. The gain nodes in the audioObjects enable dynamic muting of nodes. When a bar in the sliding ranking is clicked, the audio engine mutes all audioObjects and un-mutes the clicked one. Therefore, if the audio samples are perfectly aligned up and of the same sample length, they will remain perfectly aligned with each other. + +\subsection{Setup and Results Formats}\label{sec:setupresultsformats} + +Setup and the results both use the common XML document format to outline the various parameters. The setup file contains all the information needed to initialise a test session. Several Nodes can be defined to outline the audio samples to use, questions to be asked and any pre- or post-test questions or instructions. Having one document to modify allows for quick manipulation in a 'human readable' form to create new tests, or adjust current ones, without needing to edit which web files. + +The results file is dynamically generated by the interface upon clicking the submit button. There will be checks, depending on the setup file, to ensure that all tracks have been evaluated and their positions in the slider moved. The XML returned contains a node per audioObject and contains its rating in the slider and any comments written in its associated comment box. The rating returned is normalised to be within a integer range of 0 to 100. This normalises the pixel representation of different browser windows. If a window for instance is only 1280 wide, reporting its pixel position is not representative to a display with a width of 1920. + +The results will also contain information collected by any defined pre/post questions. These are referenced against the setup XML by using the same ID as well as printing in the same question, so readable responses can be obtained. Future development will also evolve to include any session data, such as the browser the tool was used in, how long the test took and any other metrics. Currently the results files are downloaded on the user side of the browser as a .xml file to be manually returned. However the end goal is to allow the XML files to be submitted over the web to a receiving server to store them, allowing for automated collection. + +Here is an example of the setup XML and the results XML: +% Should we include an Example of the input and output XML structure?? \section{Applications}\label{sec:applications} %? diff -r 31a8cd5ddf75 -r b7b85431df50 example_eval/project.xml --- a/example_eval/project.xml Wed Apr 08 09:45:24 2015 +0100 +++ b/example_eval/project.xml Wed Apr 08 10:57:43 2015 +0100 @@ -1,7 +1,7 @@ - +