Пример #1
0
        tone = quietnet.tone(freq, DATASIZE, offset=offset)
        output_buffer += quietnet.envelope(tone, left=last_bit=='0', right=next_bit=='0')
        offset += DATASIZE
        last_bit = bit

    return quietnet.pack_buffer(output_buffer)

def play_buffer(buffer):
    output = ''.join(buffer)
    stream.write(output)

if __name__ == "__main__":
    print("Welcome to quietnet. Use ctrl-c to exit")

    try:
        # get user input and play message
        while True:
            message = user_input("> ")
            try:
              pattern = psk.encode(message)
              buffer = make_buffer_from_bit_pattern(pattern, FREQ, FREQ_OFF)
              play_buffer(buffer)
            except KeyError:
              print("Messages may only contain printable ASCII characters.")
    except KeyboardInterrupt:
        # clean up our streams and exit
        stream.stop_stream()
        stream.close()
        p.terminate()
        print("exited cleanly")
Пример #2
0

def play_buffer(buffer):
    output = b''.join(buffer)
    stream.write(output)


if __name__ == "__main__":
    print("Use ctrl-c to exit")

    try:
        # get user input and play message
        while True:
            message = input("> ")
            try:
                pattern1 = psk.encode(message[::2])
                pattern2 = psk.encode(message[1::2])
                buffer1 = make_buffer_from_bit_pattern(pattern1, FREQ,
                                                       FREQ_OFF)
                buffer2 = make_buffer_from_bit_pattern(pattern2, 800, FREQ_OFF)
                for i in range(min(len(buffer1), len(buffer2))):
                    #print(buffer1[i], int.from_bytes(buffer1[i], byteorder="little", signed=True))
                    buffer1[i] = (int.from_bytes(
                        buffer1[i], byteorder="little", signed=True) +
                                  int.from_bytes(buffer2[i],
                                                 byteorder="little",
                                                 signed=True)).to_bytes(
                                                     2,
                                                     byteorder="little",
                                                     signed=True)
                play_buffer(buffer1)
Пример #3
0
def play_buffer(buffer):
    output = ''.join(buffer)
    sample_width = p.get_sample_size(FORMAT)
    print 'saving to file'
    stream.write(output)
    save_to_file(RATE, sample_width, output, "e:\\test.wav")

if __name__ == "__main__":
    print("Welcome to quietnet. Use ctrl-c to exit")

    try:
        # get user input and play message
        while True:
            message = user_input("> ")
            try:
              transmittedMessage = message + message[-1]
              print 'transmittedMessage: %s' % transmittedMessage
              pattern = psk.encode(transmittedMessage)
              buffer = make_buffer_from_bit_pattern(pattern, FREQ, FREQ_OFF)
              play_buffer(buffer)
            except KeyError:
              print("Messages may only contain printable ASCII characters.")
    except KeyboardInterrupt:
        # clean up our streams and exit
        stream.stop_stream()
        stream.close()
        p.terminate()
        
        print("exited cleanly")

Пример #4
0
        offset += DATASIZE
        last_bit = bit

    return quietnet.pack_buffer(output_buffer)


def play_buffer(buffer):
    output = ''.join(buffer)
    stream.write(output)


if __name__ == "__main__":
    print("Welcome to quietnet. Use ctrl-c to exit")

    try:
        # get user input and play message
        while True:
            message = user_input("> ")
            try:
                pattern = psk.encode(message)
                buffer = make_buffer_from_bit_pattern(pattern, FREQ, FREQ_OFF)
                play_buffer(buffer)
            except KeyError:
                print("Messages may only contain printable ASCII characters.")
    except KeyboardInterrupt:
        # clean up our streams and exit
        stream.stop_stream()
        stream.close()
        p.terminate()
        print("exited cleanly")
Пример #5
0
        tone = quietnet.tone(freq, DATASIZE, offset=offset)
        output_buffer += quietnet.envelope(tone, left=last_bit=='0', right=next_bit=='0')
        offset += DATASIZE
        last_bit = bit

    return quietnet.pack_buffer(output_buffer)

def play_buffer(buffer):
    output = ''.join(buffer)
    stream.write(output)

if __name__ == "__main__":
    print("Welcome to quietnet. Use ctrl-c to exit")

    try:
        # get user input and play message
        while True:
            message = user_input("> ")
            try:
              pattern = psk.encode(message, options.sigil)
              buffer = make_buffer_from_bit_pattern(pattern, FREQ, FREQ_OFF)
              play_buffer(buffer)
            except KeyError:
              print("Messages may only contain printable ASCII characters.")
    except KeyboardInterrupt:
        # clean up our streams and exit
        stream.stop_stream()
        stream.close()
        p.terminate()
        print("exited cleanly")