Debian Codegraph @

src/Sound/soundgenerator.hxx

raw symbols SCIP
1 // soundgenerator.hxx -- simple sound generation
2 //
3 // Written by Curtis Olson, started March 2001.
4 //
5 // Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
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
22
23 #ifndef _FGSOUNDGENERATOR_HXX
24 #define _FGSOUNDGENERATOR_HXX
25
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29
30 class FGSoundGenerator {
31
32 public:
33 static const int BYTES_PER_SECOND = 22050;
34 // static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
35 static const int BEAT_LENGTH = 92; // milleseconds (13 wpm)
36 static const int TRANSITION_BYTES = BYTES_PER_SECOND/200; // aka (int)(0.005 * BYTES_PER_SECOND);
37 static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
38 static const int DIT_SIZE = 2 * COUNT_SIZE; // 2 counts
39 static const int DAH_SIZE = 4 * COUNT_SIZE; // 4 counts
40 static const int SPACE_SIZE = 3 * COUNT_SIZE; // 3 counts
41 static const int LO_FREQUENCY = 1020; // AIM 1-1-7 (f) specified in Hz
42 static const int HI_FREQUENCY = 1350; // AIM 1-1-7 (f) specified in Hz
43
44 protected:
45 /**
46 * \relates FGMorse
47 * Make a tone of specified freq and total_len with trans_len ramp in
48 * and out and only the first len bytes with sound, the rest with
49 * silence.
50 * @param buf unsigned char pointer to sound buffer
51 * @param freq desired frequency of tone
52 * @param len length of tone within sound
53 * @param total_len total length of sound (anything more than len is padded
54 * with silence.
55 * @param trans_len length of ramp up and ramp down to avoid audio "pop"
56 */
57 static void make_tone( unsigned char *buf, int freq,
58 int len, int total_len, int trans_len );
59
60 public:
61
62 virtual ~FGSoundGenerator();
63 };
64
65
66
67 #endif // _FGSOUNDGENERATOR_HXX