41 lines
922 B
Python
41 lines
922 B
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
import scgenerator as sc
|
|
|
|
|
|
def main():
|
|
nperseg = 513
|
|
nseg = 240
|
|
ntot = (nperseg - 1) * (nseg - 1)
|
|
|
|
fs = 44100
|
|
nf = 45611
|
|
f = np.linspace(0, fs // 2, nf)
|
|
|
|
spec = 1 / (f + 1)
|
|
spec += np.exp(-(((f - (0.2 * fs)) / (0.5 * fs)) ** 2))
|
|
plt.plot(f, spec)
|
|
plt.xscale("log")
|
|
plt.yscale("log")
|
|
plt.show()
|
|
|
|
noise = sc.noise.NoiseMeasurement(f, spec)
|
|
t, y = noise.time_series(nf=nperseg, nseg=nseg)
|
|
# tf, yf = noise.time_series(nperseg=(ntot // 2) + 1, nseg=1)
|
|
plt.plot(t, y, ls="", marker=".")
|
|
plt.show()
|
|
|
|
newnoise = noise.from_time_series(y, t[1] - t[0], nperseg=(nperseg - 1) * 2)
|
|
|
|
plt.plot(*noise.plottable())
|
|
f, sxx = noise.sample_spectrum(nperseg)
|
|
plt.plot(f, 10 * np.log10(sxx))
|
|
plt.plot(*newnoise.plottable())
|
|
plt.xscale("log")
|
|
plt.show()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|