Upload of all solutions and assigment 1

This commit is contained in:
2020-09-01 17:01:07 +02:00
parent bf91256310
commit b5ae8eb7a5
14 changed files with 36 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,33 @@
import numpy as np
import sounddevice as sd
# Physical freq to "sample", must be integer
F_1 = 1000
# Volume must be between 0 and 100, may be float
volume = 20
# Sampling freq, must be integer
F_s = 6000
# Time how long a sample should last, must be integer
duration = 4
# Calculation of constants
volume = volume / 100
totalSamples = F_s * duration
# Comment out the last decleration if you want to use a fixed f1
f_1 = 0.3
#f_1 = F_1 / F_s
def GenSound(f1, noSamples, vol):
x = np.empty(noSamples)
for n in range(noSamples):
x[n] = np.cos(2*np.pi * f1 * n) * vol
return x
x = GenSound(f_1, totalSamples, volume)
print(x)
sd.play(x, F_s)
sd.wait()
sd.stop()

Binary file not shown.