DavidKinder / Windows-Frotz

Z-code interpreter for Windows, based on Stefan Jokisch's Frotz interpreter core.
http://www.davidkinder.co.uk/frotz.html
GNU General Public License v2.0
58 stars 12 forks source link

Speech and sound improvements #4

Open DavidKinder opened 5 years ago

DavidKinder commented 5 years ago

Suggestions from Nikita Tseykovets:

mcgsegur commented 8 months ago

You can make the TTS more 'dynamic" and "confortable" by stopping any current TTS text being rendered when you send a new one to be spoken (when you type a new request). This way you can avoid listening to the same WHOLE text you already heard before when REENTERING a "room", as a new "command" will "discard the queued sentences being spoken". This is easily done by changing the source code in "FrotzSound.cpp" in two points:

typedef enum SPEAKFLAGS {
  SPF_ASYNC = (1L<<0),
  SPF_PURGEBEFORESPEAK = (1L << 1)
} SPEAKFLAGS;

and

// Speak some text
void TextToSpeech::Speak(LPCWSTR speech)
{
  if (m_voice != NULL)
    m_voice->Speak(speech,SPF_ASYNC | SPF_PURGEBEFORESPEAK,NULL);
}

and just to deal correctly with the loading of a "new adventure", just change FrotzApp.cpp like this:

// Load a new game
void FrotzApp::OnFileNew() 
{
  if (PromptForGame(false))
  {
  // code added
    FrotzSound::ShutDown();
    m_spokenIndex = 0;
  //
    StoreWindowSize();
    m_wantRestart = true;
    theWnd->InputType(FrotzWnd::Input::CheckRestart);
  }
}