From 6831274a25af6aa0eaa066a8d96dc4ce22473a23 Mon Sep 17 00:00:00 2001 From: Zorchenhimer Date: Sun, 16 Nov 2025 17:38:41 -0500 Subject: [PATCH] [rom] Fix writing AUDI data The length of the audio chunk was incorrect and did not include the format bytes. This was also the source of the "garbage four bytes" that were being chopped off before. --- rom/write.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rom/write.go b/rom/write.go index 1fa7923..e3e0516 100644 --- a/rom/write.go +++ b/rom/write.go @@ -56,7 +56,9 @@ func (sb *StudyBox) rawBytes() ([]byte, error) { return nil, err } - err = binary.Write(buffer, binary.LittleEndian, uint32(len(sb.Audio.Data))) + // This length is the full size of the chunk, including the format from the + // switch below. + err = binary.Write(buffer, binary.LittleEndian, uint32(len(sb.Audio.Data)+4)) if err != nil { return nil, err } @@ -81,8 +83,7 @@ func (sb *StudyBox) rawBytes() ([]byte, error) { return nil, err } - // For some reason there's 4 extra bytes. no idea why. chomp them off. - _, err = buffer.Write(sb.Audio.Data[0 : uint32(len(sb.Audio.Data))-4]) + _, err = buffer.Write(sb.Audio.Data[0 : uint32(len(sb.Audio.Data))]) if err != nil { return nil, err }