Created
June 28, 2020 20:20
-
-
Save akey7/c2e21dc11c798e3fd722d42a071baa4a to your computer and use it in GitHub Desktop.
This creates a sine wave in NumPy and writes it to a wave file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.io.wavfile import write | |
sps = 44100 | |
freq_hz = 440.0 | |
duration_s = 3.0 | |
t_samples = np.arange(sps * duration_s) | |
waveform = np.sin(2 * np.pi * freq_hz * t_samples / sps) | |
waveform *= 0.3 | |
waveform_ints = np.int16(waveform * 32767) | |
write('first_sine.wav', sps, waveform_ints) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment