mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
93a1b7af8c
Stopped copying over peach's lines from the mario folder to wario/luigi sound folders Stopped compiling peach's lines for wario/luigi sound folders Created a tool to precompile the aiffc tables and append them into custom sounds this matches what mario's sound files are like I believe the issue is that previously we would copy over the sound files and they were either incomplete or would be compiled during the copying process I noticed that Mario's sounds had their sound tables inserted into the aiff file already, and none of our custom sounds did. This caused a different path to be taken for mario sounds than the rest of ours. In order to prevent the possibility that there was a problem with that seperate path, I've created a tool that can insert the table into the file to match how mario sounds are.
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import os
|
|
import time
|
|
|
|
# find sound/samples/*custom* -name '*.aiff' | while read filename; do python3 tools/append_aiffc_table.py "$filename"; done
|
|
|
|
# Get the filename from the first command line argument
|
|
if len(sys.argv) < 2:
|
|
print("Usage: {} <filename>".format(sys.argv[0]))
|
|
sys.exit(1)
|
|
filename = sys.argv[1]
|
|
|
|
# check if the binary file contains the string 'VADPCMCODES', and if so print that it was already found and exit
|
|
with open(filename, 'rb') as f:
|
|
content = f.read()
|
|
if b'VADPCMCODES' in content:
|
|
print('Already contains a table for ' + filename + '. Exiting.')
|
|
sys.exit(0)
|
|
|
|
# run the program ./tools/tabledesign on the specified filename and capture the output
|
|
import subprocess
|
|
command = ['./tools/tabledesign', '-s', '1', filename]
|
|
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
output = result.stdout.decode('utf-8').strip()
|
|
|
|
# split the output by whitespace
|
|
words = output.split()
|
|
|
|
# calculate header info
|
|
size = len(words) * 2 + 18
|
|
unknown = 0x0b
|
|
version = 1
|
|
|
|
# append the chunk header
|
|
chunk = b''
|
|
chunk += b'APPL'
|
|
chunk += size.to_bytes(4, 'big', signed=True)
|
|
chunk += b'stoc'
|
|
chunk += unknown.to_bytes(1, 'big', signed=False)
|
|
chunk += b'VADPCMCODES'
|
|
chunk += version.to_bytes(2, 'big', signed=False)
|
|
|
|
# convert each word to a signed 16 bit integer and append them to content
|
|
for word in words:
|
|
value = int(word)
|
|
chunk += value.to_bytes(2, 'big', signed=True)
|
|
|
|
# find the index of the first instance of 'SSND'
|
|
index = content.find(b'SSND')
|
|
if index == -1:
|
|
print("Couldn't find 'SSND' for ' + filename + '. Aborting.")
|
|
sys.exit(1)
|
|
|
|
if size != len(chunk) - 8:
|
|
print('Failed to generate the correct size for ' + filename)
|
|
sys,exit(1)
|
|
|
|
# insert the chunk before 'SSND'
|
|
content = content[:index] + chunk + content[index:]
|
|
|
|
# write the modified content to the binary file
|
|
with open(filename, 'wb') as f:
|
|
f.write(content)
|