After the very productive outcome of my recent question on intonation, I'm emboldened to ask a related question. In the previous one, particular pitchlevels are connected to produce an intonation contour, but for tone languages (where each syllable in a word usually has a particular pitch associated with it, a different approach is needed, where the pitchlevels are indicated by small horizontal lines. I have a couple of approaches to this that already work, and I have now created a new TikZ one based on Matthew Leingang's approach to the earlier question, but I'm sure improvements are possible. The options are set out in the MWE below, using examples from kiKongo, an African Bantu language.
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text, Scale=MatchLowercase}
\setmainfont{Charis SIL}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\newcommand{\tikzpitch}[1]{\tikz[overlay, remember picture, baseline] \coordinate (#1);}%
\tikzstyle{pitchlevel}=[x=1mm, y=1mm, yshift=-7mm, semithick]
% Charis SIL pitchlevel glyphs
\newcommand \pitch[1]{\char"F1F#1} % use \pitch1..9 to generate the 9 pitch-level marks fromthe glyphs F1F{1..9}
% John Frampton's pitchlevels code
\usepackage{pstricks}
\newdimen\dimpla
\newdimen\dimplb
\newdimen\dimplc
\def\1{\contourpitch{-2.5ex}{-2.5ex}}
\def\2{\contourpitch{-2.1ex}{-2.1ex}}
\def\3{\contourpitch{-1.7ex}{-1.7ex}}
\def\4{\contourpitch{-1.3ex}{-1.3ex}}
\def\5{\contourpitch{-.9ex}{-.9ex}}
\def\6{\contourpitch{-.5ex}{-.5ex}}
% level pitches
\def\contourpitch #1#2#3{\setbox0=\hbox{#3}\dimpla=.5\wd0 \dimplb=.5\wd0
\advance\dimpla by -.25em
\advance\dimplb by .25em
\dimplc=#1
\ifdim#2<#1 \dimplc=#2 \fi
\dimplc=-\dimplc
\advance\dimplc by 1ex
\psline(\dimpla,#1)(\dimplb,#2)
\vrule width0pt depth\the\dimplc #3}
% glides
\def\pitchup{\contourpitch{-2.5ex}{-1.7ex}}
\def\pitchdown{\contourpitch{-1.7ex}{-2.5ex}}
\def\steepup{\contourpitch{-2.5ex}{-.5ex}}
% format fbox
\setlength\fboxsep{1pt}
\begin{document}
% generate glides in Charis SIL
\fontspec[Renderer=Graphite]{Charis SIL}
\section{Pitchlevel marking using xelatex}
In Africanist linguistics, pitchlevel marks are often used so that the pitches can be discussed without drawing premature conclusions as to how these pitches should be represented in the eventual tone-marking.
\subsection{Word-side (inline) marking}
The example of \textbf{ibuuna [~\pitch1\, \pitch9\pitch9\, \pitch1~]} (\textit{so}) can be used to show inline marking of individual words. This solution uses the pitchlevel glyphs in Charis SIL. Glide variants are possible:
[~\pitch1\, \pitch9\, \pitch1\pitch5~]
[~\pitch1\, \pitch9\, \pitch1\pitch1\pitch5~]
[~\pitch1\, \pitch9\, \pitch1\pitch1\pitch5\pitch5~]
[~\pitch1\, \pitch9\, \pitch1\pitch5\pitch5~]
\bigskip
\noindent An alternative solution to the same issue of showing \noindent \textbf{ibuuna} [ \tikz\draw[x=1mm, y=1mm, semithick](0,0)--(1.5,0) (2.5,2)--(5,2) (6,0)--(7.5,0); ] uses TikZ. Glide variants are also possible here:
[ \tikz\draw[x=1mm, y=1mm, semithick](0,0)--(1.5,0) (2.5,2)--(5,2) (6,0)--(7.5,1); ]
[ \tikz\draw[x=1mm, y=1mm, semithick](0,0)--(1.5,0) (2.5,2)--(5,2) (6,0)--(7.5,0)--(8.5,1); ]
[ \tikz\draw[x=1mm, y=1mm, semithick](0,0)--(1.5,0) (2.5,2)--(5,2) (6,0)--(7.5,0)--(8.5,1)--(10,1); ]
[ \tikz\draw[x=1mm, y=1mm, semithick](0,0)--(1.5,0) (2.5,2)--(5,2) (6,0)--(7.5,1)--(9,1); ]
\subsection{Parallel marking}
\subsubsection{Using Charis font features}
\noindent ibuuna · basiidi kilumbu · ki-bakweenda kuna-kiziitu \\
\pitch1~~\pitch9\pitch9~~\pitch1~~~\pitch1~~\pitch9~~\pitch7~~\pitch5~\pitch3~~~~~\pitch1\pitch5 ~~~~\pitch1~~~\pitch1~~~~\pitch9\pitch9~~~\pitch8~~~\pitch4~~\pitch1~~~\pitch5~\pitch5~\fbox{\pitch1\pitch5} \\
\textit{so · they set aside a day · on which they would go to the in-laws \dots}
\subsubsection{Using pstricks}
\noindent\1ib\5u\5un\1a · b\1as\5i\5id\4i k\3il\2umb\pitchup u · k\1i-b\1akw\5e\5end\4a k\3un\1a-k\3iz\3i\3it\fbox{\pitchup u}\\
\textit{so · they set aside a day · on which they would go to the in-laws \dots}
\subsubsection{Using TikZ}
\noindent\begin{tikzpicture}[remember picture]
\node{\tikzpitch{1}ib\tikzpitch{2}u\tikzpitch{3}un\tikzpitch{4}a · b\tikzpitch{5}as\tikzpitch{6}iid\tikzpitch{7}i k\tikzpitch{8}il\tikzpitch{9}umb\tikzpitch{10}u · k\tikzpitch{11}i-b\tikzpitch{12}akw\tikzpitch{13}eend\tikzpitch{14}a k\tikzpitch{15}un\tikzpitch{16}a-k\tikzpitch{17}iz\tikzpitch{18}iit\tikzpitch{19}u}; \\
\draw[pitchlevel] (1 |- 0,0)--+(2,0) (2 |- 0, 4.5)--+(2,0) (3 |- 0, 4.5)--+(2,0) (4 |- 0, 0)--+(2,0) (5 |- 0,0)--+(2,0) (6 |- 0, 4.5)--+(2,0) (7 |- 0, 4)--+(2,0) (8 |- 0, 3)--+(2,0) (9 |- 0,1.5)--+(2,0) (10 |- 0, 0)--+(1,0.5)--+(2,1.5) (11 |- 0,0)--+(2,0) (12 |- 0, 0)--+(2,0) (13 |- 0, 4.5)--+(3,0) (14 |- 0, 3.5)--+(2,0) (15 |- 0,3)--+(2,0) (16 |- 0, 1)--+(2,0) (17 |- 0, 3)--+(2,0) (18 |- 0, 3)--+(2,0) (19 |- 0,0)--+(1,0.5)--+(2,1.5);
\end{tikzpicture}\\
\mbox{\textit{so · they set aside a day · on which they would go to the in-laws \dots}}
\end{document}

The inline marking (1.1) is simple. Re the three versions of parallel marking (1.2):
1.2.1: Charis SIL can only be used with XeTeX. (For LaTeX there is an alternative approach using the tipa package and some additional code - see this question.) This appears to be the only font currently which contains these glyphs (in its Private Use Area), but in practice this is unlikely to be a problem. The main issue is that, as in the intonation question, it is necessary to use trial-and-error to space the glyphs to match the words. One benefit is that it is possible to use \fbox to highlight a particular pitch.
1.2.2: The pstricks code was kindly offered by John Frampton, author of expex. The main benefit is that it embeds the pitch levels into the text, making it easier to write out the example. An \fbox can be used to highlight a pitch (though it also marks the letter as well, which is less visually attractive). The pitchlevel lines are also "sharper" than in the other two options. As against that, it is slower to compile, and the current code does not allow word-side (inline) pitch marking. (It doesn't seem to work with LaTeX either, but perhaps that's just me.)
1.2.3: This is something I've put together by molesting Matthew Leingang's solution to the intonation question (I wouldn't even know where to start on mwibrow's more comprehensive code!). All I'm doing is getting the coordinate, and then drawing a line from that to a point 2mm to the right. (Ideally, I would draw 1mm each side of the coordinate, but how?) This actually works quite well - in particular, glides can be specified in more detail. However, as it stands, it needs two compiles because of remember picture, and I have no way of highlighting a pitch. Also, the kiKongo text seems to be indented slightly for some reason.
So all of these work, but I'd be interested in any suggestions for improvements, in particular, for tidying up the TikZ solution, since that works for both LaTeX and XeTeX, and is font-independent.

\contourcontourpathcommandcode, which in effect allows any sort of squiggle to be generated and used as a pitchmark, so the system is very versatile. I've tested various entry characters here, and since, < > : ; @ ^ ( ) - _ = 'all work, there is plenty of scope for expansion. Thank you so much for this! – donnek Apr 16 '13 at 08:21