view SMC2015latex/framework.tex @ 50:e71028851131

updating latex and bug fixes to main py files
author christopherh <christopher.harte@eecs.qmul.ac.uk>
date Mon, 27 Apr 2015 09:51:15 +0100
parents
children
line wrap: on
line source
\section{Framework}

\begin{figure}[t]
\centering
\includegraphics[width=0.6\columnwidth]{images/framework.pdf}
\caption{Module hierarchy in the synpy toolkit: The top-level module provides a simple interface for the user to test different syncopation models. Musical constructs such as bars, velocity and note sequences, notes and time signatures are defined in the `music objects' module while support for common procedures such as sequence concatenation and subdivision is provided in `basic functions'. Models and file reading components can be interchanged as required by the user.\label{fig:framework}}
\end{figure}

\begin{figure}
\footnotesize{
\begin{minted}[frame=single,framesep=10pt]{python}
T{4/4} # time signature
TPQ{4} # ticks per quarternote
# Bar 1
Y{(0,3,2),(3,1,1),(6,2,2),(10,2,1),(12,4,1)}
# Bar 2
V{1,0,0,0.5,0,0,1,0,0,0,0.5,0,0.5,0,0,0}
\end{minted}
}
\caption{Example rhythm annotation \code{.rhy} file containing two bars of the Son Clave rhythm. The first is expressed as a note sequence with resolution of four ticks per quarternote; the second is the same rhythm expressed as a velocity sequence (see section~\ref{sec:background}.}
\label{ta:clave} 
\end{figure}
\begin{figure}
\footnotesize{
\begin{minted}[frame=single,framesep=10pt]{python}
>>>from synpy import *
>>>import synpy.PRS as model
>>>calculate_syncopation(model, "clave.rhy")
{'bars_with_valid_output': [0, 1],
 'mean_syncopation_per_bar': 8.625,
 'model_name': 'PRS',
 'number_of_bars': 2,
 'number_of_bars_not_measured': 0,
 'source': 'clave.rhy',
 'summed_syncopation': 17.25,
 'syncopation_by_bar': [8.625, 8.625]}
\end{minted}
}
\caption{To use the library, the top level \code{synpy} module is imported along with a model (in this example Pressing \cite{pressing}); calling \code{calculate\_syncopation()} gives the syncopation results as shown. 
\label{ta:example} }
\end{figure}

The architecture of the toolkit is relatively simple (see Figure~\ref{fig:framework}); syncopation values are calculated for each bar in a given source of rhythm data with the user specifying which model to use and supplying any special parameters that are required.  Output can optionally be saved directly to XML or JSON files. Sources of rhythm data can be the name of a file containing rhythm data or a bar or list of bar objects as defined in section~\ref{sec:?}.   Where a model is unable to calculate a value for a given rhythm pattern, a “None” value is recorded for that bar and the indices of unmeasured bars reported in the output.  

Musical constructs such as bars, velocity and note sequences, notes and time signatures are defined in the `music objects' module with support for common procedures such as sequence concatenation and subdivision being provided in `basic functions'.  Two file reader modules are currently provided; one for reading standard MIDI files and one for reading plain text rhythm annotation \code{.rhy} files. These modules open their respective file types and return a list of bar objects that the syncopation models can process.  

The system architecture has been designed to allow new models to be added easily.   Models have a common interface, exposing a single function that will return the syncopation value for a bar of music.  Optional parameters may be supplied as a Python dictionary if the user wishes to specify settings different from the those given in the literature for a specific model.



% \section{MIDI Input}\label{sec:midi}

% \cite{Taylor89MusicTheory}

% \section{Text Input}\label{sec:textinput}

% \begin{table*}
% \small{
% \begin{minted}[frame=single,framesep=10pt]{console}
% <piece>             ::=  [<comment-lines>] <timesig> <line> | <piece> <line>

% <comment-lines>     ::= <comment> "\n" | <comment-lines> <comment> "\n"

% <line>              ::= [<barlist>] [<comment>] "\n"

% <comment>           ::= "#" <comment-text>

% <barlist>           ::= <time-info> | [<time-info>] <bar> | <barlist> <bar>

% <time-info>         ::= [<timesig>] [<ticks-per-quarter>] [<tempo>] 

% <tempo>             ::= "QPM{" <digits> "}"

% <ticks-per-quarter> ::= "TPQ{" <digits> "}"

% <timesig>           ::= "T{" <digit> "/" <digit> "}"

% <bar>               ::= "V{" <velocity-sequence> "}" | "Y{" <note-sequence> "}"

% <note-sequence>     ::= <note> | <note-sequence> "," <note>

% <note>              ::= "(" <digits> "," <digits> "," <digits> ")"

% <velocity-sequence> ::= <decimal> | <velocity-sequence> "," <decimal>

% <decimal>           ::= "0" | "1" | "0." <digits>

% <digits>            ::= <digit> | <digits> <digit>

% <digit>             ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
% \end{minted}
% }
% \caption{Syntax of rhythm text format Backus-Naur Form}
% \label{ta:BNF} 
% \end{table*}