\documentclass[11pt,oneside]{article}
\usepackage{array}
\usepackage{epsf}
\usepackage{epic}
\usepackage{eepic}
\usepackage{epsfig}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{a4}
\usepackage{makeidx}
\usepackage{fancyheadings}
\usepackage[latin1]{inputenc}

\textheight22.5cm
\textwidth17.5cm
%\topmargin -2.0cm
\oddsidemargin -1.0cm
\evensidemargin -0.3cm
\linespread{1.3}
%\setlength{\parindent}{0ex}

%\pagestyle{fancy}
%\headrulewidth 0cm
%\footrulewidth 0cm
%\chead{}
%\rhead{}
%\lfoot{}
%\cfoot{}
%\rfoot{{\bf P.5(}\textrm{\thepage}{\bf )}}

\newcommand{\cif}{\textrm{\tt if }}
\newcommand{\ciff}{\textrm{\tt if}}
\newcommand{\cnot}{\textrm{\tt not }}
\newcommand{\cthen}{\ \textrm{\tt then }}
\newcommand{\celse}{\ \textrm{\tt else }}
\newcommand{\cfi}{\ \textrm{\tt fi}}
\newcommand{\cfii}{\textrm{\tt fi}}
\newcommand{\proofend}{\begin{flushright}$\Box$\end{flushright}}
\newcommand{\ind}{\emph{\it independent}}
\newcommand{\eff}{\emph{\it eff}}


\begin{document}

\newtheorem{Definition}{Definition}
\newtheorem{lem}{Lemma}
\newtheorem{Example}{Example}
\newtheorem{alg}{Algorithm}
\newtheorem{theorem}{Theorem}
\newtheorem{Claim}{Claim}
\newtheorem{Proposition}{Proposition}

\begin{center}
\Large
{\bf Structure and Interpretation of Music Concpets}
\end{center}

\noindent
{\bf Class$10$ -- Tonal Arithmetics}.

\begin{center}
\Large
{\bf The Tonal Music Pitch and Interval Domain:
Terminology, Arithmetics, Physical mappings}.
\end{center}

%\section{Tonal Music Arithmetics: Notes, Intervals}

The domain of notes and intervals in tonal music is created by a rich
set of pitch-classes (interval-classes), that is much larger than the
set of physical pitch-classes to which they are mapped.
The set of \emph{Tonal-Pitch-Classes} (\emph{TPC})
(\emph{Tonal-Interval-Classes} (\emph{TIC})) is
generated by extending the western twelve tone selection with an
additional seven tone selection -- called the \emph{diatonic points}.
The overall TPC (TIC) domain is a set of pairs, that correspond
to the diatonic points, and amount of alteration. Since the diatonic
points map in a $1:1$ manner to specific $12$-tone pitch-classes, these
pairwise values map also to the $12$-tone pitch-classes. However, the mapping
is no longer $1:1$.

These class notes include the definition of the TPC and TIC concepts, the
\emph{Tonal-Pitch} and \emph{Tonal-Interval} concepts,
and their arithmetics. The definition of the concepts is done by providing a
single abstraction for both concepts: \emph{Tonal-Class} and
\emph{Tonal-Element}. The arithmetics is obtained from a mapping
of the Tonal-Class values to $12$-tone pitch-classes, and from
two enumerations of the Tonal-Element values:
\begin{enumerate}
\item
$diatonic\_value$, that enumerates only the diatonic points in each octave --
and hence, every octave includes only $7$ elements.
\item
$chromatic\_value$, that enumerates all $12$ pitch-classes in each octave --
and hence, every octave includes $12$ elements.
\end{enumerate}
This way we obtain a uniform, 
single arithmetics for all Tonal-Pitch and Tonal-Interval
computations, therby avoiding the need to
provide separate arithmetics for the different types. The arithmetics
characterizes the set of Tonal-Elements
as a commutative group, and supports further
operations and characterizations.   

\section{Terminology -- Types}

\subsection{Tonal-Pitch-Class, Tonal-Interval-Class, Tonal-Class}

\subsubsection*{Tonal-Pitch-Class}
\begin{enumerate}

\item  
$Diatonic\_Pitch = \{C,~ D,~ E,~ F,~ G,~ A,~ B \}$

\item
$Pitch\_Alteration
  = \{ \flat\flat,~ \flat,~ \natural,~ \sharp,~  \sharp\sharp \}$ 

\item
$Tonal\_Pitch\_Class ~(TPC) = Diatonic\_Pitch \times Pitch\_Alteration$

\end{enumerate}
For example: $(C, \sharp)$ for the C sharp pitch class. 

\subsubsection*{Tonal-Interval-Class}
\begin{enumerate}

\item
$Diatonic\_Interval
   = \{ Prime,~ Second,~ Third,~ Fourth,~ Fifth,~ Sixth,~
   Seventh \}$ 

\item
$Interval\_Alteration
    = \{ Diminished,~ Minor,~ Major,~ Perfect,~ Augmented \}$

\item
$Tonal\_Interval\_Class ~(TIC) = Diatonic\_Interval \times Interval\_Alteration$

\end{enumerate}
For example: $(Fifth, Perfect)$ for the perfect fifth interval class. 


\subsubsection*{Tonal-Class}
\begin{enumerate}

\item
$Diatonic\_Point = \{ 0,~ 1,~ 2,~ 3,~ 4,~ 5,~ 6 \}$

\item
$Alteration = \{ -2,~ -1,~ 0,~ 1,~ 2 \}$

\item
$Tonal\_Class ~(TC) = Diatonic\_Point \times Alteration$

\end{enumerate}
For example: $(0, -1)$ for the $(C, \sharp)$ pitch-class, or for the
$(Prime, Diminished)$ interval-class. \\  

\noindent
{\bf Selectors for the Tonal Class type}: \\
$diatonic: Tonal\_Class \rightarrow Diatonic\_Point$. \\
$alteration: Tonal\_Class \rightarrow Alteration.$


\subsection{Tonal-pitch, Tonal-Interval, Tonal-Element}

\begin{enumerate}

\item
$Octave = I$, the set of integers. \\
$Positive\_Octave = N$, (including 0).

\item
$Tonal\_pitch = Octave \times TPC$. \\
The intention is that octave number $0$ marks the middle octave (midi-pitch $60
- 72$).

\item
$Tonal\_Interval = \{ up, down \} \times Octave \times TIC$. \\
For example: (down, 1, (Fifth, Perfect)) marks an interval of a whole octave
$+$ a perfect fifth in the downword direction.

\item
$Tonal\_Element = Octave \times TC$. \\
For example, $(-3, (0, -1))$ is
a tonal element that denotes the tonal pitch Cb,
$3$  octaves
below middle C -- $(3, (C, \flat))$,
or the donword tonal interval of $3$ octaves and augmented
prime -- $(downword,~ 3, (Prime,~ Augmented))$.  

\end{enumerate}

%Examples.

                              
\section{Mapping the Tonal Level to a Diatonic and Twelve Tone Enumeration}

\subsubsection*{Diatonic Points}

\noindent
$value: Diatonic\_Point \rightarrow Music\_Pitch\_Class$, \\
defined as follows:
\begin{center}

  \begin{tabular}{l|lllllll}
    dp & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline

    value(dp) & 0 & 2 & 4 & 5 & 7 & 9 & 11 \\
  \end{tabular}

\end{center}

\subsubsection*{Tonal Class Mapping}

The $value$ mapping is extended to values of the $Tonal\_Class$ set: \\
$value: Tonal\_Class \rightarrow Music\_Pitch\_Class \cup
                  \{ -2,~ -1,~ 12,~ 13  \}$, \\
defined by:
   $value(d, a) = value(d) + a$. \\


\subsubsection*{Tonal Element Mapping}

Each tonal element value has two values associated with it: A
$diatonic\_value$, that provides the diatonic position in a diatonic points
axis, and $chromatic\_value$, that provides the position in a music pitch
axis.
The arithmetics of the tonal elements arises from coordination of these
two values. The $diatonic\_value$ provides a count of the tonal element on an
axis of diatonic points (base $7$), and the $chromatic\_value$ provides the
actual music pitch (a count on an axis of music pitch classes -- base $12$). 
\begin{enumerate}
\item
$diatonic\_value: Tonal\_Element \rightarrow I$: \\
where, \\
$diatonic\_value(o, tc) = 7*o + diatonic(tc)$ \\
Example: $diatonic\_value(-1, (6,2)) = 7*(-1) + 6 = -1$

\item
$chromatic\_value: TE \rightarrow I$: \\
where, \\
$chromatic\_value(o, tc) = 12*o + value(tc)$ \\
Example: $chromatic\_value(-1, (6, 2)) = 12*(-1) + 11 + 2 = 1$

\item
$music\_pitch: TE \rightarrow Music\_Pitch$: \\
where,
$music\_pitch(o, tc) = (o + 5 + mod\_quotient(value(tc), 12),~
                        modulo(value(tc), 12))$ \\
where $mod\_quotient$ and $modulo$ are quotient and remainder functions that
return always a positive ``modulo'' remainder, and a quotient that together
account for the whole division. They are defined at the end of this document.
Modulo is a primitive of Scheme.

\end{enumerate}

      
\section{Arithmetics}

\begin{Proposition}
Given two integers $dv$ and $cv$, they uniquely define a tonal
element $(o, tc)$ as follows :
\begin{enumerate}
\item
$o = \lfloor \frac{dv}{7} \rfloor$
\item
$diatonic(tc) = modulo(dv, 7)$
\item
$alteration = cv - chromatic\_value( (o, (diatonic\_point(tc), 0) ) )$
\end{enumerate}
\end{Proposition}

\begin{Definition}
Addition of tonal elements: \\
Let $(o_1 , tc_1 )$, $(o_2 , tc_2 )$ be tonal elements.
Their addition,
$(o, tc) = (o_1 , tc_1 )$ + $(o_2 , tc_2 )$, is the
tonal element that is uniquely defined (by
the above Proposition) from:
\begin{itemize}
\item
$dv = diatonic\_value( o_1 , tc_1 ) + diatonic\_value( o_2 , tc_2 )$
\item
$cv = chromatic\_value( o_1 , tc_1 ) + chromatic\_value( o_2 , tc_2 )$
\end{itemize}
\end{Definition}

\begin{Claim}
The set TE of tonal elements, together with the addition operation forms
a commutative additive group.
\end{Claim}
\subsubsection*{Proof:}
\begin{enumerate}
\item
{\bf Commutativity}: By the commutativity of numeric addition, and the above
  proposition, \\
  $~~ (o_1 , tc_1 ) + (o_2 , tc_2 ) = (o_2 , tc_2 ) + (o_1 , tc_1 )$
\item
{\bf Associativity}: By the associativity of numeric addition, and the above
  proposition, \\  
  $~~ (o_1 , tc_1 ) + ((o_2 , tc_2 ) + (o_3 , tc_3 )) =
  ((o_1 , tc_1 ) + (o_2 , tc_2 )) + (o_3 , tc_3 ) $
\item
{\bf Unit element}: For every tonal element $(o, tc)$: 
  $~~ (o, tc) + (0, (0, 0)) = (o, tc) $
\item
{\bf Inverse element}: The inverse element of a tonal element $(o, tc)$
  is defined by the above Proposition from:
\begin{itemize}
\item
$ dv = -(diatonic\_value(o, tc)) $
\item
$ cv = -(chromatic\_value(o, tc)) $
\end{itemize}
It is easy to verify that the inverse element, denoted 
$-(o, tc)$ indeed satisfies: \\
$~~ (o, tc) + (-(o, tc)) = (0, (0, 0)) $
\end{enumerate}
\begin{Definition}
Subtraction of tonal elements:  \\
Let $(o_1 , tc_1 )$ and $(o_2 , tc_2 )$ be tonal elements. Then:
$~~ (o_1 , tc_1 ) - (o_2 , tc_2 ) = (o_1 , tc_1 ) + (-(o_2 , tc_2 )) $
\end{Definition}

\section{Translations from and to the Tonal Pitch and Tonal Interval to the
  Tonal Element Abstraction}

\begin{enumerate}
\item
Mapping Tonal-Pitch-Classes and Tonal-interval-Classes to Tonal-Classes, and
back:
\begin{enumerate}
\item  
The translations $tpc \rightarrow tc$ and $tc \rightarrow tpc$
to and from Tonal-Pitch-Classes and Tonal-Classes are defined
component-wise, in the following tables: 
\[
  \begin{array}{l|lllllll}
    diatonic\_tpc \leftrightarrow tc &&&&&&& \\ \hline \hline
    Diatonic\_Pitch & C & D & E & F & G & A & B \\ \hline
    Diatonic\_Point & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
  \end{array}
\]

\[
  \begin{array}{l|lllll}
    alteration\_tpc \leftrightarrow tc &&&&& \\ \hline \hline
    Pitch\_Alteration & \flat\flat & \flat & \natural & \sharp
    & \sharp\sharp \\ \hline
    Alteration & -2 & -1 & 0 & 1 & 2 \\
  \end{array}
\]
For example : $tpc \rightarrow tc(G, \sharp\sharp) = (4, 2)$
\item
The translations to and from Tonal-Interval-Classes and Tonal-Classes are
defined component-wise, in the following tables: 
\[
      \begin{array}{l|lllllll}
        diatonic\_tic \leftrightarrow tc &&&&&&& \\ \hline \hline
        Diatonic\_Interval & Prime & Second & Third & Fourth & Fifth
        & Sixth & Seventh \\ \hline
        Diatonic\_Point & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
      \end{array}
\]
For a $Diatonic\_Interval \in \{Prime,~ Fourth,~ Fifth \}$:
\[
      \begin{array}{l|lll}
        alteration\_Perfect\_tic \leftrightarrow tc &&& \\ \hline \hline 
        Interval\_Alteration & Diminished & Perfect & Augmented \\ \hline
        Alteration & -1 & 0 & 1 \\
      \end{array}
\]
For a $Diatonic\_Interval \in \{Second,~ Third,~ Sixth,~ Seventh \}$:
\[
      \begin{array}{l|llll}
        alteration\_MajMin\_tic \leftrightarrow tc &&&& \\ \hline \hline  
        Interval\_Alteration & Diminished & Minor & Major & Augmented \\ \hline
        Alteration & -2 & -1 & 0 & 1 \\
      \end{array}
\]
For example : $tic \rightarrow tc(Fourth, Augmented) = (3, 1)$

\end{enumerate}
\item
Translations from and to Tonal Pitches and Tonal Elements:
\begin{itemize}
\item
$tp \rightarrow te(o, tpc) = (o, tpc \rightarrow tc(tpc))$
\item
$te \rightarrow tp(o, tc) = (o, tc \rightarrow tpc(tc))$ 
\end{itemize}
\item
Translations from and to Tonal Intervals and Tonal Elements:
\begin{itemize}
\item
\begin{tabbing}
$ti \rightarrow te$\=$(dir, o, tic) =$ \\
      \> if $dir = up$: $(o, tic \rightarrow tc(tic))$ \\
      \> if $dir = down$: \=$-(ti \rightarrow te(up, o, tic))$ \\
      \> \>               where $-$ is the inverse operation of $+$ on TE.
\end{tabbing}
\item
\begin{tabbing}  
$te \rightarrow ti$\=$(o, tc)=$ \\
      \> if $o \ge 0$: $(up, o, tc \rightarrow tic(tc))$ \\
      \> if $o < 0$: \=$( te \rightarrow ti( -(o, tc) ))_{/dir = down}$ \\
      \> \>    where $-$ is the inverse operation of $+$ on TE, and \\
      \> \>    for a $Tonal\_Interval$ $ti$,
               $ti_{/dir = val}$ denotes a $Tonal\_Interval$
               that is \\
      \> \>    equal to $ti$ except for $dir = val$.
\end{tabbing}
\end{itemize}
\end{enumerate}

\begin{Example} Translations: Tonal Elements, Tonal Pitches, Tonal Intervals:
\begin{itemize}
\item
$ti \rightarrow te( (up, 1, (Fifth, Diminished)) ) = (1, (4, -1))$
\item
$ti \rightarrow te( (down, 1, (Fifth, Diminished)) ) =
    -(1, (4, -1)) = (-2, (3, 1)) $
\item    
$te \rightarrow tp ( (0, (4, 1)) ) = (0, (G, \natural))$
\item
$te \rightarrow ti( (0, (6, 0)) ) = (up, 0, (Seventh, Major))$
\end{itemize}
\end{Example}

\begin{Example} Tonal Arithmetics:
\begin{enumerate}
\item
$Tonal\_Pitch + Tonal\_Interval = Tonal\_Pitch$: \\
$(0, (G, \natural)) + (up, 0, (Fourth, Perfect)) = $ \\
$te \rightarrow tp [ tp \rightarrow te( (0, (G, \natural)) ) + 
  ti \rightarrow te( (UP, 0, (Fourth, Perfect)) ) ] = $ \\
$te \rightarrow tp [ (0, (4, 0)) + (0, (3, 0)) ] =
 te \rightarrow tp( (1, (0, 0)) )
  = (1, (C, \natural)) $

\item
$Tonal\_Interval + Tonal\_Interval = Tonal\_Interval$: \\
$(up, 0, (Third, Major)) + (up, 0, (Third, Minor)) = $ \\
$te \rightarrow ti [ ti \rightarrow te( (up, 0, (Third, Major)) ) + 
  ti \rightarrow te( (up, 0, (Third, Minor)) ) ] = $ \\
$te \rightarrow ti [ (0, (2, 0)) + (0, (2, -1)) ] = 
 te \rightarrow ti( (0, (4, 0)) ) = (up, 0, (Fifth, Perfect)) $

\item
$Tonal\_Interval - Tonal\_Interval = Tonal\_Interval$: \\ 
$(up, 0, (Seventh, Minor)) - (up, 0, (Third, Minor)) = $ \\
$te \rightarrow ti [ ti \rightarrow te( (up, 0, (Seventh, Minor)) ) + 
  ti \rightarrow te( (up, 0, (Third, Minor)) ) ] = $ \\
$te \rightarrow ti [ (0, (6, -1)) - (0, (2, -1)) ] =
 te \rightarrow ti [ (0, (6, -1)) + (-(0, (2, -1))) ] = $ \\ 
$te \rightarrow ti [ (0, (6, -1)) + (-1, (5, 0)) ] = 
 te \rightarrow ti ( (0, (4, 0)) ) = (up, 0, (Fifth, Perfect)) $

\item
$Tonal\_Pitch - Tonal\_Pitch = Tonal\_Interval$: \\
$(0, (G, \natural)) - (1, (C, \natural)) = $ \\
$te \rightarrow ti [ tp \rightarrow te( (0, (G, \natural)) ) - 
  tp \rightarrow te( (1, (C, \natural)) ) ] = $ \\
$te \rightarrow ti [ (0, (4, 0)) - (1, (0, 0)) ] =
 te \rightarrow ti [ (0, (4, 0)) + (-(1, (0, 0))) ] = $ \\ 
$te \rightarrow ti [ (0, (4, 0)) + (-1, (0, 0)) ] = 
 te \rightarrow ti (  (0, (3, 0)) ) = (up, 0, (Fourth, Perfect)) $
\end{enumerate}
\end{Example}


%\pagebreak

\begin{verbatim}

Scheme procedures for mod-quotient and modulo.
==============================================

(define (mod-quotient n1 n2)
   (numerator (/ (- n1 (modulo n1 n2))
                 n2)))

(define (true-mod-quotient-modulo n1 n2)
        (= n1 (+ (* (mod-quotient n1 n2) n2)
                 (modulo n1 n2))))

> (mod-quotient 50 12)
4
> (modulo 50 12)
2
> (modulo -50 12)
10
> (mod-quotient -50 12)
-5
> (true-mod-quotient-modulo 50 12)
#t
> (true-mod-quotient-modulo -50 12)
#t
> (true-mod-quotient-modulo 0 12)
#t
\end{verbatim}


\end{document}
