From 830e234dd6b9285bdbdd047b03b6d54aff5f5e1d Mon Sep 17 00:00:00 2001 From: UnitedAirforce Date: Fri, 7 Feb 2025 19:02:37 +0800 Subject: [PATCH] fix bugs --- various-tools/BGM + SHOT to BGM & SHOT/8.py | 27 ++++++++++++++------- various-tools/pak file/readme.txt | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/various-tools/BGM + SHOT to BGM & SHOT/8.py b/various-tools/BGM + SHOT to BGM & SHOT/8.py index adf568b..dfa86ea 100644 --- a/various-tools/BGM + SHOT to BGM & SHOT/8.py +++ b/various-tools/BGM + SHOT to BGM & SHOT/8.py @@ -1,9 +1,14 @@ import numpy as np import scipy.io.wavfile as wav import os +import sys -file1 = input("Enter the first WAV file (music track): ").strip() -file2 = input("Enter the second WAV file (SFX track): ").strip() +if len(sys.argv) != 4: + print("Usage: 8.py ") + sys.exit(1) + +file1 = sys.argv[1] +file2 = sys.argv[2] rate1, data1 = wav.read(file1) rate2, data2 = wav.read(file2) @@ -14,19 +19,23 @@ if rate1 != rate2: if data1.ndim != data2.ndim: raise ValueError("Channel count mismatch!") -# Convert to int32, addition (not normalization), then cap values. +# Find the minimum length of the two arrays +min_length = min(len(data1), len(data2)) + +# Trim both arrays to the same length +data1 = data1[:min_length] +data2 = data2[:min_length] + +# Convert to int32, perform addition (without normalization), and clip values data1 = data1.astype(np.int32) data2 = data2.astype(np.int32) mixed = data1 + data2 - -mixed = np.clip(mixed, -32768, 32767) - -mixed = mixed.astype(np.int16) +mixed = np.clip(mixed, -32768, 32767).astype(np.int16) dir_name, base_name = os.path.split(file2) -output_file = os.path.join(dir_name, "1_" + base_name) +output_file = file2 # Overwrite the shot file with the mixed output wav.write(output_file, rate1, mixed) -print(f"Mixing complete! Saved as {output_file}") \ No newline at end of file +print(f"Mixing complete! Saved as {output_file}") diff --git a/various-tools/pak file/readme.txt b/various-tools/pak file/readme.txt index a963671..f95f8a3 100644 --- a/various-tools/pak file/readme.txt +++ b/various-tools/pak file/readme.txt @@ -1 +1 @@ -Tool for packing/unpaking the stage, skin, and tunFile paks. +Tool for packing/unpaking the stage, skin, and tuneFile paks.