X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSound%2Fbeacon.cxx;h=1f9d6b30612fedf2a328a085a557cbdc18d0ef9a;hb=1ae2b59333dc914d10bcc726bc94e71cbf3e411e;hp=3da3843f9f7f0997c693289f46876fa523f26672;hpb=51c04e9e4c4d2ecc0f3ee0a6d3559d1e22e247c5;p=flightgear.git diff --git a/src/Sound/beacon.cxx b/src/Sound/beacon.cxx index 3da3843f9..1f9d6b306 100644 --- a/src/Sound/beacon.cxx +++ b/src/Sound/beacon.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started March 2001. // -// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -16,16 +16,18 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ #include "beacon.hxx" +#include // constructor -FGBeacon::FGBeacon() { +FGBeacon::FGBeacon() +{ } // destructor @@ -39,6 +41,10 @@ bool FGBeacon::init() { int len; unsigned char *ptr; + unsigned char inner_buf[ INNER_SIZE ] ; + unsigned char middle_buf[ MIDDLE_SIZE ] ; + unsigned char outer_buf[ OUTER_SIZE ] ; + // Make inner marker beacon sound len= (int)(INNER_DIT_LEN / 2.0 ); unsigned char inner_dit[INNER_DIT_LEN]; @@ -51,38 +57,48 @@ bool FGBeacon::init() { ptr += INNER_DIT_LEN; } - inner = new SGSimpleSound( inner_buf, INNER_SIZE ); - - // Make middle marker beacon sound - len= (int)(MIDDLE_DIT_LEN / 2.0 ); - unsigned char middle_dit[MIDDLE_DIT_LEN]; - make_tone( middle_dit, MIDDLE_FREQ, len, MIDDLE_DIT_LEN, - TRANSITION_BYTES ); - - len= (int)(MIDDLE_DAH_LEN * 3 / 4.0 ); - unsigned char middle_dah[MIDDLE_DAH_LEN]; - make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN, - TRANSITION_BYTES ); - - ptr = middle_buf; - memcpy( ptr, middle_dit, MIDDLE_DIT_LEN ); - ptr += MIDDLE_DIT_LEN; - memcpy( ptr, middle_dah, MIDDLE_DAH_LEN ); - - middle = new SGSimpleSound( middle_buf, MIDDLE_SIZE ); - - // Make outer marker beacon sound - len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 ); - unsigned char outer_dah[OUTER_DAH_LEN]; - make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN, - TRANSITION_BYTES ); - - ptr = outer_buf; - memcpy( ptr, outer_dah, OUTER_DAH_LEN ); - ptr += OUTER_DAH_LEN; - memcpy( ptr, outer_dah, OUTER_DAH_LEN ); - - outer = new SGSimpleSound( outer_buf, OUTER_SIZE ); + try { + inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND ); + inner->set_reference_dist( 10.0 ); + inner->set_max_dist( 20.0 ); + + // Make middle marker beacon sound + len= (int)(MIDDLE_DIT_LEN / 2.0 ); + unsigned char middle_dit[MIDDLE_DIT_LEN]; + make_tone( middle_dit, MIDDLE_FREQ, len, MIDDLE_DIT_LEN, + TRANSITION_BYTES ); + + len= (int)(MIDDLE_DAH_LEN * 3 / 4.0 ); + unsigned char middle_dah[MIDDLE_DAH_LEN]; + make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN, + TRANSITION_BYTES ); + + ptr = middle_buf; + memcpy( ptr, middle_dit, MIDDLE_DIT_LEN ); + ptr += MIDDLE_DIT_LEN; + memcpy( ptr, middle_dah, MIDDLE_DAH_LEN ); + + middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND ); + middle->set_reference_dist( 10.0 ); + middle->set_max_dist( 20.0 ); + + // Make outer marker beacon sound + len= (int)(OUTER_DAH_LEN * 3.0 / 4.0 ); + unsigned char outer_dah[OUTER_DAH_LEN]; + make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN, + TRANSITION_BYTES ); + + ptr = outer_buf; + memcpy( ptr, outer_dah, OUTER_DAH_LEN ); + ptr += OUTER_DAH_LEN; + memcpy( ptr, outer_dah, OUTER_DAH_LEN ); + + outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND); + outer->set_reference_dist( 10.0 ); + outer->set_max_dist( 20.0 ); + } catch ( sg_io_exception &e ) { + SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage()); + } return true; }