\documentclass[svgnames,smaller,xetex]{beamer}

\usepackage{listings}
\lstset{
    aboveskip=1em,
    basicstyle=\footnotesize\ttfamily, 
    belowskip=0.25em,
    breaklines=True, 
    commentstyle=\color{red}\itshape,
    frame=single,
    language=Python,
    showspaces=false,
    showstringspaces=false,
    showtabs=false, 
    tabsize=4, 
    }

\frenchspacing
\usepackage[quiet]{fontspec}

\parskip=1em
\baselineskip=1.2em

\setbeamerfont{text}{size*={14}{1.4em}}

\defaultfontfeatures{
    Mapping=tex-text,
    Scale=MatchLowercase,
}
\setsansfont[
    LetterSpace=3.0
]{Helvetica Neue Light}
\setmonofont[
    LetterSpace=3.0
]{Monaco}


\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[text line]{}

\makeatletter
\setbeamertemplate{frametitle}
{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
    {\strut\color{black}\bfseries\insertframetitle\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
    \vskip-1.5ex%
    \rule{\dimexpr\paperwidth-0.6cm\relax}{0.4pt}}
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
    %
}
\makeatother

\begin{document}


\begin{frame}[fragile]
    \begin{center}
    \Huge{\textbf{Abjad's core object model}}
    \end{center}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: leaves and containers
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: selections
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: simple attachments
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: spanners
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: spanners
}
Spanners can attach to containers:
<abjad>
staff = Staff("abj: | 1/4 c'4 || 2/4 d'8 e' f' g' || 1/4 a'4 |")
slur = Slur()
attach(slur, staff[1])  # This is the 2/4 measure.
show(staff)
</abjad>
<abjad>
staff[1].append(Note("cqs''"))
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's object model: spanners
}
Spanners can also attach directly to leaves:
<abjad>
staff = Staff("abj: | 1/4 c'4 || 2/4 d'8 e' f' g' || 1/4 a'4 |")
slur = Slur()
attach(slur, staff[1].select_leaves())
show(staff)
</abjad>
<abjad>
staff[1].append(Note("cqs''"))
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
    \begin{center}
    \Huge{\textbf{Abjad's top-level functions}}
    \end{center}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Abjad's top-level functions
}
\begin{columns}
    \Large
    \begin{column}{0.5\textwidth}
        \begin{itemize}
            \item \texttt{attach()}
            \item \texttt{detach()}
            \item \texttt{graph()}
            \item \texttt{inspect\_()}
            \item \texttt{iterate()}
            \item \texttt{mutate()}
            \item \texttt{new()}
        \end{itemize}
    \end{column}
    \begin{column}{0.5\textwidth}
        \begin{itemize}
            \item \texttt{override()}
            \item \texttt{parse()}
            \item \texttt{persist()}
            \item \texttt{play()}
            \item \texttt{select()}
            \item \texttt{set\_()}
            \item \texttt{show()}
        \end{itemize}
    \end{column}
\end{columns}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{inspect\_()} objects in a score
}
<abjad>
staff = Staff("abj: 5/4 { c'4 2/3 { d'16 e' f' } g'8 } 3/4 { a'8 b' c''4 }")
show(staff)
</abjad>
<abjad>
for leaf in staff.select_leaves():
    print leaf, inspect_(leaf).get_duration()
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{attach()} spanners to selections
}
Spanners include beams, slurs, glissandi, and other structure which \emph{span}
a group of score components in the same logical voice.
<abjad>
staff = Staff("c'8 d'8 r8 f'8 r4 g'8 <a' c'' e''>8")
for run in iterate(staff.select_leaves()).by_run((Note, Chord)):
    if 1 < len(run):
        attach(Slur(), run)
</abjad>
<abjad>
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{attach()} non-scoped typographic indicators
}
<abjad>
staff = Staff("c'4 ~ c'8 r16 d'16 ~ d'4 e'4")
iterator = iterate(staff.select_leaves()).by_logical_tie(pitched=True)
for logical_tie in iterator:
    accent = Articulation('accent')
    bend_after = indicatortools.BendAfter(-3.5)
    attach(accent, logical_tie.head)
    attach(bend_after, logical_tie.tail)
</abjad>
<abjad>
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{attach()} scoped typographic indicators
}
<abjad>

</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{attach()} arbitrary non-typographic objects with scope
}
<abjad>
staff = Staff("abj: | 3/8 c'4 d'8 || 2/4 g''8 fs'8 b8 a'8 |")
pitch_range = pitchtools.PitchRange(('C4', 'C5'))
attach(pitch_range, staff.select_leaves()[0], scope=Staff)
prototype = pitchtools.PitchRange
for note in iterate(staff).by_class(Note):
    if note.written_pitch not in inspect_(note).get_effective(prototype):
        override(note).note_head.color = 'red'

</abjad>
<abjad>
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{mutate()} score structures by splitting and transposing
}
<abjad>
staff = Staff("c'4 d'4 e'4 f'4")
for i, shard in enumerate(mutate(staff[:]).split(
    [Duration(5, 32)], 
    cyclic=True,
    tie_split_notes=False,
    )):
    mutate(shard).transpose(i)
    attach(Articulation('accent'), shard[0])
</abjad>
<abjad>
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{mutate()} score structures by fusing measures
}
<abjad>
staff = Staff("abj: | 2/4 c'4 d'4 || 2/4 e'4 f'4 |")
show(staff)
</abjad>
<abjad>
mutate(staff[:]).fuse()
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{mutate()} score structures by fusing tuplets
}
<abjad>
staff = Staff("abj: 2/3 { c'8 d'8 e'8} 2/3 { f'8 d'8 e'8 }")
show(staff)
</abjad>
<abjad>
mutate(staff[:]).fuse()
show(staff)
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{persist()} score objects to disk
}
Any object implementing \texttt{\_\_illustrate\_\_} can be shown (via
\texttt{show()}), played (via \texttt{play()}), or persisted (via
\texttt{persist()}) as a LilyPond .ly, PDF or MIDI file.
<abjad>
staff = Staff("c'4 d'4 e'4 f'4")
</abjad>
<abjad>
status = persist(staff).as_ly('example.ly')
</abjad>
<abjad>
status = persist(staff).as_pdf('example.pdf')
</abjad>
<abjad>
status = persist(staff).as_midi('example.midi')
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{persist()} Abjad data structures as Python modules
}
<abjad>
timespan_inventory = timespantools.TimespanInventory([
    timespantools.Timespan(0, 4),
    timespantools.Timespan(3, 10),
    ])
</abjad>
<abjad>
status = persist(timespan_inventory).as_module('example.py', 'object_name')
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    \texttt{persist()} Abjad data structures as Python modules
}
<abjad>
with open('example.py', 'r') as f:
    print f.read()
</abjad>
\end{frame}


\begin{frame}[fragile]
    \begin{center}
    \Huge{\textbf{High-level score-creation techniques}}
    \end{center}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Using \emph{makers} to create musical materials
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Templating \emph{makers} with \texttt{new()}    
}
\end{frame}



\begin{frame}[fragile]
\frametitle{
    Modeling time with timespans and timespan inventories
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Laying-out compositions with annotated timespans
}
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Creating time signature sequences from offset counters
}
<abjad>[hide=true]
timespans = [
    timespantools.Timespan(0, (1, 8)),
    timespantools.Timespan(1, (5, 4)),
    ]
</abjad>
<abjad>
timespan_inventory = timespantools.TimespanInventory(timespans)
offset_counter = timespan_inventory.count_offsets()
possible_meters = [(4, 4), (3, 4), (5, 8), (7, 16)]
meters = metertools.Meter.fit_meters_to_expr(
    possible_meters,
    offset_counter,
    )
time_signatures = [meter.implied_time_signature for meter in meters]
</abjad>
\end{frame}


\begin{frame}[fragile]
\frametitle{
    Rewriting rhythms to match metrical hierarchies
}
<abjad>[scale=0.75]
string = "abj: | 2/4 r8 c'4 r8 || 3/8 d'16. a8. g'16. ~ |"
string += "| 5/8 g'16 d'4. e'16 f'8 |"
staff = Staff(string)
show(staff)
</abjad>
<abjad>[scale=0.75]
for measure in staff:
    mutate(measure[:]).rewrite_meter(measure.time_signature)

show(staff)
</abjad>
\end{frame}


\end{document}
