Upload of all solutions and assigment 1

master
Øyvind Skaaden 2020-09-01 17:01:07 +02:00
parent bf91256310
commit b5ae8eb7a5
14 changed files with 36 additions and 0 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "/home/oyvind/miniconda3/bin/python"
}

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.