repos/TB065

Commits Files Refs
commit ed319ef4dc5628d9ed6223a1668439ec0701b680
parent b184f007fa34b9b23412ffba116836c11cac539e
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Sun, 14 Sep 2025 22:59:31 -0300

update `tp/*`

Diffstat:
Mtp/main.py | 8++++----
Rtp/file1_filter1_output.wav -> tp/out/file1_filter1_output.wav | 0
Rtp/file1_filter2_output.wav -> tp/out/file1_filter2_output.wav | 0
Rtp/file2_filter1_output.wav -> tp/out/file2_filter1_output.wav | 0
Rtp/file2_filter2_output.wav -> tp/out/file2_filter2_output.wav | 0
Mtp/utils.py | 14+++++++++-----
6 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/tp/main.py b/tp/main.py
@@ -35,8 +35,8 @@ plot(file1_fs, file1_data, file1_path,
 file1_filter1_output = np.convolve(file1_data, filter1_h, mode='same')
 file1_filter2_output = np.convolve(file1_data, filter2_h, mode='same')
 
-save_convolved_to_wav(file1_filter1_output, file1_fs, "out/file1_filter1_output.wav")
-save_convolved_to_wav(file1_filter2_output, file1_fs, "out/file1_filter2_output.wav")
+save_convolved_to_wav(file1_filter1_output, file1_fs, "file1_filter1_output.wav")
+save_convolved_to_wav(file1_filter2_output, file1_fs, "file1_filter2_output.wav")
 
 # fig, ax = plot(file1_fs, file1_filter1_output)
 # save_plot(fig, file1_path, extra_name="_filter1_output")
@@ -72,8 +72,8 @@ plot(file2_fs, file2_data, file2_path, t_start=26.570, t_width=0.01)
 file2_filter1_output = np.convolve(file2_data, filter1_h, mode='same')
 file2_filter2_output = np.convolve(file2_data, filter2_h, mode='same')
 
-save_convolved_to_wav(file2_filter1_output, file2_fs, "out/file2_filter1_output.wav")
-save_convolved_to_wav(file2_filter2_output, file2_fs, "out/file2_filter2_output.wav")
+save_convolved_to_wav(file2_filter1_output, file2_fs, "file2_filter1_output.wav")
+save_convolved_to_wav(file2_filter2_output, file2_fs, "file2_filter2_output.wav")
 
 # fig, ax = plot(file2_fs, file2_filter1_output, t_start=6)
 # save_plot(fig, file2_path, t_start=6, extra_name="_filter1_output")
diff --git a/tp/file1_filter1_output.wav b/tp/out/file1_filter1_output.wav
Binary files differ.
diff --git a/tp/file1_filter2_output.wav b/tp/out/file1_filter2_output.wav
Binary files differ.
diff --git a/tp/file2_filter1_output.wav b/tp/out/file2_filter1_output.wav
Binary files differ.
diff --git a/tp/file2_filter2_output.wav b/tp/out/file2_filter2_output.wav
Binary files differ.
diff --git a/tp/utils.py b/tp/utils.py
@@ -12,6 +12,7 @@ import os
 from scipy.io import wavfile
 
 plot_dir_name = 'plot'
+out_dir_name = 'out'
 
 matplotlib.rcParams['font.family'] = 'Inter'
 matplotlib.rcParams['font.size'] = 12
@@ -20,7 +21,7 @@ matplotlib.rcParams['axes.prop_cycle'] = cycler(
 matplotlib.use("TkAgg")
 
 def ticks_label_format(x, pos):
-    # 3 decimals, strip trailing zeros
+    # 3 decimales, se eliminan los ceros y puntos
     return f"{x:.3f}".rstrip("0").rstrip(".")
 
 def graph_multiple_data(x, y_arr, y_lab, t=0, dt=0, a=0, da=0, show=True):
@@ -44,7 +45,7 @@ def graph_multiple_data(x, y_arr, y_lab, t=0, dt=0, a=0, da=0, show=True):
 
     plt.tight_layout()
 
-    # max 3 decimals
+    # max 3 decimales
     axis.xaxis.set_major_formatter(FuncFormatter(ticks_label_format))
 
     axis.set_xlim([t, t+dt if dt > 0 else x[-1]])
@@ -140,13 +141,16 @@ def save_plot(fig, src_file_path, t_start=0, t_width=0, extra_name=''):
     fig.savefig(fig_file_name, dpi=300, bbox_inches="tight")
 
 def save_convolved_to_wav(convolved, fs, file_path):
-    # 4️⃣ Normalize to prevent clippin
+    # normalizar para prevenir clipping
     convolved = convolved / np.max(np.abs(convolved))
 
-    # 5️⃣ Convert to 16-bit PCM for WAV
+    # convertir a 16-bit PCM para WAV
     convolved_int16 = np.int16(convolved * 32767)
 
+    # crea carpeta para wavs
+    os.makedirs(out_dir_name, exist_ok=True)
+
+    file_path = f'{out_dir_name}/{file_path}'
     print(f'- "{file_path}"')
-    # 6️⃣ Save to WAV
     wavfile.write(file_path, fs, convolved_int16)