]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/morse.hxx
Latest YASim changes.
[flightgear.git] / src / Sound / morse.hxx
index c4038fcac9fd17d1a4aef8d9dcf51b5b310325f8..1fcb482cdea30e092c5cb900d091818c8c46428b 100644 (file)
@@ -90,22 +90,32 @@ 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 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
+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
 
 // manages everything we need to know for an individual sound sample
 class FGMorse {
 
-    unsigned char dit[ DIT_SIZE ] ;
-    unsigned char dah[ DAH_SIZE ] ;
+private:
+
+    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 ] ;
+
+    bool cust_init( const int freq );
+
 public:
 
     FGMorse();
@@ -115,10 +125,26 @@ public:
     bool init();
 
     // make a FGSimpleSound morse code transmission for the specified string
-    FGSimpleSound *make_ident( const string& id );
+    FGSimpleSound *make_ident( const string& id,
+                              const int freq = LO_FREQUENCY );
 };
 
 
+/**
+ * \relates FGMorse
+ * Make a tone of specified freq and total_len with trans_len ramp in
+ * and out and only the first len bytes with sound, the rest with
+ * silence.
+ * @param buf unsigned char pointer to sound buffer
+ * @param freq desired frequency of tone
+ * @param len length of tone within sound
+ * @param total_len total length of sound (anything more than len is padded
+ *        with silence.
+ * @param trans_len length of ramp up and ramp down to avoid audio "pop"
+ */
+void make_tone( unsigned char *buf, int freq, 
+               int len, int total_len, int trans_len );
+
 #endif // _MORSE_HXX