noise improvements with (i)stft

This commit is contained in:
Benoît Sierro
2024-01-11 10:43:37 +01:00
parent c3ea042d71
commit 7c7e7b7533
2 changed files with 60 additions and 27 deletions

40
examples/noise_study.py Normal file
View File

@@ -0,0 +1,40 @@
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()