READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Scripting Help (from Troubleshooting forum)

Coders and would-be coders alike, this is the place to talk about programming.
elcondor
VIP member
VIP member
Posts: 18
Joined: Tue Dec 14, 2004 11:28 am

Post by elcondor » Sun Mar 05, 2006 9:07 pm

Right, I've just confirmed that the script on the Wiki is the correct one, and that the sound files in SRFs are macintosh SFIL files (which means that they may need endian swapping)

User avatar
Mr.Mouse
Site Admin
Posts: 4039
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 559 times
Contact:

Post by Mr.Mouse » Sun Mar 05, 2006 9:19 pm

Ah thanks! ;)

taraquedo
ultra-n00b
Posts: 3
Joined: Mon Sep 18, 2006 11:44 pm
Been thanked: 1 time

Post by taraquedo » Mon Sep 18, 2006 11:55 pm

I solved the problem with the confusing soundfiles!

Sorry for my broken english but I am from germany. As mentioned here in the forum it is hard to find a way to play the soundfiles which are extracted of the srf-files. I figured out what it is and how to play these files under win os. Even better: I can also convert them to normal WAVE files.

I don't want to write it twice. So under http://free.prohosting.com/jellyvis/cgi ... 3;start=17 you can find a short description on how to play/convert the files yourself. This is too difficult for you? Then write a short mail to me and I can send you a small (german ;-) ) program which takes a srf, extracts every resource it knows (graphics too) and converts ima4 to wave. All in one step.

Thanks for the information in this thread which made my program possible.

Greetings from germany!

User avatar
Mr.Mouse
Site Admin
Posts: 4039
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 559 times
Contact:

Post by Mr.Mouse » Tue Sep 19, 2006 8:39 am

Hello folks and sorry for my broken english (i am from germany)!

I have made it!
I worked two days on hacking the soundfiles of ydkj and now i can play them under win os. I used the german version of ydkj but wikipedia says that the english version will work too.

So okay, here is what i figured out:
Extract the soundresources like mentioned above. Do so with MultiEx or other tools. MultiEx really does a bad job for this. Better write your own tool or use mine.
You'll get an ima4 encoded file but WITH a header. I do not understand the header so I deleted it. The header has a constant size of 84 bytes in every soundfile. Without the header the data must be a multiple of 34 - othernwise it is not an ima4.
Now add a new header in front of the data (for details see the AIFC description). Just use mine:
46 4F 52 4D XX XX XX XX 41 49 46 43 46 56 45 52
00 00 00 04 A2 80 51 40 43 4F 4D 4D 00 00 00 16
00 01 YY YY YY YY 00 10 40 0D AF C8 00 00 00 00
00 00 69 6D 61 34 53 53 4E 44 ZZ ZZ ZZ ZZ 00 00
00 00 00 00 00 00
You have to calculate the values for X, Y and Z in big endian.
X = the total filesize (data+header) - 8 Bytes
Y = size of data / 34 Bytes
Z = size of data + 8 Bytes
Rename the file to an extension ".aifc". With this you can (and should) play it with Quicktime. You can also convert it with a tool aifc2wav. Google for it. My application uses the code of this project to convert the ima4 to wave (ima4 is a really easy codec by the way). But there seems to be a problem: The wavefiles sound cropped. Maybe something wrong in the decoding.

Realize that the musicloops are not ima4 encoded. You can see this in the 84 bytes header at adress 0x3C. There is a "ima4" or 00 00 00 00. In case it is not ima4 encoded it is just plain pcm wave. use it with 22,5kHz 16bit and 1 channel.

You can get a compiled (german) tool which extracts srf to aifc and wave. Just ask me. But I am not going to make the source public for several reasons a) with aifc2wav it is almost trivial b) it is programmed under "stress" - no errorchecks c) legal issues.

Greetings from germany!
I took the liberty to post your comments on that board at this one.

You say "MultiEx does a bad job", what do you mean? It doesn't save a header? I'd have preferred you'd said "MultiEx doesn't add a header, so you have to add one yourself" . MultiEx extracts the files as they are saved in the archive. It's an extractor.

You also might have credited El Condor for pointing you in the right direction.

Oh and greetings from The Netherlands.

taraquedo
ultra-n00b
Posts: 3
Joined: Mon Sep 18, 2006 11:44 pm
Been thanked: 1 time

Post by taraquedo » Tue Sep 19, 2006 10:53 am

Hello again!

I've downloaded MultiEx in the latest version (with the scripts included there) and it works for the question resourcefiles well. But with the bigger (and more interesting) files like intro1.srf I had problems. MultiEx quits the open command to these files with an errormessage and you can do nothing against it.
Sorry I don't wanted to blame it on MultiEx. Of course MultiEx extracts the resources only and this is done quite good for the questionfiles. You can then delete the confusing header and replace it by mine.

Enjoy the Intro1, Intro2 and USD.srf - they are really funny ;-)

User avatar
Mr.Mouse
Site Admin
Posts: 4039
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 559 times
Contact:

Post by Mr.Mouse » Tue Sep 19, 2006 10:59 am

taraquedo wrote:Hello again!

I've downloaded MultiEx in the latest version (with the scripts included there) and it works for the question resourcefiles well. But with the bigger (and more interesting) files like intro1.srf I had problems. MultiEx quits the open command to these files with an errormessage and you can do nothing against it.
Sorry I don't wanted to blame it on MultiEx. Of course MultiEx extracts the resources only and this is done quite good for the questionfiles. You can then delete the confusing header and replace it by mine.

Enjoy the Intro1, Intro2 and USD.srf - they are really funny ;-)
Then it must mean that there are multiple SRF formats, and MultiEx supports one of them. It's not MultiEx's fault then, the other SRF format may simply not be supported. I would need to have examples of a file that works and a file that doesn't. To compare.

elcondor
VIP member
VIP member
Posts: 18
Joined: Tue Dec 14, 2004 11:28 am

Post by elcondor » Tue Sep 26, 2006 8:22 pm

Sorry to bring this up again, but is the script on the XentaXWiki the same as the one in MultiEx, as the one on the wiki appears to work for the more 'interesting' SRFs.

User avatar
Mr.Mouse
Site Admin
Posts: 4039
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 559 times
Contact:

Post by Mr.Mouse » Tue Sep 26, 2006 9:40 pm

elcondor wrote:Sorry to bring this up again, but is the script on the XentaXWiki the same as the one in MultiEx, as the one on the wiki appears to work for the more 'interesting' SRFs.
Hmm, it's not, so I checked. Damn, how's that possible.

Anyway, the new script is here in BMS form:
You do not have the required permissions to view the files attached to this post.

taraquedo
ultra-n00b
Posts: 3
Joined: Mon Sep 18, 2006 11:44 pm
Been thanked: 1 time

Post by taraquedo » Sun Nov 26, 2006 2:22 pm

Hi!

In a few hours you can download the SRF to WAVE Extractor I have made under
http://srfextra.sourceforge.net

It uses the GPL - so feel free to download the source and reuse it in your projects or to get a hint on how the srf files work. In a few hours you can download the source and a compiled binary for use under Win32 there. Enjoy!

Greetings from Germany!

User avatar
Dinoguy1000
Site Admin
Posts: 721
Joined: Mon Sep 13, 2004 1:55 am
Has thanked: 106 times
Been thanked: 130 times

Post by Dinoguy1000 » Mon Nov 27, 2006 5:01 am

hmm... might I ask why you didn't just start a new topic for it? :P
Welcome to Xentax!

Rules | Requests | Wiki

If you run across a post that breaks the rules, please report the post - a mod or admin will handle it from there.

IntimidatedAgain
ultra-n00b
Posts: 1
Joined: Wed Jul 01, 2009 5:30 pm
Has thanked: 2 times

Re: Scripting Help (from Troubleshooting forum)

Post by IntimidatedAgain » Wed Jul 01, 2009 7:20 pm

Apologies for the thread necro..

I've made a patch which fixes the audio clipping in the resulting .wav files in taraquedo's project above.

I've tried to contact taraquedo directly, but I suspect after three years he may be inactive on the project, so i'm posting it here to help anyone who might come accross this.

I've also uploaded a patched binary here for those who are not comfortable with patching source code, but please, always remember that downloading executable files from untrusted sources is risky. I can personally guarantee that the executable linked above is safe, but you have no reason to trust me.
You do not have the required permissions to view the files attached to this post.

xjcl
ultra-n00b
Posts: 1
Joined: Sun Sep 16, 2018 12:28 am

Re: Scripting Help (from Troubleshooting forum)

Post by xjcl » Sun Sep 16, 2018 1:34 am

I want to replace YDKJ3's question numbers with custom audio. Is this possible?


The SRFExtra program presented in this thread extracts music data from game files, but has no functionality to encode them AFAIK. To draw the whole pipeline:
SRF --SRFExtra--> AIFC (Apple audio) --SRFExtra--> WAV (Windows audio)
SRF <--???-- AIFC <--???-- WAV

So far I've downloaded and ran SRFExtra from https://sourceforge.net/projects/srfextra/files/, but as I said, that only allows me to extract audio, not encode it.
Since the file format seems to be known, writing an encoder should be possible, right?

I can't even find the C++ source for SRFExtra! Has this just vanished?


Thus I can't apply the patch posted by IntimidatedAgain. Is this even needed? Wouldn't any other aifc2wav program work? I tried using the BMS files that everyone posted and downloaded quickbms. This produced files with no file extensions that had the same sizes as the AIFC files produced by SRFExtra, so I thought it must be them. But then I ran a program called aifc2wav from http://sed.free.fr in a command line to convert them and it said "bad sound file, can't load".

Windows Media Player fails to play both the SRFExtra and quickbms versions of the AIFC files, although the SRFExtra file works in VLC Player. Only the old script from the wiki (29 July 2005) produces somewhat sensible output, the current one (4 August 2005) produces files garbage files with garbage names. The WAV files from SRFExtra work fine, although they are (as previously stated) cropped at the end and some contain crackling (e.g. QNUMBERS.SRF.1004.wav or QNUMBERS.SRF.2003.wav from YDKJ3)

Post Reply