\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
\lhead{\bf \large Section 2}
\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{defs}{Definition}
\newtheorem{lem}{Lemma}
\newtheorem{example}{Example}
\newtheorem{alg}{Algorithm}
\newtheorem{theorem}{Theorem}
\newtheorem{claim}{Claim}
\newtheorem{pro}{Proposition}

\begin{center}
\Large
Tonal Music Basics: Notes, Intervals and Arithmetics
\end{center}

\section{Tonal Music Arithmetics: Notes, Intervals}

The Note concept in the system knowledge base depends on the concept
of Pitch-Class.
A Pitch-Class stands for the set of al notes that share the same
diatonic and alteration
names such as ``all G$\sharp$'s''. Following \cite{Arithmetic},
a Pitch-Class is captured as
a pair, like $(C, \sharp)$ for the C sharp pitch class. 
A Pitch-Class cannot be played since it does not specify an octave number.

The concept of Note in JOINME knowledge base adds an octave number
(an integer) 
to a Pitch-Class., and it can be heard or played. 
For example, $C\sharp3$ names the note object with Pitch-Class
$(C, \sharp)$ and octave
number 3 (following MIDI devices' convention) which is the middle
C sharp note.

Interval is the Note's dual basic concept of tonal music. As
explained in Section 3.1,
intervals in tonal music are not numerical entities, but complex
ones that derive their 
structure from enharmonic notes' terminology. the Interval concept
in the knowledge base
depends on the concept of Interval-Class.

An {\em Interval Class} stands for the set of all intervals that share
the same diatonic and alteration names, such as ``all Perfect Fifth''.
Following \cite{Arithmetic}, an Interval-Class is captured as a pair
(FIFTH, PERFECT).
The concept of Interval in JOINME knowledge base adds a direction and
a number of included
octaves to an Interval-Class, and it can be played.
For example, (UP, 0, (FIFTH, PERFECT)) names the interval of perfect
fifth, that does not include
additional octaves and is played in the upward direction.
The direction can be either UP or DOWN, and the number-of-octaves must
be a non-negative integer.

Computations wioth Notes and Intervals are accomplished via the
arithmetic system,
developed in  \cite{Arithmetic}.
The main nidea lies in a generalization of the common structure
of notes and intervals
into a single numerical complex entity, called {\em Primitive Element}. 
A primitive element is a triplet of an octave number (an integer),
a diatonic number
([0, 6]), and a shift number (an integer) : ($<octave-number>,
<diatonic-number>, <shift-number>$).
A primitive element is associated with a {\em diatonic value}
and a {\em chromatic value},
defined as follows :
  \[ diatonic-value( (O, D, S) ) = 7*O + D \]
  \[chromatic-value( (O, D, S) ) = 12*O + chromatic-value(D) + S, \]
where chromatic-value(D) is given in the following table :
\begin{center}

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

    ch(D) & 0 & 2 & 4 & 5 & 7 & 9 & 11 \\
  \end{tabular}

\end{center}
The diatonic and chromatic values of primitive elements are used to
define an additive arithmetic
on this set. the arithmetic is based on the following proposition :

\subsubsection*{Proposition 6.1:}

Given two integers dv and cv, they uniquely define a primitive
element $(O, D, S)$ as follows :
\[ O = \lfloor \frac{dv}{7} \rfloor \]
\[ D = mod(dv, 7) \]
\[ S = cv - cv( (O, D, 0) ) \]
{\bf Definition :} Addition of primitive elements : \\ \\
Let $(O_1, D_1, S_1)$ and $(O_2, D_2, S_2)$ be primitive elements.
$(O, D, S)$ = $(O_1, D_1, S_1)$ + $(O_2, D_2, S_2)$ is the
primitive elements defined by
Proposition 6.1 above, from :
\[ dv = diatonic-value(O_1, D_1, S_1) + diatonic-value(O_2, D_2, S_2) \]
\[ cv = chromatic-value(O_1, D_1, S_1) + chromatic-value(O_2, D_2, S_2). \]
\subsubsection*{Claim 6.2 :}

The set PE of primitive elements, with the addition operation forms
a commutative 
additive group.

\subsubsection*{Proof :}

\begin{enumerate}
\item Commutativity : 
  \[ (O_1, D_1, S_1) + (O_2, D_2, S_2) = (O_2, D_2, S_2) + (O_1, D_1, S_1) \]
\item Associativity : 
  \[ (O_1, D_1, S_1) + ((O_2, D_2, S_2) + (O_3, D_3, S_3)) =
  ((O_1, D_1, S_1) + (O_2, D_2, S_2)) + (O_3, D_3, S_3) \]
\item Unit element : For every primitive element $(O, D, S)$ : 
  \[ (O, D, S) + (0, 0, 0) = (O, D, S) \]
\item Inverse element : The inverse element of a primitive element $(O, D, S)$
  is defined by Proposition 6.1 from :
  \[ dv = -[diatonic-value(O, D, S)] \] 
  \[ cv = -[chromatic-value(O, D, S)] \]
\end{enumerate}
It is very easy to verify that the inverse element, denoted -
$(O, D, S)$ indeed 
satisfies :
\[ (O, D, S) + (-(O, D, S)) = (0, 0, 0) \]
{\bf Definition :} Subtraction of primitive elements : \\ \\
Let $(O_1, D_1, S_1)$ and $(O_2, D_2, S_2)$ be primitive elements. Then :
\[ (O_1, D_1, S_1) - (O_2, D_2, S_2) = (O_1, D_1, S_1) + (-(O_2, D_2, S_2)) \]
Primitive elements account for all note and interval computations
since notes and intervals
can be translated into primitive elements and back. The translations
are given by the four
mappings below :

\begin{enumerate}
\item Note to Primitive Element Conversion :
  \[ note \rightarrow pe ( (octave-number, diatonic-name,
  alteration-name) ) = \]
  \[ (octave-number, d, s), \]
  where d and s are given in the following tables :

\begin{center}

  \begin{tabular}{l|lllllll}
    diatonic-name & C & D & E & F & G & A & B \\ \hline

    d & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
  \end{tabular}

\end{center}

\begin{center}

  \begin{tabular}{l|lllll}
    alteration-name & $\flat\flat$ & $\flat$ & $\natural$ & $\sharp$
    & $\sharp\sharp$ \\ \hline

    s & -2 & -1 & 0 & 1 & 2 \\
  \end{tabular}

\end{center}
For example : $note \rightarrow pe( (0, G, \sharp\sharp) ) = (0, 4, 2)$

\item Interval to Primitive Element Conversion :
  \[ interval \rightarrow pe ( (direction, octave-number,
  diatonic-name, alteration-name) ) = \]
  \[ (o, d, s) \]
  \begin{enumerate}
  \item If a direction is UP :
    o = octave-number (must be $\ge$ 0) and d and s are given in the following
    tables :

    \begin{center}

      \begin{tabular}{l|lllllll}
        diatonic-name & Prime & Second & Third & Fourth & Fifth
        & Sixth & Seventh \\ \hline

        d & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
      \end{tabular}

    \end{center}
    For a diatonic-name $\in$ \{Prime, Fourth, Fifth\} :

    \begin{center}

      \begin{tabular}{l|lll}
        alteration-name & Diminished & Perfect & Augmented \\ \hline

        d & -1 & 0 & 1 \\
      \end{tabular}

    \end{center}
    For a diatonic-name $\in$ \{Second, Third, Sixth, Seventh\} :

    \begin{center}

      \begin{tabular}{l|llll}
        alteration-name & Diminished & Minor & Major & Augmented \\ \hline

        d & -2 & -1 & 0 & 1 \\
      \end{tabular}

    \end{center}

  \item If direction is DOWN :
    \[ (O^{'}, D^{'}, S^{'}) = \] 
    \[ interval \rightarrow pe( (UP, octave-number, diatonic-name,
    alteration-name) ) \]
    \[ (O, D, S) = -(O^{'}, D^{'}, S^{'}) \]
    For example :
    \[ interval \rightarrow pe( (UP, 1, Fifth, Diminished) ) = (1, 4, -1) \]
    \[ interval \rightarrow pe( (DOWN, 1, Fifth, Diminished) ) =
    -(1, 4, -1) = (-2, 3, 1) \]
  \end{enumerate}

\item Primitive Element to Note Conversion : 
  \[ pe \rightarrow note ( (o, d, s) ) = (o, diatonic-name,
  alteration-name), \]
  determined by the tables as in $note \rightarrow pe$. \\

  For example : \( pe \rightarrow note ( (0, 4, 1) ) = (0, G, \natural) \)

\item Primitive Element to Interval Conversion :
  \[ pe \rightarrow interval ( (o, d, s) ) = (direction, o^{'},
  diatonic-name, alteration-name), \]
  where :

  \begin{enumerate}
  \item If $o \ge$ 0, then
    direction = UP \\
    $o^{'}$ = $o$ \\    
    diatonic-name and alteration-name are determined by the tables
    in $interval \rightarrow pe$.

  \item If $o <$ 0 : \\
    If $pe \rightarrow interval (-(o, d, s)) = (UP, o^{'}, d^{'}, s^{'})$ then

    \( pe \rightarrow interval(o, d, s) = (DOWN, o^{'}, d^{'}, s^{'}).\) \\

    For example : \( pe \rightarrow interval( (0, 6, 0) ) =
    (UP, 0, Seventh, Major) \)

  \end{enumerate}

\end{enumerate}

Based on the primitive elements arithmetic and the two-way
conversions between Notes
and Intervals to Primitive Elements, notes and intervals can be
properly added and 
subtracted. For example :

\begin{enumerate}
\item Note + Interval = Note

  \( (0,G, \natural) + (UP, 0, Fourth, Perfect) = \)

  \( note \rightarrow pe( (0, G, \natural) ) + 
  interval \rightarrow pe( (UP, 0, Fourth, Perfect) ) = \)

  \( (0, 4, 0) + (0, 3, 0) = (1, 0, 0) = pe \rightarrow note( (1, 0, 0) )
  = (1, C, \natural) \)

\item Interval + Interval = Interval

  \( (UP, 0, Third, Major) + (UP, 0, Third, Minor) = \)

  \( interval \rightarrow pe( (UP, 0, Third, Major) ) + 
  interval \rightarrow pe( (UP, 0, Third, Minor) ) = \)

  \( (0, 2, 0) + (0, 2, -1) = (0, 4, 0) = \)
  \( pe \rightarrow interval( (0, 4, 0) ) = (UP, 0, Fifth, Perfect) \)

\item Interval - Interval = Interval

  \( (UP, 0, Seventh, Minor) - (UP, 0, Third, Minor) = \)

  \( interval \rightarrow pe( (UP, 0, Seventh, Minor) ) + 
  interval \rightarrow pe( (UP, 0, Third, Minor) ) = \)

  \( (0, 6, -1) - (0, 2, -1) = (0, 6, -1) + (-(0, 2, -1)) = \)

  \( (0, 6, -1) + (0, -2, -12) = (0, 6, -1) + (-1, 5, 0) = \)

  \( (0, 4, 0) = pe \rightarrow interval( (0, 4, 0) ) = (UP, 0,
  Fifth, Perfect) \)

\item Note - Note = Interval

  \( (0,G, \natural) - (1, C, \natural) = \)
  \( note \rightarrow pe( (0, G, \natural) ) - 
   note \rightarrow pe( (1, C, \natural) ) = \)

  \( (0, 4, 0) - (1, 0, 0) = (0, 4, 0) + (-(1, 0, 0)) = \)

  \( (0, 4, 0) + (-1, 0, 0) = (0, 3, 0) = \)

  \( pe \rightarrow interval( (0, 3, 0) ) = (UP, 0, Fourth, Perfect) \)
\end{enumerate}

The Music Knowledge Base includes all relevant instances
of {\em Pitch-Class} and 
{\em Interval-Class.} They are used to construct real notes and intervals.
For example, to get the note $D\sharp$ in the middle octave, one
can use $D\sharp$ instance of the Pitch-Class and the middle octave
number, as the parameters
for the note construction. 
In a similar way, a real interval can be produced, from an
instance of the class 
Interval-Class a direction and the number of octaves to include
as the construction parameters.

\begin{center}

  \centerline{$Pitch-Class~Instances~Presented~in~the~MKB~of~JOINME$}
  \centerline{}

  \begin{tabular}{|l l l l l l l|} \hline
    $C\natural$ & $D\natural$ & $E\natural$ & $F\natural$
    & $G\natural$ & $A\natural$ & 
    $B\natural$ \\

    $C\sharp$ & $D\sharp$ & $E\sharp$ & $F\sharp$ & $G\sharp$ &
    $A\sharp$ & $B\sharp$ \\

    $C\sharp\sharp$ & $D\sharp\sharp$ & $E\sharp\sharp$ &
    $F\sharp\sharp$ & $G\sharp\sharp$ & 
    $A\sharp\sharp$ & $B\sharp\sharp$ \\

    $C\flat$ & $D\flat$ & $E\flat$ & $F\flat$ & $G\flat$ & $A\flat$
    & $B\flat$ \\

    $C\flat\flat$ & $D\flat\flat$ & $E\flat\flat$ & $F\flat\flat$
    & $G\flat\flat$ & 
    $A\flat\flat$ & $B\flat\flat$ \\ \hline
  \end{tabular}

\end{center}

\centerline{}

\begin{center}

  \centerline{$Interval-Class~Instances~Presented~in~the~MKB~of~JOINME$}
  \centerline{}

  \begin{tabular}{|l l l l|} \hline
    Perfect Prime & Augmented Prime & Diminished Prime & \\

    Major Second & Minor Second & Augmented Second & Diminished Second \\

    Major Third & Minor Third & Augmented Third & Diminished Third \\

    Perfect Fourth & Augmented Fourth & Diminished Fourth & \\

    Perfect Fifth & Augmented Fifth & Diminished Fifth & \\

    Major Sixth & Minor Sixth & Augmented Sixth & Diminished Sixth \\

    Major Seventh & Minor Seventh & Augmented Seventh & Diminished
    Seventh \\ \hline
  \end{tabular}

\end{center}


\bibliographystyle{plain}
\bibliography{mobile,er,security}


\end{document}
