1 // beacon.cxx -- Morse code generation class
3 // Written by Curtis Olson, started March 2001.
5 // Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 FGBeacon::FGBeacon() {
32 FGBeacon::~FGBeacon() {
36 // allocate and initialize sound samples
37 bool FGBeacon::init() {
42 // Make inner marker beacon sound
43 len= (int)(INNER_DIT_LEN / 2.0 );
44 unsigned char inner_dit[INNER_DIT_LEN];
45 make_tone( inner_dit, INNER_FREQ, len, INNER_DIT_LEN,
49 for ( i = 0; i < 6; ++i ) {
50 memcpy( ptr, inner_dit, INNER_DIT_LEN );
54 inner = new FGSimpleSound( inner_buf, INNER_SIZE );
56 // Make middle marker beacon sound
57 len= (int)(MIDDLE_DIT_LEN / 2.0 );
58 unsigned char middle_dit[MIDDLE_DIT_LEN];
59 make_tone( middle_dit, MIDDLE_FREQ, len, MIDDLE_DIT_LEN,
62 len= (int)(MIDDLE_DAH_LEN * 3 / 4.0 );
63 unsigned char middle_dah[MIDDLE_DAH_LEN];
64 make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN,
68 memcpy( ptr, middle_dit, MIDDLE_DIT_LEN );
69 ptr += MIDDLE_DIT_LEN;
70 memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
72 middle = new FGSimpleSound( middle_buf, MIDDLE_SIZE );
74 // Make outer marker beacon sound
75 len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 );
76 unsigned char outer_dah[OUTER_DAH_LEN];
77 make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN,
81 memcpy( ptr, outer_dah, OUTER_DAH_LEN );
83 memcpy( ptr, outer_dah, OUTER_DAH_LEN );
85 outer = new FGSimpleSound( outer_buf, OUTER_SIZE );