]> git.mxchange.org Git - flightgear.git/blob - src/Sound/soundgenerator.hxx
Flight-history men usage cap.
[flightgear.git] / src / Sound / soundgenerator.hxx
1 // soundgenerator.hxx -- simple sound generation \r
2 //\r
3 // Written by Curtis Olson, started March 2001.\r
4 //\r
5 // Copyright (C) 2001  Curtis L. Olson - http://www.flightgear.org/~curt\r
6 //\r
7 // This program is free software; you can redistribute it and/or\r
8 // modify it under the terms of the GNU General Public License as\r
9 // published by the Free Software Foundation; either version 2 of the\r
10 // License, or (at your option) any later version.\r
11 //\r
12 // This program is distributed in the hope that it will be useful, but\r
13 // WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
15 // General Public License for more details.\r
16 //\r
17 // You should have received a copy of the GNU General Public License\r
18 // along with this program; if not, write to the Free Software\r
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
20 //\r
21 \r
22 \r
23 #ifndef _FGSOUNDGENERATOR_HXX\r
24 #define _FGSOUNDGENERATOR_HXX\r
25 \r
26 #ifdef HAVE_CONFIG_H\r
27 #  include <config.h>\r
28 #endif\r
29 \r
30 class FGSoundGenerator {\r
31 \r
32 public:\r
33     static const int BYTES_PER_SECOND = 22050;\r
34     // static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)\r
35     static const int BEAT_LENGTH = 92;  // milleseconds (13 wpm)\r
36     static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);\r
37     static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;\r
38     static const int DIT_SIZE = 2 * COUNT_SIZE;   // 2 counts\r
39     static const int DAH_SIZE = 4 * COUNT_SIZE;   // 4 counts\r
40     static const int SPACE_SIZE = 3 * COUNT_SIZE; // 3 counts\r
41     static const int LO_FREQUENCY = 1020;        // AIM 1-1-7 (f) specified in Hz\r
42     static const int HI_FREQUENCY = 1350;        // AIM 1-1-7 (f) specified in Hz\r
43 \r
44 protected:\r
45     /**\r
46     * \relates FGMorse\r
47     * Make a tone of specified freq and total_len with trans_len ramp in\r
48     * and out and only the first len bytes with sound, the rest with\r
49     * silence.\r
50     * @param buf unsigned char pointer to sound buffer\r
51     * @param freq desired frequency of tone\r
52     * @param len length of tone within sound\r
53     * @param total_len total length of sound (anything more than len is padded\r
54     *        with silence.\r
55     * @param trans_len length of ramp up and ramp down to avoid audio "pop"\r
56     */\r
57     static void make_tone( unsigned char *buf, int freq, \r
58         int len, int total_len, int trans_len );\r
59 \r
60 public:\r
61 \r
62     virtual ~FGSoundGenerator();\r
63 };\r
64 \r
65 \r
66 \r
67 #endif // _FGSOUNDGENERATOR_HXX\r