[comp.object] sound-text synchronizing

jrscs@uno.edu (12/18/90)

   I am working on a text-to-speech conversion program on the NeXT computer
system using Interface Builder.  Everything is coming along fine except for
one problem which I hope someone can help me with.  I am having difficulty
synchronizing the highlighting of a word in a window with actually saying the
word.  As of now, the relevant code looks like the following:

- readReaderFile
{
  char  aWord[ 50 ];
  int   startPos = 0 ,
        endPos;

  while ( [ self getWordBoundaries:&startPos :&endPos ] == YES )
  {
    [ [ theDocument docView ] setSel:startPos :endPos ];
    [ [ theDocument docView ] getSubstring:aWord start:startPos length:.... ];
    speak( aWord , endPos - startPos );
    startPos = endPos - 1;
  }

  return self;
}

*** NOTE : The text is contained in a ScrollView's docView, and hence the
           "[ theDocument docView ]" command.

For a short file, what happens is all of the words are spoken first and then
the selections are executed.  If I put the "[ .... setSel .... ]" line in a
loop to execute for about ten times, then two words are spoken and one is
highlighted, two are spoken and one is highlighted, ....  There must be a way
around this.  I think one approach might entail using delegates for the sound
object which stores the sound data for each word: "willPlay" and "didPlay".
But, I can't seem to hook things together.  Can someone please give me an idea
on how I can solve this problem.