Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Is it possible to preserve raw PCM data for reimporting?

Featured Replies

  • Author
  • Localization

R4nger, posted Sat Nov 03, 2018 3:16 pm (40075)


Hello, everyone!
I am attempting to extract a WAV file from Prince of Persia: Warrior Wihin's .sb0 files.
I managed to extract it and import it into audacity as raw data. I also managed to find the right offset for the size of the file, which is 0x350 threebyte in little endianness. However when I place a different file for reimporting, the archive gets completely changed (making it essentially useless). (This happens with both reimport and reimport2.bat and/or a smaller or higher file size,) however reimporting the original unchanged file works flawlessly. The WAV file specifically is named Pr_ONOHURT_001.WAV in the .sb0 file, which I included below. (It is renamed to .zip because .sb0 was not allowed.)

I will accept any kind of help. :)
Thank you in advance.
R4nger
  • Author
  • Localization

aluigi, posted Sat Nov 03, 2018 5:46 pm (40080)


What's the script you are using?
  • Author
  • Localization

R4nger, posted Sat Nov 03, 2018 11:55 pm (40084)


aluigi wrote:
What's the script you are using?

A very simple custom script which is only a few lines, those being getting the offset of the file, the size and the name and logging that. Nothing fancy. It works, but its a bit bad of a script.

Code:
goto x310
getdstring NAME 0x12
goto 0x33B
get OFFSET byte
goto 0x350
get SIZE threebyte
log NAME OFFSET SIZE
  • Author
  • Localization

R4nger, posted Sun Nov 04, 2018 12:51 pm (40096)


Although the OFFSET of the script is just 00, so i probably wouldnt even need to use the get command for it, but its just how i do it.
  • Author
  • Localization

aluigi, posted Wed Nov 07, 2018 11:11 pm (40183)


"goto x310" is not hexadecimal.
Do you mean "goto 0x310"?
  • Author
  • Localization

aluigi, posted Wed Nov 07, 2018 11:14 pm (40184)


Anyway the offset is for sure wrong and the reason your reimported file corrupts everything is just that one, offset 0 with a size bigger than 0x310 (where the first file name resides).
  • Author
  • Localization

R4nger, posted Thu Nov 08, 2018 5:27 pm (40196)


aluigi wrote:
Anyway the offset is for sure wrong and the reason your reimported file corrupts everything is just that one, offset 0 with a size bigger than 0x310 (where the first file name resides).


Interesting. I will keep that in mind, Aluigi. Thanks a lot for your help here! :)

PS: The original is indeed 0x310, a simple copy mistake.
  • Author
  • Localization

R4nger, posted Sun Nov 18, 2018 8:00 pm (40482)


It is me again!
I have managed to find some new info in the messy format of the .sb0 file, like the channel number, frequency and bits.

I was wondering if it would be possible to put this info into the WAV file itself, to make it playable right after extraction and if it would be possible to reimport again after that?

Code:
goto 0x300
get FREQ long
get BITS long
goto 0x310
getdstring NAME 0x12
getdstring DUMMY 0x16
get CH long
goto 0x2F0             //Temporal "correct" offset until I find the correct offset
get OFFSET short
goto 0x2C4
get SIZE long
log NAME OFFSET SIZE

Super sorry for the messy code, still kind of a noob to this! :D

PS: I realize this fits more into the "Audio and Video Formats" thread now, so if you wanna move it that thread, go ahead.
  • Author
  • Localization

aluigi, posted Mon Nov 19, 2018 12:52 am (40486)


I have a function that I use often in my script when I have to dump raw PCM data into a wav file.
The latest version is currently used in this script:
http://aluigi.org/bms/score_hero_bnk.bms

It's the function starting at line 50: startfunction TOWAV

I guess that in your case it's enough to use the following instead of "log NAME OFFSET SIZE":
Code:
math CODEC = 1
math FREQUENCY = FREQ
math CHANNELS = CH
callfunction TOWAV 1
  • Author
  • Localization

R4nger, posted Mon Nov 19, 2018 1:20 pm (40500)


Awesome! Thanks aluigi!
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.