import math import matplotlib.pyplot as plt sample_rate = 100000 baud_rate = 48000 f0 = 1000 f1 = 2000 message = "HELLO" phase = 0 freq = 0 samples_per_bit = int(sample_rate/baud_rate) values = [] for c in message: bword = format(ord(c), '08b') for bit in bword: if bit == '0': freq = f0 else: freq = f1 for i in range(samples_per_bit): phase += 2 * math.pi * (freq/sample_rate) values.append(math.cos(phase)) plt.plot(values) plt.show()