|
@@ -16,6 +16,36 @@ import math
|
|
|
from scipy.interpolate import interp1d
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
+def plotting_stuffs():
|
|
|
+
|
|
|
+ plt.figure(figsize=(15, 17))
|
|
|
+ t = librosa.frames_to_time(range(rms.size), hop_length=flength)
|
|
|
+ ax = plt.subplot(3, 1, 1)
|
|
|
+ librosa.display.waveshow(wave, alpha=0.5)
|
|
|
+ plt.plot(t, rms[0], color="r")
|
|
|
+ plt.ylim((-1, 1))
|
|
|
+ plt.title("Wave&Featurres")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ x = np.array(range(200))
|
|
|
+ #x = np.array(range(len(cent[0])))
|
|
|
+ y = np.array(cent[0])
|
|
|
+
|
|
|
+
|
|
|
+ #plt.hist(cent[0], color = 'blue', edgecolor = 'black', bins = int(cent.max()/100))
|
|
|
+
|
|
|
+
|
|
|
+ plt.show()
|
|
|
+
|
|
|
+
|
|
|
+ x = np.linspace(1, 4000, 4000)
|
|
|
+ y = f(x)
|
|
|
+
|
|
|
+ plt.plot(x, y)
|
|
|
+ plt.show()
|
|
|
+
|
|
|
+
|
|
|
def f(t):
|
|
|
return 1.0025+0.002*np.sin(1.25*3.14*t/30)
|
|
|
#return x ** 2
|
|
@@ -43,21 +73,18 @@ flength = 22050//fps
|
|
|
|
|
|
|
|
|
|
|
|
-y, sr = librosa.load(audio_input_file)
|
|
|
-rms = librosa.feature.rms(y=y, frame_length=flength, hop_length=flength)
|
|
|
+wave, sr = librosa.load(audio_input_file)
|
|
|
+rms = librosa.feature.rms(y=wave, frame_length=flength, hop_length=flength)
|
|
|
|
|
|
-#rms = librosa.feature.rms(y=y, frame_length=735, hop_length=735)
|
|
|
-cent = librosa.feature.spectral_centroid(y=y, sr=sr,n_fft=flength, hop_length=flength)
|
|
|
-duration = int(math.ceil(librosa.get_duration(y=y, sr=sr)))
|
|
|
+#rms = librosa.feature.rms(y=wave, frame_length=735, hop_length=735)
|
|
|
+cent = librosa.feature.spectral_centroid(y=wave, sr=sr,n_fft=flength, hop_length=flength)
|
|
|
+duration = int(math.ceil(librosa.get_duration(y=wave, sr=sr)))
|
|
|
|
|
|
frames = duration * fps
|
|
|
|
|
|
-
|
|
|
-
|
|
|
print("RMS SIZE: " + str(len(rms[0])))
|
|
|
print("CEN SIZE: " + str(len(cent[0])))
|
|
|
print("TOTAL FRAMES: " + str(frames))
|
|
|
-
|
|
|
# sr.len /22050 = duration
|
|
|
# rms.len * 30 = duration
|
|
|
# rms[i] mi da la potenza media del frame iesimo
|
|
@@ -76,28 +103,11 @@ try:
|
|
|
print("---------------")
|
|
|
print("")
|
|
|
|
|
|
- for frame in range(rms.size):
|
|
|
+ for frame in range(cent.size):
|
|
|
print(str(frame) + ":(" + str(cent[0][frame]) + "),", end="")
|
|
|
except:
|
|
|
print(exception)
|
|
|
|
|
|
|
|
|
-
|
|
|
-x = np.array(range(200))
|
|
|
-#x = np.array(range(len(cent[0])))
|
|
|
-y = np.array(cent[0])
|
|
|
-
|
|
|
-
|
|
|
-plt.hist(cent[0], color = 'blue', edgecolor = 'black',
|
|
|
- bins = int(cent.max()/100))
|
|
|
-
|
|
|
-
|
|
|
-plt.show()
|
|
|
-
|
|
|
-
|
|
|
-x = np.linspace(1, 4000, 4000)
|
|
|
-y = f(x)
|
|
|
-
|
|
|
-plt.plot(x, y)
|
|
|
-plt.show()
|
|
|
+plotting_stuffs()
|
|
|
|