Exemple #1
0
    def send_text_message(self, msg):
        bmsg = '11010001' + fsk.encode_ascii(msg)
        byte = ''
        bytearray = []
        fs = self.RATE
        carrier = self.CARRIER
        Bd = self.BAUD

        for k, bit in enumerate(bmsg, start=1):
            if k % 8 == 0:
                byte += bit
                bytearray.append(byte)
                byte = ''
            else:
                byte += bit

        sys.stdout.write('### BAUD {} @ CARRIER {}Hz ###\n'.format(str(Bd), str(carrier)))
        sys.stdout.flush()
        s = fsk.set_frequency_header(np.zeros(0),Bd)
        sd.play(s, fs)
        status = sd.wait()

        for byte in bytearray:
            s = fsk.generate_tones(byte, fs, Bd, carrier)
            tone = s * (2**15 - 1) / np.max(np.abs(s))
            tone = tone.astype(np.int16)
            self.SIGNAL = tone
            sd.play(tone, fs)
            status = sd.wait()

        s = fsk.set_frequency_trailer(np.zeros(0),Bd)
        sd.play(s, fs)
        status = sd.wait()
Exemple #2
0
    def message_to_wav(self, msg):
        fs = self.RATE
        carrier = self.CARRIER
        Bd = self.BAUD
        bmsg = '11010001' + fsk.encode_ascii(msg)
        sys.stdout.write(f'### BAUD {Bd} @ CARRIER {carrier}Hz ###\n')
        sys.stdout.flush()

        s = fsk.generate_tones(bmsg, fs, Bd, carrier)
        s = fsk.sanduiche_encoding(s, Bd)
        tone = s * (2**15 - 1) / np.max(np.abs(s))
        tone = tone.astype(np.int16)
        self.SIGNAL = tone
Exemple #3
0
    def send_generic_message(self, msg, debug=False):
        fs = self.RATE
        carrier = self.CARRIER
        Bd = self.BAUD
        bmsg = '11010001' + fsk.encode_ascii(msg)
        if debug: print(bmsg)
        sys.stdout.write(f'### BAUD {Bd} @ CARRIER {carrier}Hz ###\n')
        sys.stdout.flush()

        s = fsk.generate_tones(bmsg, fs, Bd, carrier)
        s = fsk.sanduiche_encoding(s, Bd)
        tone = s * (2**15 - 1) / np.max(np.abs(s))
        tone = tone.astype(np.int16)

        self.SIGNAL = tone
        sd.play(tone, fs)
        status = sd.wait()
Exemple #4
0
    def send_generic_message(self, msg):
        fs = self.RATE
        carrier = self.CARRIER
        Bd = self.BAUD
        bmsg = '1101000111010001' + fsk.encode_ascii(msg)
        print(bmsg)
        sys.stdout.write('### BAUD {} CARRIER {}Hz ###\n'.format(
            str(Bd), str(carrier)))
        sys.stdout.flush()

        s = fsk.generate_tones(bmsg, fs, Bd, carrier)
        s = fsk.sanduiche_encoding(s)
        tone = s * (2**15 - 1) / np.max(np.abs(s))
        tone = tone.astype(np.int16)

        self.SIGNAL = tone
        sd.play(tone, fs)
        status = sd.wait()