R3: Music Extraction Discussion Topic

Talk about the Rayman music website.

Moderators: Droolie, English moderators

Forum rules
Please keep the forum rules and guidelines in mind when creating or replying to a topic.
Hunchman801
Bad Rayman
Posts: 83848
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 610019

Re: R3: Music Extraction Discussion Topic

Post by Hunchman801 »

I would take ages to rewrite a whole game from assembly language, even if several people worked on it. Not to mention that only über-geeks program in ASM xD
Image
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

I'm not planning to recode the whole game!!
And anyway, only trying to identify the part of the program responsible for the decoding of the speechs/musics is a real pain in the ass!
Hunchman801
Bad Rayman
Posts: 83848
Joined: Thu Aug 07, 2003 6:50 pm
Location: Paris, France
Contact:
Tings: 610019

Re: R3: Music Extraction Discussion Topic

Post by Hunchman801 »

Well yeah, this is why I think we would have to reprogram the whole game xD
Image
gmsj0001
Électoon
Posts: 20
Joined: Wed Jul 23, 2008 1:26 pm
Location: Shanghai, China
Contact:
Tings: 0

Re: R3: Music Extraction Discussion Topic

Post by gmsj0001 »

i'm the topic starter and now i'm back~~ :D

i finally failed to extract musics from data.hst last summer because i know little about sound file struct. but these days i learn little about dasm... :D

the music and sound decode function is at offset 0x42C550 in my computer (i means, r3 pc has different editions). the program use MMX statements to decode the music... i guess if anyone who knows more sound structs and some about MMX? brother Synthesis? seems only you're able to work for this... :fou2:

just use OllyDbg to debug Rayman3.exe, it's very easy for you because i already find the currect function offset... but don't forget to use D3DWindow to hook rayman3 or you'll be in trouble...
LunaVorax
Antitoon
Posts: 96
Joined: Mon Jul 03, 2006 11:31 pm
Location: Lune
Tings: 0

Re: R3: Music Extraction Discussion Topic

Post by LunaVorax »

Hunchman801 wrote:I would take ages to rewrite a whole game from assembly language, even if several people worked on it. Not to mention that only über-geeks program in ASM xD
Actually, that's what all the guys working on the ScummVM project are doing everyday.
(Yeah, old quote is old)
deton24
Garatta Ciatik
Posts: 1141
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 8652

Re: R3: Music Extraction Discussion Topic

Post by deton24 »

Hi again people in this topic, after 5 years.
Curiousity: Did you know that GOG used Synthesis' rip in their release of soundtrack in their retail-online version of R2?
The question is...
how did this happen xD
Though, as you know, nowadays, when game devs use scene cracks to put their games on Steam... (Max Payne 2) it seems like everything's possible.

This GOG-Synthesis release of soundtrack contains unused music from PC version, but used later in Revolution, and sounds a little better than extracted from PS2, someway. Such further curiosity.
But for a remastering purposes, PS2 FLAC version is the best.

Here's a continuation of this topic - R3 audio extracting tool:
http://raymanpc.com/forum/viewtopic.php ... 43#p370643
Last edited by deton24 on Thu Jul 26, 2018 2:36 am, edited 1 time in total.
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

deton24 wrote:Hi again people in this topic, after 5 years.
OMG that's right, I'm late as well :p
deton24 wrote: Curiousity: Did you know that GOG used Synthesis' rip in their release of soundtrack in their retail-online version of R2?
The question is...
how to this happened xD
Honestly I don't have a clue. Found out somewhat by accident. One day my old copy of Rayman 2 wouldn't work with Daemon Tools under W7 so I thought "well, screw it, it's crazy cheap on GOG so I'm just gonna buy it there". I was surprised to see my old rips provided as a bonus download! What made me click was that the file names weren't even changed, and there's a missing part in "Riding the Shell" (the part between 0:50 and 0:57 in this video).

I'm surprised they used my rip instead of Droolie's, which iirc is is based on the Dreamcast port, which is uncompressed.
deton24
Garatta Ciatik
Posts: 1141
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 8652

Re: R3: Music Extraction Discussion Topic

Post by deton24 »

Nice to see you again Synthesis.

They have used PC rip because they sell just PC version. Revolution has bonus tracks, as well as previous rip from DC version, which was in fact, line-in recorded. This PCMs which you've mentioned would probably need to arrange again from tiny parts of songs. As I done it with PSX version (with splitting all this small parts, seamlessly one by one, and then arrange). Maybe license or sth. They're just not UBI to use all possible sources. (or they were just lazy)

Can I ask, finally, according to this topic:
http://raymanpc.com/forum/viewtopic.php ... 43#p366681
Whether is possible to unpack R3 PC music already, or it's still too complicated?
I'm lost my self in this whole stuff. Respect.

PS. Old R2 version may be probably installed only on x86 system, or only XP, I'm not sure.
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

deton24 wrote:Nice to see you again Synthesis.
Can I ask, finally, according to this topic:
http://raymanpc.com/forum/viewtopic.php ... 43#p366681
Whether is possible to unpack R3 PC music already, or it's still too complicated?
I'm lost my self in this whole stuff. Respect.
Sure that's possible. Did you try gmsj0001's tool? Does the job pretty well.
I don't have its source code and I won't go into the time-consuming task of deassembling it, but I guess the program scans the "Data.hst" resource file, and then for each file it finds, it runs a little piece of assembly code copy-pasted from the actual game executable. I might be wrong but that's the idea.

I haven't listened to all the files it extracted since there are more than 1900 of them, but I assume all the music is extracted. The only problem with the tool is that the proper file names aren't retrieved -- the files have ID names, like "512.wav" or "2207.wav", which makes it hard to differenciate which song they belong to.
deton24 wrote:
Synthesis wrote:One day my old copy of Rayman 2 wouldn't work with Daemon Tools under W7 so I thought "well, screw it, it's crazy cheap on GOG so I'm just gonna buy it there".
PS. Old R2 version may be probably installed only on x86 system, or only XP, I'm not sure.
I remember running it on an x86 machine. I think the main reason was that it was a CD image extracted from a burnt copy of a friend's original CD... I was using a No-CD patch; and even though the game was correctly installed, I had that big pirate head popping up in the middle of the Precipice, asking for the CD in the drive, and then some parts of the levels started to load incorrectly (eg. missing platforms), making it impossible to finish...
deton24
Garatta Ciatik
Posts: 1141
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 8652

Re: R3: Music Extraction Discussion Topic

Post by deton24 »

Did you try gmsj0001's tool? Does the job pretty well.
[...]
I guess the program scans the "Data.hst"
[...]
I assume all the music is extracted
Thank you, now I know what to do. But I need to decrypt it from this smart way of publish via Hex.
I had that big pirate head popping up in the middle of the Precipice, asking for the CD in the drive
Woah, I had this at another level (maybe rock and lava, or stone and fire). Without any patch.
But it's just a matter of proper NoCD patch. Then I loaded other level with cheats. GoG version works fine.
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

Hang on for a second, I'm reuploading the file...

Edit: Here it is.

Edit 2: which reminds me, I haven't posted the source code for Zeroid (plus there's a buggy version hanging around somewhere).
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

I made this tool nearly 7 years ago and pretty much haven't touched it since, so I don't remember much about the format of the .apm files. As far as I remember there's a header with the initial values and a bunch of other things that my decoder didn't use.
deton24 wrote:is there any opportunity to copy again into the game, new sfx files, overwriting them (PC)?
Technically it's not impossible, but to be able to do so, you have to know what the .apm file structure is and what each value means in the file header. The raw audio data is just plain IMA ADPCM.
deton24 wrote:Do you know whether engine runs 44kHz audio?
I don't remember whether the sample rate is included in the APM header, so I can't tell you. If not, then you'll be out of luck trying to use your PS rip since it would be played at half speed.
deton24
Garatta Ciatik
Posts: 1141
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 8652

Re: R3: Music Extraction Discussion Topic

Post by deton24 »

I don't know much about programming. It requires to fill IMA ADPCM files with .apm extra data, probably in series.
Even if files would be properly encoded with 44kHz, engine may still run them in downgraded samplerate.
Anyway I doubt in existing of capable daredevils willing to do that with such an old game.
Thank you for your help!
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

I just dug up my old Ray2Get source code and had a quick look at some of the .apm files: yes, the sample rate is included in the header! Which means it would totally be possible to replace the soundtrack of the game with some custom audio! (Not sure that just any audio would play properly though.)

I will post a more detailed file format description once I have gathered enough information, just hang on for a moment.
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

So here's what I managed to infer so far with a bit of tweaking around (some things might be incorrect):

Code: Select all

OFFSET  SIZE TYPE          DESCRIPTION
------  ---- ----          -----------
0x00    2    ?             ? (0x00 0x20)
0x02    2    short         number of channels
0x04    4    int           sample rate
0x08    4    int           byte rate, uncompressed
0x0c    2    short         ? (0x0001)
0x0e    2    short         ? (0x0004)
0x10    4    int           ? (0x00000050)
0x14    4    char * 4      ? ("vs12")
0x18    4    unsigned int  total file size in bytes
0x1c    4    unsigned int  size of the data chunk, "DATA" not included:
                           - for stereo files, this is equal to the total file
                             size - 100 or - 101, depending on whether the size
                             is odd or even (yes, some stereo files have an odd
                             data size, for some reason)
                           - for the only mono file (outro1.apm), this is equal
                             to TWICE the value of (total file size - 100), for
                             some reason
0x20    4    ?             ? (0xFF 0xFF 0xFF 0xFF)
0x24    4    ?             ? (0x00 0x00 0x00 0x00)
0x28    4    ?             ? (0x00 0x00 0x00 0x00)

For stereo audio:
0x2c    4    signed int    initial PCM value for right channel (16-bit value
                           stored as a 32-bit int with sign extension)
0x30    4    int           initial step index for right channel
0x34    4    byte * 4      bytes 2 to 5 of the DATA chunk
0x38         signed int    initial PCM value for left channel (16-bit value
                           stored as a 32-bit int with sign extension)
0x3c    4    int           initial step index for left channel
0x40    4    byte * 4      first four bytes of the DATA chunk

For mono audio:
0x2c    4    signed int    initial PCM value (16-bit value stored as a 32-bit
                           int with sign extension)
0x30    4    int           initial ADPCM step index
0x34    4    byte * 4     first four bytes of the DATA chunk

The rest of the header seems to be padded with zeros.
0x60    4    char * 4      data chunk header ("DATA")
0x64    ?    ?             raw audio data;
EOF
A word on ADPCM stereo interleaving:

An ADPCM stereo signal is divided in 2-byte blocks of audio data; each blocks contains 2 samples for each channel (that makes it 4 nibbles).
For example, let's take the following block: 0xAB 0xCD.
Sample 1 for left channel is nibble A;
Sample 1 for right channel is nibble C;
Sample 2 for left channel is nibble B;
Sample 2 for right channel is nibble D.

Edit: I'm gonna be quite busy in the next three weeks, but if I'm motivated enough I might give it a try and write a WAV-to-APM converter. :D
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: R3: Music Extraction Discussion Topic

Post by Synthesis »

I haven't looked into .bnm files, so that'll only apply to the music. If it does work, of course.
deton24
Garatta Ciatik
Posts: 1141
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 8652

Re: R3: Music Extraction Discussion Topic

Post by deton24 »

I understand. Anyway, changing music inside, would be also some option.

I just looking at DC archives, and extracting music from there is much easier than from PC...
And it sounds better. Segments are ordered and have some names: PO/PS/RH...
It is a pity that it didn't turned out before. It would saved a lot of work to you in those days.
Program running .dcz files - Psound (allows unpacking)
Extracting DC image - gdiexplorer
I also preserved separated music segments from PSX version.

But for SFX I'd like PS2 or DC version. It's better to remaster than from PC (has a lot of noise). PSX has below 22kHz SFXes (sth like 11kHz).
I just looking for SFXes from DC version.
PS2's .bf files decipherated Droolie. I don't know whether SFXes are readible as same as music currently.

DC SFXes are here: (unreadable)
https://copy.com/iN9kiw7KFqX1PQOS
DAT files describe content of every .osb bank (one shot bank). Names inside relates to PC files. They're waves. But noone managed tool for .osb it so far. These files inside archives are joined together.
It's still on wanted list of one Jet Set Radio Modding Discussion Thread:
http://steamcommunity.com/app/205950/di ... ideModal=1.
Pity.
Oh, it looks like I found something: (still distorted)
https://www.youtube.com/watch?v=rE-DZNAgBa0
Another complicated programming job. But it's just VOX ADPCM (snd is distorted, though).
That's just for an info for someone.

Rayman 2 revolution PS2 SFX and voices
http://www.mediafire.com/download/u5xv8 ... v-VSFX.zip

But their quality is worse than from PC version, except voices (PCM).

SFX for Rayman 3
http://www.mediafire.com/download/xdnmm ... +-+SFX.zip
Last edited by deton24 on Thu Jul 26, 2018 2:40 am, edited 1 time in total.
Post Reply