Skip to content

Commit

Permalink
Don't convert SND0 if it is already in AT3 format
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information
sahlberg committed Aug 14, 2023
1 parent 804a80a commit cb01d04
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pop-fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def convert_snd0_to_at3(snd0, at3, duration, max_size, subdir = './'):
subprocess.run(['atracdenc/src/atracdenc', '--encode=atrac3', '-i', tmp_wav, '-o', tmp_snd0], check=True)
except:
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\natracdenc not found.\nCan not create SND0.AT3\nPlease see README file for how to install atracdenc\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
return None
print('Converting EA3 to AT3 file') if verbose else None
temp_files.append(at3)
create_riff(tmp_snd0, at3, number_of_samples=int(len(s['data']['data'])/4), max_data_size=0, loop=True)
Expand Down Expand Up @@ -878,6 +879,15 @@ def create_psp(dest, disc_ids, game_title, icon0, pic0, pic1, cue_files, cu2_fil
True

snd0_data = None
if snd0:
# Check if it is already in ATRAC3 format
with open(snd0, 'rb') as s:
buf = s.read(36)
if buf[:4] == b'RIFF' and buf[8:12] == b'WAVE' and struct.unpack_from('<H', buf, 20)[0] == 0x270:
print('SND0 is already in AT3 format. No conversion needed.')
s.seek(0)
snd0_data = s.read()
snd0 = None
if snd0:
try:
temp_files.append(subdir + 'snd0_tmp.wav')
Expand Down Expand Up @@ -1042,7 +1052,14 @@ def create_ps3(dest, disc_ids, game_title, icon0, pic0, pic1, cue_files, cu2_fil
of.write(GenerateSFO(sfo))
temp_files.append(f + '/PARAM.SFO')
if snd0:
subprocess.call(['ffmpeg', '-y', '-i', snd0, '-filter:a', 'atempo=0.91', '-ar', '44100', '-ac', '2', subdir + 'snd0_tmp.wav'])
# Check if it is already in ATRAC3 format
with open(snd0, 'rb') as s:
buf = s.read(36)
if buf[:4] == b'RIFF' and buf[8:12] == b'WAVE' and struct.unpack_from('<H', buf, 20)[0] == 0x270:
print('SND0 is already in AT3 format. No conversion needed.')
copy_file(snd0, f + '/SND0.AT3')
snd0 = None
if snd0:
try:
temp_files.append(subdir + 'snd0_tmp.wav')
if os.name == 'posix':
Expand Down

0 comments on commit cb01d04

Please sign in to comment.