]> git.mxchange.org Git - flightgear.git/blob - src/ATC/ATCVoice.hxx
Changes to support voice rendering of ATC
[flightgear.git] / src / ATC / 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #ifndef _FG_ATC_VOICE
22 #define _FG_ATC_VOICE
23
24 #include <simgear/compiler.h>
25
26 #ifdef SG_HAVE_STD_INCLUDES
27 #  include <fstream>
28 #  include <iostream>
29 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
30 #  include <fstream.h>
31 #  include <iostream.h>
32 #elif defined( __BORLANDC__ ) || (__APPLE__)
33 #  include <fstream>
34 #  include <iostream>
35 #else
36 #  include <fstream.h>
37 #  include <iostream.h>
38 #endif
39
40 #include <map>
41 #include <list>
42 #include <string>
43
44 SG_USING_STD(map);
45 SG_USING_STD(list);
46 SG_USING_STD(string);
47 SG_USING_STD(cout);
48 SG_USING_STD(ios);
49
50 #if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
51 SG_USING_STD(ofstream);
52 SG_USING_STD(ifstream);
53 #endif
54
55 /*****************************************************************
56
57 Warning.
58
59 Assumptions inherent in this class are that char is 1 byte length,
60 short int is 2 byte length and int is 4 byte length.
61
62 ******************************************************************/
63
64 struct WordData {
65         unsigned int offset;    // Offset of beginning of word sample into raw sound sample
66         unsigned int length;    // Byte length of word sample
67 };
68
69 typedef map < string, WordData > atc_word_map_type;
70 typedef atc_word_map_type::iterator atc_word_map_iterator;
71 typedef atc_word_map_type::const_iterator atc_word_map_const_iterator;
72
73 class FGATCVoice {
74         
75 public:
76
77         FGATCVoice();
78         ~FGATCVoice();
79
80         // Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
81         // Return true if successful.   
82         bool LoadVoice(string voice);
83         
84         // Given a desired message, return a pointer to the data buffer and write the buffer length into len.
85         // Sets dataOK = true if the returned buffer is valid.
86         unsigned char* WriteMessage(char* message, int& len, bool& dataOK);
87         
88         
89 private:
90
91         // the sound and word position data
92         char* rawSoundData;
93         unsigned int rawDataSize;
94         
95         // A map of words vs. byte position and length in rawSoundData
96         atc_word_map_type wordMap;
97
98 };
99
100 #endif  // _FG_ATC_VOICE