1 // speech synthesis interface subsystem
3 // Written by Melchior FRANZ, started February 2006.
5 // Copyright (C) 2006 Melchior FRANZ - mfranz@aon.at
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 #include <simgear/compiler.h>
33 #include <simgear/props/props.hxx>
34 #include <simgear/io/sg_socket.hxx>
35 #include <simgear/structure/subsystem_mgr.hxx>
37 #include <Main/fg_props.hxx>
39 #if defined(ENABLE_THREADS)
40 # include <simgear/threads/SGThread.hxx>
41 # include <simgear/threads/SGQueue.hxx>
45 #endif // ENABLE_THREADS
51 class FGVoiceMgr : public SGSubsystem {
56 void update(double dt);
61 #if defined(ENABLE_THREADS)
63 FGVoiceThread *_thread;
69 SGPropertyNode_ptr _pausedNode;
71 vector<FGVoice *> _voices;
76 #if defined(ENABLE_THREADS)
77 class FGVoiceMgr::FGVoiceThread : public SGThread {
79 FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {}
81 void wake_up() { _jobs.signal(); }
84 void wait_for_jobs() { SGGuard<SGMutex> g(_mutex); _jobs.wait(_mutex); }
93 class FGVoiceMgr::FGVoice {
95 FGVoice(FGVoiceMgr *, const SGPropertyNode_ptr);
99 void setVolume(double);
100 void setPitch(double);
101 void setSpeed(double);
102 void pushMessage(string);
105 class FGVoiceListener;
110 SGPropertyNode_ptr _volumeNode;
111 SGPropertyNode_ptr _pitchNode;
112 SGPropertyNode_ptr _speedNode;
116 #if defined(ENABLE_THREADS)
117 SGLockedQueue<string> _msg;
126 class FGVoiceMgr::FGVoice::FGVoiceListener : public SGPropertyChangeListener {
128 FGVoiceListener(FGVoice *voice) : _voice(voice) {}
129 void valueChanged(SGPropertyNode *node);