In [2]:
from matplotlib import pyplot as plt
%matplotlib inline
import numpy as np
from scipy.signal import spectrogram
import soundfile
In [2]:
samples, sample_rate = soundfile.read(r'data\IDMT-SMT-GUITAR_V2\dataset1\Fender Strat Clean Neck SC\audio\G53-50110-1111-00011.wav')
print(samples.shape)
print(sample_rate)
In [18]:
f, t, Sxx = spectrogram(samples[4410:16000], sample_rate)
print(f.shape)
print(t.shape)
print(Sxx.shape)
plt.figure(figsize=(10,10))
plt.pcolormesh(t, f, Sxx, cmap='binary')
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.ylim(ymax=4000)
Out[18]:
In [10]:
for desc, file in [
('nofx', r'D:\Users\Michel\Documents\FH\module\8_IP6\input\IDMT-SMT-AUDIO-EFFECTS\Gitarre monophon\Samples\NoFX\G61-40100-1111-20593.wav'),
('distorted', r'D:\Users\Michel\Documents\FH\module\8_IP6\input\IDMT-SMT-AUDIO-EFFECTS\Gitarre monophon\Samples\Distortion\G61-40100-4413-38689.wav'),
]:
samples, sample_rate = soundfile.read(file)
print(desc)
print(samples[:4410].max())
print(samples[4410:8820].max())
print(samples[8820:13230].max())
print(samples[13230:17640].max())
f, t, Sxx = spectrogram(samples[:22050], sample_rate)
plt.figure(figsize=(8, 6))
plt.pcolormesh(t, f, Sxx, cmap='binary')
plt.title(desc)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.ylim(ymax=2000)