repos/TB065

Commits Files Refs
commit df0b105686d2d84890b3b2e23bb06cf20ca9a719
parent d9dc016f96dad58c96a349496431b952b65f2c0b
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Wed, 22 Oct 2025 15:51:05 -0300

Updated `tp/**`

Diffstat:
Mtp/main.py | 6++++--
Mtp/plot/a4_clarinete.png | 0
Mtp/plot/a4_flauta.png | 0
Mtp/plot/a4_violin.png | 0
Mtp/plot/cancion1.png | 0
Mtp/plot/cancion1_0_248s_a_0_256s.png | 0
Mtp/plot/cancion1_0_520s_a_0_528s.png | 0
Dtp/plot/cancion1_espectograma.png | 0
Atp/plot/cancion1_espectograma_blackman_0512.png | 0
Atp/plot/cancion1_espectograma_blackman_1024.png | 0
Atp/plot/cancion1_espectograma_blackman_2048.png | 0
Atp/plot/cancion1_espectograma_blackman_4096.png | 0
Atp/plot/cancion1_espectograma_hamming_0512.png | 0
Atp/plot/cancion1_espectograma_hamming_1024.png | 0
Atp/plot/cancion1_espectograma_hamming_2048.png | 0
Atp/plot/cancion1_espectograma_hamming_4096.png | 0
Atp/plot/cancion1_espectograma_hann_0512.png | 0
Atp/plot/cancion1_espectograma_hann_1024.png | 0
Atp/plot/cancion1_espectograma_hann_2048.png | 0
Atp/plot/cancion1_espectograma_hann_4096.png | 0
Mtp/plot/cancion1_fft.png | 0
Mtp/plot/cancion1_filter1_output_compare.png | 0
Mtp/plot/cancion1_filter1_output_fft.png | 0
Mtp/plot/cancion1_filter2_output_fft.png | 0
Mtp/plot/cancion2.png | 0
Mtp/plot/cancion2_14_72s_a_14_73s.png | 0
Mtp/plot/cancion2_26_57s_a_26_58s.png | 0
Dtp/plot/cancion2_espectograma.png | 0
Atp/plot/cancion2_espectograma_blackman_0512.png | 0
Atp/plot/cancion2_espectograma_blackman_1024.png | 0
Atp/plot/cancion2_espectograma_blackman_2048.png | 0
Atp/plot/cancion2_espectograma_blackman_4096.png | 0
Atp/plot/cancion2_espectograma_hamming_0512.png | 0
Atp/plot/cancion2_espectograma_hamming_1024.png | 0
Atp/plot/cancion2_espectograma_hamming_2048.png | 0
Atp/plot/cancion2_espectograma_hamming_4096.png | 0
Atp/plot/cancion2_espectograma_hann_0512.png | 0
Atp/plot/cancion2_espectograma_hann_1024.png | 0
Atp/plot/cancion2_espectograma_hann_2048.png | 0
Atp/plot/cancion2_espectograma_hann_4096.png | 0
Mtp/plot/cancion2_fft.png | 0
Mtp/plot/cancion2_filter1_output_fft.png | 0
Mtp/plot/cancion2_filter2_output_fft.png | 0
Mtp/plot/filter1_h_fft.png | 0
Mtp/plot/filter2_h_fft.png | 0
Mtp/utils.py | 27+++++++++++++--------------
46 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/tp/main.py b/tp/main.py
@@ -120,8 +120,10 @@ def freq_domain():
     freq_plot(48000, filter1_h, "filter1_h_fft", f_max=2000)
     freq_plot(48000, filter2_h, "filter2_h_fft", f_max=8000)
 
-    spectogram_plot(file1_fs, file1_data, "cancion1_espectograma")
-    spectogram_plot(file2_fs, file2_data, "cancion2_espectograma", t=6)
+    for i in [512, 1024, 2048, 4096]:
+        for window in ['hann', 'hamming', 'blackman']:
+            spectogram_plot(file1_fs, file1_data, f"cancion1_espectograma_{window}_{i:04d}", N=i, win=window)
+            spectogram_plot(file2_fs, file2_data, f"cancion2_espectograma_{window}_{i:04d}", t=6, N=i, win=window)
 
 time_domain()
 freq_domain()
diff --git a/tp/plot/a4_clarinete.png b/tp/plot/a4_clarinete.png
Binary files differ.
diff --git a/tp/plot/a4_flauta.png b/tp/plot/a4_flauta.png
Binary files differ.
diff --git a/tp/plot/a4_violin.png b/tp/plot/a4_violin.png
Binary files differ.
diff --git a/tp/plot/cancion1.png b/tp/plot/cancion1.png
Binary files differ.
diff --git a/tp/plot/cancion1_0_248s_a_0_256s.png b/tp/plot/cancion1_0_248s_a_0_256s.png
Binary files differ.
diff --git a/tp/plot/cancion1_0_520s_a_0_528s.png b/tp/plot/cancion1_0_520s_a_0_528s.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma.png b/tp/plot/cancion1_espectograma.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_blackman_0512.png b/tp/plot/cancion1_espectograma_blackman_0512.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_blackman_1024.png b/tp/plot/cancion1_espectograma_blackman_1024.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_blackman_2048.png b/tp/plot/cancion1_espectograma_blackman_2048.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_blackman_4096.png b/tp/plot/cancion1_espectograma_blackman_4096.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hamming_0512.png b/tp/plot/cancion1_espectograma_hamming_0512.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hamming_1024.png b/tp/plot/cancion1_espectograma_hamming_1024.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hamming_2048.png b/tp/plot/cancion1_espectograma_hamming_2048.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hamming_4096.png b/tp/plot/cancion1_espectograma_hamming_4096.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hann_0512.png b/tp/plot/cancion1_espectograma_hann_0512.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hann_1024.png b/tp/plot/cancion1_espectograma_hann_1024.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hann_2048.png b/tp/plot/cancion1_espectograma_hann_2048.png
Binary files differ.
diff --git a/tp/plot/cancion1_espectograma_hann_4096.png b/tp/plot/cancion1_espectograma_hann_4096.png
Binary files differ.
diff --git a/tp/plot/cancion1_fft.png b/tp/plot/cancion1_fft.png
Binary files differ.
diff --git a/tp/plot/cancion1_filter1_output_compare.png b/tp/plot/cancion1_filter1_output_compare.png
Binary files differ.
diff --git a/tp/plot/cancion1_filter1_output_fft.png b/tp/plot/cancion1_filter1_output_fft.png
Binary files differ.
diff --git a/tp/plot/cancion1_filter2_output_fft.png b/tp/plot/cancion1_filter2_output_fft.png
Binary files differ.
diff --git a/tp/plot/cancion2.png b/tp/plot/cancion2.png
Binary files differ.
diff --git a/tp/plot/cancion2_14_72s_a_14_73s.png b/tp/plot/cancion2_14_72s_a_14_73s.png
Binary files differ.
diff --git a/tp/plot/cancion2_26_57s_a_26_58s.png b/tp/plot/cancion2_26_57s_a_26_58s.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma.png b/tp/plot/cancion2_espectograma.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_blackman_0512.png b/tp/plot/cancion2_espectograma_blackman_0512.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_blackman_1024.png b/tp/plot/cancion2_espectograma_blackman_1024.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_blackman_2048.png b/tp/plot/cancion2_espectograma_blackman_2048.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_blackman_4096.png b/tp/plot/cancion2_espectograma_blackman_4096.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hamming_0512.png b/tp/plot/cancion2_espectograma_hamming_0512.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hamming_1024.png b/tp/plot/cancion2_espectograma_hamming_1024.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hamming_2048.png b/tp/plot/cancion2_espectograma_hamming_2048.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hamming_4096.png b/tp/plot/cancion2_espectograma_hamming_4096.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hann_0512.png b/tp/plot/cancion2_espectograma_hann_0512.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hann_1024.png b/tp/plot/cancion2_espectograma_hann_1024.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hann_2048.png b/tp/plot/cancion2_espectograma_hann_2048.png
Binary files differ.
diff --git a/tp/plot/cancion2_espectograma_hann_4096.png b/tp/plot/cancion2_espectograma_hann_4096.png
Binary files differ.
diff --git a/tp/plot/cancion2_fft.png b/tp/plot/cancion2_fft.png
Binary files differ.
diff --git a/tp/plot/cancion2_filter1_output_fft.png b/tp/plot/cancion2_filter1_output_fft.png
Binary files differ.
diff --git a/tp/plot/cancion2_filter2_output_fft.png b/tp/plot/cancion2_filter2_output_fft.png
Binary files differ.
diff --git a/tp/plot/filter1_h_fft.png b/tp/plot/filter1_h_fft.png
Binary files differ.
diff --git a/tp/plot/filter2_h_fft.png b/tp/plot/filter2_h_fft.png
Binary files differ.
diff --git a/tp/utils.py b/tp/utils.py
@@ -140,10 +140,10 @@ def save_plot(fig, name):
 
     #     save_name = f'{file_path_no_ext}_{i}.png'
 
-    print(f'- "{save_name}"')
+    print(f'"{save_name}"')
      # crea carpeta para plots
     os.makedirs(plot_dir_name, exist_ok=True)
-    fig.savefig(save_name, dpi=500, bbox_inches="tight")
+    fig.savefig(save_name, dpi=200, bbox_inches="tight")
     plt.close(fig) # liberar memoria
 
 def save_convolved_to_wav(convolved, fs, file_path):
@@ -157,7 +157,7 @@ def save_convolved_to_wav(convolved, fs, file_path):
     os.makedirs(out_dir_name, exist_ok=True)
 
     file_path = f'{out_dir_name}/{file_path}'
-    print(f'- "{file_path}"')
+    print(f'"{file_path}"')
     wavfile.write(file_path, fs, convolved_int16)
 
 # frecuencia
@@ -165,8 +165,8 @@ def save_convolved_to_wav(convolved, fs, file_path):
 def freq_graph_data(x, y, f_min=0, f_max=0, y_min=0, y_max=0, show=True, save_path=""):
     fig, axis = plt.subplots(figsize=(8, 4))
 
-    axis.plot(x, y, label='Señal de audio')
-    axis.set(xlabel='Frecuencia [Hz]', ylabel='Magnitud normalizada')
+    axis.plot(x, y)
+    axis.set(xlabel='Frecuencia [Hz]', ylabel='Magnitud')
 
     axis.minorticks_on()
     axis.grid(True, which='major', color='black', linestyle=':', linewidth=1.00)
@@ -219,9 +219,7 @@ def freq_plot(fs, data, save_name="", f_min=0, f_max=0, y_min=0, y_max=0,
     return fig, ax
 
 
-from datetime import datetime
-
-def spectogram_plot(fs, data, save_name="", t=0, dt=0, xlim=[], ylim=[], show=False):
+def spectogram_plot(fs, data, save_name="", t=0, dt=0, N=1024, overlp=16, win='hann', xlim=[], ylim=[], show=False):
     if dt == 0:
         dt = (len(data)/fs)-t
 
@@ -229,10 +227,15 @@ def spectogram_plot(fs, data, save_name="", t=0, dt=0, xlim=[], ylim=[], show=Fa
     di = int((t+dt)*fs)
     interval_data = data[i:di]
 
-    f, time, Sxx = spectrogram(interval_data, fs=fs, nperseg=4096, noverlap=32)
+    # `nperseg`  tamaño de ventana (número de muestras por segmento)
+    # `noverlap` cantidad de solapamiento entre ventanas
+    f, time, Sxx = spectrogram(interval_data, fs=fs, nperseg=N, noverlap=overlp,
+                               window=win)
     fig, axis = plt.subplots(figsize=(8, 4))
 
-    plt.pcolormesh(time, f, Sxx**0.10, shading='gouraud')
+    # plt.pcolormesh(time, f, Sxx**0.10, shading='gouraud')
+    plt.pcolormesh(time, f, 10*np.log10(Sxx + 1e-12), shading='gouraud')
+
     plt.ylabel('Frecuencia [Hz]')
     plt.xlabel('Tiempo [s]')
 
@@ -247,10 +250,6 @@ def spectogram_plot(fs, data, save_name="", t=0, dt=0, xlim=[], ylim=[], show=Fa
     if show == True:
         plt.show()
     else:
-        if save_name == "":
-            timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
-            save_name = f"spectogram_{timestamp}"
-
         save_plot(fig, save_name)
 
     return fig, axis