]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/ATCVoice.hxx
httpd: don't spam the console with debug messages
[flightgear.git] / src / ATCDCL / ATCVoice.hxx
1 // FGATCVoice.hxx - a class to encapsulate an ATC voice
2 //
3 // Written by David Luff, started November 2002.
4 //
5 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
6 //
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.
11 //
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.
16 //
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.
20
21 #ifndef _FG_ATC_VOICE
22 #define _FG_ATC_VOICE
23
24 #include <simgear/compiler.h>
25 #include <simgear/structure/SGSharedPtr.hxx>
26
27 #include <map>
28 #include <string>
29
30 class SGSoundSample;
31 class SGPath;
32
33 struct WordData {
34         unsigned int offset;    // Offset of beginning of word sample into raw sound sample
35         unsigned int length;    // Byte length of word sample
36 };
37
38 typedef std::map < std::string, WordData > atc_word_map_type;
39 typedef atc_word_map_type::iterator atc_word_map_iterator;
40 typedef atc_word_map_type::const_iterator atc_word_map_const_iterator;
41
42 class FGATCVoice {
43
44 public:
45
46         FGATCVoice();
47         ~FGATCVoice();
48
49         // Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
50         // Return true if successful.   
51         bool LoadVoice(const std::string& voicename);
52         
53         // Given a desired message, return a pointer to the data buffer and write the buffer length into len.
54         // Sets len to something other than 0 if the returned buffer is valid.
55         void* WriteMessage(const std::string& message, size_t *len);
56
57 private:
58         bool AppendVoiceFile(const SGPath& basepath, const std::string& file);
59         bool ParseVoiceIndex(const SGPath& basepath, const std::string& file, size_t globaloffset);
60
61         // the sound and word position data
62         char* rawSoundData;
63         size_t rawDataSize;
64         SGSharedPtr<SGSoundSample> SoundData;
65
66         // A map of words vs. byte position and length in rawSoundData
67         atc_word_map_type wordMap;
68
69 };
70
71 #endif  // _FG_ATC_VOICE