]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/morse.hxx
Flight-history men usage cap.
[flightgear.git] / src / Sound / morse.hxx
index c4038fcac9fd17d1a4aef8d9dcf51b5b310325f8..c5fe7cc8fa217039e53210e2691a914a6d4453ca 100644 (file)
@@ -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
 //
 // 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$
 
 
 #ifndef _MORSE_HXX
 #define _MORSE_HXX
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
+#include "soundgenerator.hxx"
 #include <simgear/compiler.h>
-
-#include <plib/sl.h>
-#include <plib/sm.h>
-
-#include "soundmgr.hxx"
+#include <simgear/sound/soundmgr_openal.hxx>
 
 
 // Quoting from http://www.kluft.com/~ikluft/ham/morse-intro.html by
 // Hz for the VOR ident.
 
 
-static const char DI = '1';
-static const char DIT = '1';
-static const char DA = '2';
-static const char DAH = '2';
-static const char end = '0';
-
-static const int BYTES_PER_SECOND = 8000;
-static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
-// static const int BEAT_LENGTH = 92;  // milleseconds (13 wpm)
-static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
-static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
-static const int DIT_SIZE = 2 * COUNT_SIZE;   // 2 counts
-static const int DAH_SIZE = 4 * COUNT_SIZE;   // 4 counts
-static const int SPACE_SIZE = 3 * COUNT_SIZE; // 3 counts
-static const int FREQUENCY = 1020;      // AIM 1-1-7 (f) specified in Hz
-
 // manages everything we need to know for an individual sound sample
-class FGMorse {
+class FGMorse : public FGSoundGenerator {
+
+private:
 
-    unsigned char dit[ DIT_SIZE ] ;
-    unsigned char dah[ DAH_SIZE ] ;
+    unsigned char hi_dit[ DIT_SIZE ] ;
+    unsigned char lo_dit[ DIT_SIZE ] ;
+    unsigned char hi_dah[ DAH_SIZE ] ;
+    unsigned char lo_dah[ DAH_SIZE ] ;
     unsigned char space[ SPACE_SIZE ] ;
 
+    unsigned char cust_dit[ DIT_SIZE ] ;
+    unsigned char cust_dah[ DAH_SIZE ] ;
+
+    static FGMorse * _instance;
+
+    bool cust_init( const int freq );
+    // allocate and initialize sound samples
+    bool init();
+
 public:
+    static const int BYTES_PER_SECOND = 22050;
+    // static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
+    static const int BEAT_LENGTH = 92;  // milleseconds (13 wpm)
+    static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
+    static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
+    static const int DIT_SIZE = 2 * COUNT_SIZE;   // 2 counts
+    static const int DAH_SIZE = 4 * COUNT_SIZE;   // 4 counts
+    static const int SPACE_SIZE = 3 * COUNT_SIZE; // 3 counts
+    static const int LO_FREQUENCY = 1020;       // AIM 1-1-7 (f) specified in Hz
+    static const int HI_FREQUENCY = 1350;       // AIM 1-1-7 (f) specified in Hz
+
 
     FGMorse();
     ~FGMorse();
 
-    // allocate and initialize sound samples
-    bool init();
+    static FGMorse * instance();
 
-    // make a FGSimpleSound morse code transmission for the specified string
-    FGSimpleSound *make_ident( const string& id );
+    // make a SimpleSound morse code transmission for the specified string
+    SGSoundSample *make_ident( const std::string& id,
+                               const int freq = LO_FREQUENCY );
 };
 
 
+
 #endif // _MORSE_HXX