|
@@ -14,6 +14,7 @@ import numpy as np
|
|
|
import librosa
|
|
|
import math
|
|
|
from scipy.interpolate import interp1d
|
|
|
+from scipy.interpolate import UnivariateSpline
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
def plotting_stuffs():
|
|
@@ -23,42 +24,70 @@ def plotting_stuffs():
|
|
|
ax = plt.subplot(3, 1, 1)
|
|
|
librosa.display.waveshow(wave, alpha=0.5)
|
|
|
plt.plot(t, rms[0], color="r")
|
|
|
- plt.plot(t, trms, color="b")
|
|
|
plt.ylim((-1, 1))
|
|
|
plt.title("Wave&Featurres")
|
|
|
plt.show()
|
|
|
|
|
|
- x = np.linspace(0,1,100)
|
|
|
- y = sig(x)
|
|
|
+ x = np.linspace(1, 4000, 4000)
|
|
|
+ y = f(x)
|
|
|
|
|
|
- plt.plot(x, y)
|
|
|
- plt.show()
|
|
|
+ #plt.plot(x, y)
|
|
|
+ #plt.show()
|
|
|
|
|
|
|
|
|
plt.hist(rms[0], color = 'red', edgecolor = 'black', bins = 10)
|
|
|
plt.show()
|
|
|
- plt.hist(cent[0], color = 'blue', edgecolor = 'black', bins = int(cent.max()/100))
|
|
|
+
|
|
|
+ # Generate some example data
|
|
|
+ data =cent[0]
|
|
|
+
|
|
|
+ # Create a histogram
|
|
|
+ hist, bin_edges = np.histogram(data, bins=100, density=True)
|
|
|
+
|
|
|
+ # Calculate bin centers
|
|
|
+ bin_centers = 0.5 * (bin_edges[:-1] + bin_edges[1:])
|
|
|
+
|
|
|
+ # Perform spline interpolation on the histogram data
|
|
|
+ spline = UnivariateSpline(bin_centers, hist, s=0)
|
|
|
+
|
|
|
+ # Create a finer x-axis for plotting the interpolated function
|
|
|
+ x_interp = np.linspace(min(bin_centers), max(bin_centers), 1000)
|
|
|
+ y_interp = spline(x_interp)
|
|
|
+
|
|
|
+ # Plot the histogram and the interpolated function
|
|
|
+ plt.hist(data, bins=100, density=True, alpha=0.6, color='g', label='Histogram')
|
|
|
+ plt.plot(x_interp, y_interp, label='Interpolated PDF', color='red')
|
|
|
+ plt.legend()
|
|
|
+ plt.xlabel('x')
|
|
|
+ plt.ylabel('Probability Density')
|
|
|
+ plt.title('Histogram and Interpolated PDF')
|
|
|
+ # Obtain min and max values of the probability density
|
|
|
+ min_density = np.min(hist)
|
|
|
+ max_density = np.max(hist)
|
|
|
+
|
|
|
+ print(f"Min Probability Density: {min_density}")
|
|
|
+ print(f"Max Probability Density: {max_density}")
|
|
|
+
|
|
|
plt.show()
|
|
|
+ plt.show()
|
|
|
+
|
|
|
|
|
|
def f(t):
|
|
|
return 1.0025+0.002*np.sin(1.25*3.14*t/30)
|
|
|
#return x ** 2
|
|
|
|
|
|
-def sig(x):
|
|
|
- return 1/(1 + np.exp(-12*(x-0.431)))
|
|
|
|
|
|
-strength_min = 0.2
|
|
|
-strength_max = 0.8
|
|
|
+strength_min = 0.4
|
|
|
+strength_max = 0.6
|
|
|
|
|
|
|
|
|
# Assuming that into "generated" directoruy U've already create "project_name" subfolder
|
|
|
-audio_input_file = '/home/lalo/data/studio_grafica/deforum/wilson_r1_mm_sample2.wav'
|
|
|
+#audio_input_file = '/home/lalo/data/studio_grafica/deforum/wilson_r1_mm_sample.wav'
|
|
|
#audio_input_file = '/home/lalo/data/studio_suono/spx/231104_001_m01.wav'
|
|
|
#audio_input_file = '/home/lalo/data/studio_grafica/deforum/eucrasy_r1_sample.wav'
|
|
|
#audio_input_file = '/home/lalo/data/studio_grafica/deforum/eucrasy_r1.wav'
|
|
|
-#audio_input_file = '/home/lalo/data/studio_grafica/deforum/eucrasy_short_r1.wav'
|
|
|
#audio_input_file = '/home/lalo/data/studio_suono/231014_002_mastered_r2_clip.WAV'
|
|
|
-#audio_input_file = 'C:/Users/LucaConte/Music/lc_music/wilson_r1_mm.wav'
|
|
|
+audio_input_file = 'C:/Users/LucaConte/Music/lc_music/wilson_r1_mm.wav'
|
|
|
|
|
|
|
|
|
# Store the sampling rate as `sr`
|
|
@@ -89,15 +118,14 @@ print("Audio duration in secs: " + str(duration))
|
|
|
# sr.len /22050 = duration
|
|
|
# rms.len * 30 = duration
|
|
|
# rms[i] mi da la potenza media del frame iesimo
|
|
|
-trms= rms[0]
|
|
|
|
|
|
-m = interp1d([min(trms), max(trms)], [strength_min, strength_max])
|
|
|
+m = interp1d([rms.min(), rms.max()], [strength_min, strength_max])
|
|
|
c = interp1d([cent.min(), cent.max()], [-0.5, 0.5])
|
|
|
|
|
|
# Creating the sctipt file (the real unique aoutput of this script)
|
|
|
try:
|
|
|
for frame in range(len(rms[0])):
|
|
|
- print(str(frame) + ":(" + str(1-m(trms[frame])) + "),", end="")
|
|
|
+ print(str(frame) + ":(" + str(1-m(rms[0][frame])) + "),", end="")
|
|
|
|
|
|
print("")
|
|
|
print("---------------")
|