\documentclass{article}

\usepackage{hyperref}
\usepackage{multicol}
\usepackage{listings}

\usepackage{ddphonism}

\title{The \textsf{ddphonism} package\footnote{This
		document corresponds to \textsf{ddphonism} v0.1, dated 2019/08/10.}}
\author{Celia Rubio Madrigal\footnote{Email: \href{mailto:celrubio@ucm.es}{\texttt{celrubio@ucm.es}}}}
\date{August 10, 2019}


\begin{document}
	
	\maketitle
	
	\begin{abstract}
		This is a music-related package which is focused on notation from the Twelve-Tone System, also called Dodecaphonism. It provides \LaTeX{} algorithms that produce typical T.T.S. notation based off a musical series, or row sequence, of variable length.
		
		\begin{center}
			\textbf{Keywords}
		\end{center}
	
		\textit{twelve tone system, dodecaphonism, music, mathematics, matrix, row, series, diagram, clock diagram, notation, algorithm, schoenberg, contemporary music, 20th century}
	\end{abstract}

	\tableofcontents
	
	\section{Introduction}
	There are hundreds of music tools and software online which are able to produce different music notations. However, I have never seen a \LaTeX{} tool that can do the same. This package is not only about notation, but it also calculates mathematically how this notation should work.
	
	It is said that a twelve-tone matrix is the only thing a twelve-tone composer should need, because it provides the whole serial spectrum with which they may work. I wanted \LaTeX{} users to be able to generate them automatically.
	
	But I also think that a twelve-tone matrix is not enough, that there exist several other notations with which they may understand their series and its potential. These are the diagrams that can be obtained with this package.
	
	\begin{multicols}{2}
		\dmatrix{0,1,2,3,4}
		
		\tikz{\ddihedral{4,5,7,1,6,3,8,2,11,0,9,10}}
		
		\ddiagram{4,5,7,1,6,3,8,2,11,0,9,10}{}
		
		\tikz{\darrows{4,5,7,1,6,3,8,2,11,0,9,10}}
		
		\bigskip
		\drow{4,3,2,1,0}
	\end{multicols}
	
	\section{Using the \textsf{ddphonism} package}
	These are the commands provided by \textsf{ddphonism}:
	
	\newcommand{\I}[1]{\item[\texttt{$\backslash$#1}]\quad}
	\begin{itemize}
		\I{dmatrix} produces a twelve-tone matrix of arbitrary length, as shown in \href{https:matrices.netlify.com}{this website}. Its parameter is the row sequence. For example, \verb|\dmatrix{0,2,1,4,3,6,5}| produces the matrix \dmatrix{0,2,1,4,3,6,5}

		The command automatically reduces the input and output modulus the length of the input series. Thus, the input \verb|\dmatrix{7,9,8,11,10,13,12}| produces the same output as before.
		
		\I{ddiagram} produces a twelve tone clock diagram of arbitrary length, as shown in \href{https:diagramas.netlify.com}{this website}. Its parameters are the row sequence and its name. An additional optional parameter tells which number must be up north. The default value is the first number. For example, \verb|\ddiagram{0,2,1,4,3,6,5}{P}| produces the diagram \ddiagram{0,2,1,4,3,6,5}{P}

		and \verb|\ddiagram[3]{0,1,2,3,4}{P}| produces the diagram \ddiagram[3]{0,2,1,4,3,6,5}{P}

		The command also reduces the input and output modulus the length of the input series.
		
		\I{ddihedral} produces a dihedral representation of a series of arbitrary length. Its parameters are the original row sequence and, optionally, the transformations it undergoes: \texttt{t,s,c,v} applied in that order. For example,\\ \verb|\tikz{\ddihedral[t=2,v=1]{0,2,1,4,3,6,5}}| produces the diagram\\ \tikz{\ddihedral[t=2,v=1]{0,2,1,4,3,6,5}}

		It needs to be inside a \texttt{tikz} environment, as opposed to the previous ones, which are separate \texttt{tikz} environments on their own. This is because rotation or translation lines are sometimes included in this diagram, and sometimes it needs scalings.

		The command also reduces the input and output modulus the length of the input series.
		
		\I{darrows} produces the arrows from the \verb|\ddihedral| diagram. For example,
 		\verb|\tikz{\darrows{0,2,1,4,3,6,5}}| produces the arrows\\
 		\tikz{\darrows{0,2,1,4,3,6,5}}
		
		\I{drow} produces a twelve-tone row sequence as a permutation in its matrix form. For example, \verb|\drow{0,2,1,4,3,6,5}| produces the row
		
		\drow{0,2,1,4,3,6,5}
		
	\end{itemize}
	
	\section{The package code}	
	\lstset{
%		frame=lines,
		%
		language=[Latex]Tex,
		%
		basicstyle=\footnotesize\sffamily,
		keywordstyle=\footnotesize\sffamily,
		identifierstyle=\footnotesize\sffamily,
		commentstyle=\footnotesize\sffamily,
		stringstyle=\footnotesize\sffamily,
		escapechar=¬,
		%		
		numberstyle=\footnotesize\sffamily,%\ttfamily\tiny\color[gray]{0.3},
		numbers=left,
		stepnumber=2,
		numbersep=15pt,
		%
		columns=flexible,
		showstringspaces=false,
		tabsize=4,
	}
	\lstinputlisting{ddphonism.sty}
	
\end{document}
