Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Cracko298 authored Dec 3, 2024
1 parent 0da54c2 commit abfc2a6
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions CATool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, sys, re, urllib.request, time, zipfile, io, winsound, shutil, struct
from tkinter import messagebox
VERSION = 2.3
VERSION = 2.4

try:
import requests
Expand Down Expand Up @@ -228,9 +228,15 @@ def formatsToWave():
newFile = fileToConvert.replace('.flv','.wav')
newFile = os.path.basename(newFile)
os.system(f'.\\extrcd\\mpg\\bin\\ffmpeg.exe -y -loglevel quiet -i {fileToConvert} {os.path.dirname(__file__)}\\{newFile}')

print("\n\nConversion Completed.\n")

if '.dsp' in fileToConvert:
newFile = fileToConvert.replace('.dsp', '.wav')
newFile = os.path.basename(newFile)
os.system(f".\\extrcd\\gcadpcm\\cvt.exe -o {newFile} {fileToConvert}")
if '.fsb' in fileToConvert:
newFile = fileToConvert.replace('.fsb', '.wav')
newFile = os.path.basename(newFile)
os.system(f".\\extrcd\\gcadpcm\\cvt.exe -o {newFile} {fileToConvert}")
print("\nConversion Completed.")

def info_help():
print(f"""\n
Expand All @@ -245,7 +251,7 @@ def info_help():
--ap, add-padding [OriginalFilePATH] [ModifiedFilePATH] > Adds padding to set the Modified File Equal to the Original File Size.
--ne, name-extract [CombinedAudioPATH] [Sound Name/ID] > Extracts a FSB Soundbank File from the CombinedAudio.bin Archive via Name/SoundID.
--ra, rename-all [SegmentFolderPATH] > Renames all Segment Files back to their original FSB Soundbank Filename(s).
--gsid, get-soundid [CombinedAudioPATH] > Gets all Sound Names/ID's and Dumps them to a *.txt File.
--gsid, get-soundid [CombinedAudioPATH] > Gets all Sound Names/ID's and Segment File and Dumps them to a *.txt File.
--gssg, get-size-seg [SegmentFilePATH] > Gets the size of a specific Segment Soundbank FSB File.
--gs, get-size [SegmentOutFolderPATH] > Gets the size of all Segment Soundbank FSB Files.
--exa, extract-seg [SegmentFilePATH] > Attempts to extract Audio from Segment Soundbank FSB Files.
Expand All @@ -265,6 +271,7 @@ def info_help():
os.system('pause')

def getSoundId():
i = 0; a = 0
filename = sys.argv[2]
with open(filename, "rb") as file:
data = file.read()
Expand Down Expand Up @@ -293,8 +300,12 @@ def getSoundId():
string_end = data.find(null_byte, string_start)
if string_end != -1:
extracted_string = data[string_start:string_end].decode('utf-8', errors='replace')
if extracted_string == '':
extracted_string = f'NULL_{a}'
a += 1
print(f"Extracted string: {extracted_string}")
f.write(f"{extracted_string}\n")
f.write(f"{extracted_string} - segment_{i}.fsb\n")
i += 1

def renameSegments():
directory = sys.argv[2]
Expand Down Expand Up @@ -453,7 +464,7 @@ def gcadpcmAudio():
os.system(f'.\\extrcd\\gcadpcm\\cvt.exe -o .\\{fileF_0}_{segmentName}.wav {audio_file}')

def convertAudioGcadpcm():
originalFile = sys.argv[2] # Required because it's used in find_segment_name()
originalFile = sys.argv[2]
file2Convert = sys.argv[3]
originalFileName = find_segment_name()
if '.wav' not in file2Convert and '.wave' not in file2Convert:
Expand Down Expand Up @@ -644,11 +655,14 @@ def count_specific_bytes():
return sixCount, twoCount, celtCount, fmodCount, oneCount, interleavedFormat

def getMetaData():
answer = ""
combinedAudiof = sys.argv[2]
backupFile = f".\\extrcd\\def_aud.bin"
searchStr = b'FSB5'
count = 0
with open(combinedAudiof, 'rb') as file:
header0 = file.read(0x1A2C)
file.seek(0x1A2C)
data0 = file.read()
count = data0.count(searchStr)
file.seek(0x00)
Expand All @@ -658,10 +672,18 @@ def getMetaData():
lngth = len(data0[:position])

with open(backupFile,'rb') as f1:
header1 = f1.read(0x1A2C)
f1.seek(0x1A2C)
data1 = f1.read()

if data0 != data1:
answer = 'Yes'
if header0 != header1 and data0 != data1:
answer = "Yes (Header and SFX where Changed)"
elif header0 != header1 and data0 == data1:
answer = "Yes (Header was Changed)"
elif data0 != data1 and header0 == header1:
answer = 'Yes (SFX was Changed)'
elif os.path.basename(combinedAudiof) != 'CombinedAudio.bin' and "Yes" not in answer:
answer = "Yes (Filename Changed)"
else:
answer = "No"

Expand Down

0 comments on commit abfc2a6

Please sign in to comment.