Created
March 16, 2020 08:06
-
-
Save pemagrg1/395667bf8d6e25cf7feaf6de5d247b30 to your computer and use it in GitHub Desktop.
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
""" | |
In audio production, a sample rate (or "sampling rate") defines how many times per second a sound is sampled. | |
Technically speaking, it is the frequency of samples used in a digital recording. | |
""" | |
import numpy as np | |
from scipy.io import wavfile | |
sampleRate = 100 | |
frequency = 10 | |
audio_length = 1 #second | |
amplitude = 10 | |
t = np.linspace(0, audio_length, sampleRate * audio_length) # Produces a given 'length' seconds Audio-File | |
y = amplitude*np.sin(frequency * 2 * np.pi * t) # Has frequency of given 'frequency' | |
# wavfile.write('Sine.wav', sampleRate, y) | |
plt.plot(t,y) # plot using pyplot library from matplotlib package | |
plt.title('Sine wave f='+str(frequency)+' Hz') # plot title | |
plt.xlabel('Time (s)') # x-axis label | |
plt.ylabel('Amplitude') # y-axis label | |
plt.show() # display the figure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment