mirror of
https://github.com/qwerfd2/Groove_Coaster_2_Server.git
synced 2025-12-22 03:30:18 +00:00
added shot/bgm convert script
This commit is contained in:
32
various-tools/4max & pc BGM + SHOT to 2OS BGM & SHOT/8.py
Normal file
32
various-tools/4max & pc BGM + SHOT to 2OS BGM & SHOT/8.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import numpy as np
|
||||
import scipy.io.wavfile as wav
|
||||
import os
|
||||
|
||||
file1 = input("Enter the first WAV file (music track): ").strip()
|
||||
file2 = input("Enter the second WAV file (SFX track): ").strip()
|
||||
|
||||
rate1, data1 = wav.read(file1)
|
||||
rate2, data2 = wav.read(file2)
|
||||
|
||||
if rate1 != rate2:
|
||||
raise ValueError("Sample rate mismatch!")
|
||||
|
||||
if data1.ndim != data2.ndim:
|
||||
raise ValueError("Channel count mismatch!")
|
||||
|
||||
# Convert to int32, addition (not normalization), then cap 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)
|
||||
|
||||
dir_name, base_name = os.path.split(file2)
|
||||
output_file = os.path.join(dir_name, "1_" + base_name)
|
||||
|
||||
wav.write(output_file, rate1, mixed)
|
||||
|
||||
print(f"Mixing complete! Saved as {output_file}")
|
||||
@@ -0,0 +1,4 @@
|
||||
The 2 platform uses BGM + SHOT, but mobile uses BGM or SHOT.
|
||||
This requires reprocessing the SHOT audio.
|
||||
Layering the audios directly (in audition, for example) won't work because the volume won't be preserved due to potential overflow of int16.
|
||||
This script preserves the volume by calculating things in int32 before capping everything back, ensuring that the audio volume stays consistent.
|
||||
Reference in New Issue
Block a user