1.4 Extending AS TE R

The quality of audio renderings produced by AS TE R depends on how much of the document logical structure is recognized. Authors of (LA)TEX documents often use their own macros8 to encapsulate specific logical structures. Of course, AS TE R does not initially know of these extensions. User-defined (LA)TEX macros are initially rendered in a canonical way; typically, they are spoken as they appear in the running text. Thus, given a document containing

$A \kronecker B$

AS TE R would say

cap a kronecker cap b

In this case, this canonical rendering is quite acceptable.

In general, how AS TE R renders such user-defined structures is fully customizable. The first step is to extend the recognizer to handle the new construct, in this case, \kronecker. Section 2.4 explains the principles on which such extensions are based. Here, we give the reader a brief example of how this mechanism is used in practice.

The recognizer is extended by calling Lisp macro define-text-object as follows:

  (define-text-object :macro-name "kronecker" :number-args 0

  :processing-function kronecker-expand

  :object-name kronecker

  :supers (binary-operator) :precedence  multiplication)

This extends the recognizer; instances of macro \kronecker are represented by object kronecker. The user can now define any number of renderings for instances of object kronecker.

AFL (see Chapter 3), our language for audio formatting, is used to define rendering rules (see Chapter 4). Here is one such rendering rule for object kronecker:

  (def-reading-rule (kronecker simple)

      "Simple rendering rule for object kronecker."

    (read-aloud "kronecker product of ")

    (read-aloud (first (children kronecker)))

    (read-aloud " and ")

    (read-aloud (second (children kronecker))))

AS TE R would now speak $A \kronecker B$ as

kronecker product of cap a and cab b.

Notice that the order in which the elements of A B are spoken is independent of the order in which they appear on paper. AS TE R derives its power from representing document content as objects and by allowing multiple user-defined rendering rules for individual object types. These rules can cause any number of audio events (ranging from speaking a simple phrase, to playing a digitized sound). Once the recognizer has been extended by an appropriate call to define-text-object, user-defined macros in (LA)TEX can be handled just as well as any standard (LA)TEX construct.

To give an example of this, the logo that appears on the first page of this chapter is produced by (LA)TEX macro \asterlogo. After extending the recognizer with an appropriate call to define-text-object, we can define an audio rendering rule that produces a bark when rendering instances of this macro.