Create a Sine Wave
Explore how to create a 1kHz sine wave digitally using Python. Understand key audio concepts like frequency, sampling rate, and amplitude, then use Python's wave and struct libraries to save the wave as a 16-bit WAV file. Learn to plot the sine wave and verify it in an audio player like Audacity, gaining practical skills in audio signal processing.
We'll cover the following...
In this lesson, we’ll learn how to create a sine wave and save it as a wav file. Before that, let’s go over some basic theory that you should know.
Some definitions
Frequency: Frequency is the number of times a sine wave repeats a second. In this lesson, we’ll use a frequency of 1KHz.
Sampling rate: Most real-world signals are analogs, while computers are digital. So we need a converter to convert our analog signal into a digital representation of that signal.However, the critical thing to understand here is the sampling rate, which is the number of times the converter takes a sample of the analog signal in a second.
Now, the sampling rate doesn’t matter as much since we’re doing everything digitally, but it’s needed for our sine wave formula. We’ll use a value of 48000, which is the value used in professional audio equipment.
Sine wave formula:
...