Create a Sine Wave

Learn how to create a sine wave and convert it into an audio file.

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:

y(t)=Asin(2pift)y(t) = A * sin(2 * pi * f * t) ...