def run(): """main loop""" #constants N = int(input("N: ")) K = int(input("K: ")) # get data pre-transmission sent_file = input("Data that was sent (.wav): ") sent_file = get_recording_file_path(sent_file + ".wav") data_rec = Recording.from_file(sent_file) #sampling_freq = data_rec.rate data_seq = data_rec.get_frames_as_int16() D = len(data_seq) received_file = input("Recorded transmission (.wav): ") received_file = get_recording_file_path(received_file + ".wav") received_rec = Recording.from_file(received_file) reference_file = input("Reference signal (.wav): ") reference_file = get_recording_file_path(reference_file + ".wav") reference_rec = Recording.from_file(reference_file) offset = int(input("Manual sync offset (-ve): ")) received_data = received_rec.extract_data_sequence(reference_rec, D, offset=-offset) h = estimate_channel(received_data, data_seq, N=N, K=K) plot_h_in_time(h) plot_h_freq_domain(h, N=N)
def run(): """main loop""" signal_file = input("Signal to load (.wav): ") signal_file = get_recording_file_path(signal_file + ".wav") signal = Recording.from_file(signal_file) reference_file = input("Reference signal (.wav): ") reference_file = get_recording_file_path(reference_file + ".wav") reference = Recording.from_file(reference_file) plot_correlation(signal, reference)
def run(): """main loop""" file_name_short = input("File name to open (.wav): ") file_name_full = get_recording_file_path(file_name_short + ".wav") rec = Recording.from_file(file_name_full) plot_recording(rec)
def run(): """main loop""" print("Concatenates wav files A + B") file_a = input("File A (.wav): ") file_a = get_recording_file_path(file_a + ".wav") rec_a = Recording.from_file(file_a) file_b = input("File B (.wav): ") file_b = get_recording_file_path(file_b + ".wav") rec_b = Recording.from_file(file_b) rec_a.append_recording(rec_b) file_c = input("Save new file under (.wav): ") file_c = get_recording_file_path(file_c + ".wav") rec_a.save(file_c) print("Done")
def run(): """main loop""" signal_file = input("Signal to load (.wav): ") signal_file = get_recording_file_path(signal_file + ".wav") signal = Recording.from_file(signal_file) channel = [0.5, 0.2, 0, 0.1, 0.04, 0] print("Passing through channel...") received_signal = signal.pass_through_channel(channel) print("Done") out_file = input("File name to save (.wav): ") out_file = get_recording_file_path(out_file + ".wav") received_signal.save(out_file) plot_recording(signal, "Original Signal") plot_recording(received_signal, "Signal after passing through simulated channel")
def run(): """main loop""" file_name_short = input("File name to save (.wav): ") file_name_full = get_recording_file_path(file_name_short + ".wav") duration = int(input("Duration of recording (seconds): ")) recording = Recording.from_mic(duration=duration) recording.save(file_name_full) plot_recording(recording)
def run(): # get mode mode = input("Transmission mode (K[A,B,C]): ") K = get_K(mode) mode = input("Transmission mode (Q[1,2,3]): ") Q1, Q2 = get_Q(mode) # get data pre-transmission source_file_name = input("File to encode (must be in data dir): ") #source_file_name = "elk.bmp" source_file_path = get_data_file_path(source_file_name) source_bits = create_bits_for_file(source_file_name, source_file_path) # convert to wav rec = bits_to_wav_recording(source_bits, K, Q1, Q2) # save out_file_name = input("File name to save under (.wav): ") out_file_path = get_recording_file_path(out_file_name + ".wav") rec.save(out_file_path)
def run(): debug_channel = False debug_symbols = False mode = input("Transmission mode (K[A,B,C]): ") K = get_K(mode) mode = input("Transmission mode (Q[1,2,3]): ") Q1, Q2 = get_Q(mode) P = N + K Q = Q2 - Q1 signal_file = input("which file would you like to decode? (no .wav required) ") signal_file = get_recording_file_path(signal_file + ".wav") signal_rec = Recording.from_file(signal_file) print("extracting packets") chirp_rec = generate_chirp_recording(F, F0, F1, C*P) packet_arr, dither_arr = signal_rec.extract_packets(chirp_rec, P) num_packets = len(packet_arr) print("\nPackets found: {}\n".format(num_packets)) print("Dither array: ") print(dither_arr) data_sequence = "" num_steps = 3 print("Decoding packets") for i in range(0, num_packets): packet = packet_arr[i] #slicing key data known_data_at_start = packet[0 : D * P] known_data_at_end = packet[- D * P : ] packet_data = packet[D * P : - D * P] #estimate channel at start known_data_pre_trans = gen_known_data_chunk(N, K) h_a = estimate_channel(known_data_at_start, known_data_pre_trans, N, K) h_b = estimate_channel(known_data_at_end, known_data_pre_trans, N, K) if debug_channel: plot_h_in_time(h_a) plot_h_in_time(h_b) plot_h_freq_domain(h_a, N) plot_h_freq_domain(h_b, N) #demodulate progress_bar(i*num_steps, num_packets*num_steps) demodulated_signal = demodulate_sequence(packet_data, h_a, h_b, N, K, Q1=Q1, Q2=Q2) if debug_symbols: plot_complex_symbols(demodulated_signal) #decode progress_bar(i*num_steps + 1, num_packets*num_steps) decoded_signal = decode_symbol_sequence(demodulated_signal) #slowest step by far #xor progress_bar(i*num_steps + 2, num_packets*num_steps) de_xored = xor(decoded_signal, Q*q) #concatenate data_sequence = data_sequence + de_xored progress_bar(num_packets*num_steps, num_packets*num_steps) decode_bit_string_jossy_format_and_save(data_sequence)