\end{haskelllisting}
\paragraph*{Set tempo.}
To make it easier to initialize the duration element
of a \code{PerformanceContext.T} (see \secref{performance}),
we can define a ``metronome'' function that,
given a standard metronome marking (in beats per minute)
and the note type associated with one beat (quarter note, eighth note, etc.)
generates the duration of one whole note:
\begin{haskelllisting}

>largoRange,larghettoRange,adagioRange,andanteRange,>moderatoRange,allegroRange,prestoRange,prestissimoRange>::Fractionala=>(a,a)>>largoRange=(40,60)-- slowly and broadly>larghettoRange=(60,68)-- a little less slow than largo>adagioRange=(66,76)-- slowly>andanteRange=(76,108)-- at a walking pace>moderatoRange=(108,120)-- at a moderate tempo>allegroRange=(120,168)-- quickly>prestoRange=(168,200)-- fast>prestissimoRange=(200,208)-- very fast>>>largo,larghetto,adagio,andante,moderato,allegro,>presto,prestissimo::Fractionala=>a>>average::Fractionala=>a->a->a>averagexy=(x+y)/2>>largo=uncurryaveragelargoRange>larghetto=uncurryaveragelarghettoRange>adagio=uncurryaverageadagioRange>andante=uncurryaverageandanteRange>moderato=uncurryaveragemoderatoRange>allegro=uncurryaverageallegroRange>presto=uncurryaverageprestoRange>prestissimo=uncurryaverageprestissimoRange

\end{haskelllisting}
\caption{Common names for tempo.}
\figlabel{tempos}
\end{figure}
% http://en.wikipedia.org/wiki/Tempo
% http://groups.google.de/groups?q=adagio+andante+allegro+bpm&hl=de&lr=&ie=UTF-8&selm=25919-385E77EA-28%40storefull-615.iap.bryant.webtv.net&rnum=5
\begin{figure*}
\centerline{
\includegraphics[height=2.0in]{Doc/Pics/poly}
}
\caption{Nested Polyrhythms}
\figlabel{polyrhythms}
\end{figure*}
\paragraph*{Polyrhythms.}
For some rhythmical ideas, consider first a simple \keyword{triplet} of
eighth notes; it can be expressed as ``\code{Tempo (3\%2) m}'', where
\code{m} is a line of three eighth notes. In fact \code{Tempo} can be
used to create quite complex rhythmical patterns. For example,
consider the ``nested polyrhythms'' shown in \figref{polyrhythms}.
They can be expressed quite naturally in Haskore as follows (note the
use of the \code{where} clause in \code{pr2} to capture recurring
phrases):
\begin{haskelllisting}

\end{haskelllisting}
To play polyrhythms \code{pr1} and \code{pr2} in parallel using middle C
and middle G, respectively, we would do the following (middle C is in
the 5th octave):
\begin{haskelllisting}

>pr12::Melody.T()>pr12=pr1(5,Pitch.C)=:=pr2(5,Pitch.G)

\end{haskelllisting}
\paragraph*{Symbolic Meter Changes}
We can implement a notion of ``symbolic meter changes'' of the form
``oldnote = newnote'' (quarter note = dotted eighth, for example) by
defining a function:
\begin{haskelllisting}