import numpy as np

# --- Convert fm audio sweep i file to txt. --------------------------------
input_file  = "fm_audio_sweep_i.bin"   # 16‑bit binary you generated earlier
output_file = "fm_audio_sweep_i.txt"   # ASCII text version

# Load bytes directly into a NumPy uint8 array 
data = np.fromfile(input_file, dtype=np.int16)   # no loop, no unpacking

# Save as space‑separated integers 
# np.savetxt does the ASCII conversion efficiently
np.savetxt(output_file, data, fmt="%d", delimiter=" ")

print(f"Wrote {len(data)} samples to {output_file}")

# --- Convert fm audio sweep q file to txt. --------------------------------
input_file  = "fm_audio_sweep_q.bin"   # 16‑bit binary you generated earlier
output_file = "fm_audio_sweep_q.txt"   # ASCII text version

# Load bytes directly into a NumPy uint8 array 
data = np.fromfile(input_file, dtype=np.int16)   # no loop, no unpacking

# Save as space‑separated integers 
# np.savetxt does the ASCII conversion efficiently
np.savetxt(output_file, data, fmt="%d", delimiter=" ")

print(f"Wrote {len(data)} samples to {output_file}")

# --- Convert fm audio sweep iq file to txt. --------------------------------
input_file  = "fm_audio_sweep_iq.bin"   # 16‑bit binary you generated earlier
output_file = "fm_audio_sweep_iq.txt"   # ASCII text version

# Load bytes directly into a NumPy uint8 array 
data = np.fromfile(input_file, dtype=np.int16)   # no loop, no unpacking

# Save as space‑separated integers 
# np.savetxt does the ASCII conversion efficiently
np.savetxt(output_file, data, fmt="%d", delimiter=" ")


print(f"Wrote {len(data)} samples to {output_file}")