Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Software Development

Thread Tools
Old 15-04-14, 16:03   #501
Suikaze Raider
Suikaze Raider's Avatar
Join Date: May 2007
Location: Almeria (Spain) Type: Crazy TR Fan.
Posts: 473

Originally Posted by Lwmte View Post
As for TR3 and above - there should be less problems, since OpenAL supports ADPCM natively, so we don't need any external codecs and libraries. Most problematic one is, of course, TR3, which keeps all of its audio inside CDAUDIO.WAD file - we have to make a parser for it.
You could extract the audio files from "cdaudio.wad" file; they are waves with the same format that TR4 and TR5. It's only a suggestion

Working in TR1 & TR2 Translations.
Suikaze Raider is offline   Reply With Quote
Old 15-04-14, 16:12   #502
Lwmte's Avatar
Join Date: Aug 2010
Posts: 1,317

Yes, surely we can do this, but it means that user should do it by himself - because we can't distribute original TR soundtracks with OpenTomb because of copyright reasons. Moreover, it could be difficult task for many users. Easiest way is just to drop cdaudio.wad into audio folder, and engine should do everything else by itself.

But we can have an option, like engine searching for cdaudio.wad file, and if it's not found, it loads corresponding OGG file (for example, if user replaced native TR3 OST with remastered one that is available on forum).
Lwmte is offline   Reply With Quote
Old 15-04-14, 21:15   #503
Titak's Avatar
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 32,822

Originally Posted by Lwmte View Post
Titak, I remember I've perfectly synchronized jump timing and distance with TR4 engine side by side, so it should match almost perfectly. Or do you mean jump curve? Yes, it's a bit different (original TR one being a bit sharper), but it's more related to difference between native TR physics and bullet physics.
Yeah, I guess I mean the jumpcurve.
It is flatter, so to speak, now. Which, in my opinion anyway, makes it look more like a sort of gliding.

Oh well, not really a big deal.

You guys are doing an amazing job figuring this all out!
If it walks like a duck and if it quacks like a duck, it is a duck.
Titak is offline   Reply With Quote
Old 15-04-14, 21:57   #504
Relic Hunter
Dustie's Avatar
Join Date: Apr 2005
Location: Poland
Posts: 9,209

I bet the hard part will be when you guys will want to do shooting and enemy AI, but I'm keeping my fingers crossed!
Dustie is offline   Reply With Quote
Old 18-04-14, 11:58   #505
SLAYER's Avatar
Join Date: Jun 2006
Location: Jordan
Posts: 2,182

How to run this exactly? it crashes immediately after opening.
Right now, I'm losing patience
SLAYER is offline   Reply With Quote
Old 20-04-14, 18:29   #506
Lwmte's Avatar
Join Date: Aug 2010
Posts: 1,317

Ok, audioplayer is now fully implemented! We now have proper multitrack playback, so background ambience and one-shot tracks are played in different channels. But unlike TREP or TRNG, OpenTomb allows to define as many channels as you need, with automatic crossfade management and silencing background track when something different is played in other channel. I also plan to add TR3-like underwater low-pass filter to background channel.

Right now, player only supports Ogg Vorbis tracks, because I have no idea how to stream ADPCM wavs, plus I don't know CDAUDIO.WAD format! It would be helpful if someone will provide OpenAL/ADPCM streaming code example - maybe Turbo Pascal? I know you have this program called Cdaudio Player, which extracts tracks from WAD and plays it! It'll be nice if you will provide code piece which reads and decompresses ADPCM data into buffers.

Here is the test archive with exe and updated config.

Currently it is hardcoded for TR1 audiotracks only, so to make it work you must create data/tr1/audio/ subdirectory in OpenTomb folder, and place there all CD audio tracks grabbed from TR1 PSX CD in OGG Vorbis format with naming like "002.ogg" and so on (first one will be exactly 002.ogg, because first track on the CD is the data track).

Or you can simply download this archive, which contains already ripped TR1 CD audio!

To test audiotrack player, simply step onto any CD trigger in any TR1 level, or enter playstream "X" command in console, where X is any track number between 2 and 57.

P.S.: I had serious problems debugging OGG streaming, seems like it is very sensitive to buffer size - currently I have defined 64 kb buffer size in config file, plus made quad buffering to minimize bugs. I need some feedback to know that it works stable with such setup, so if you will encounter aburpt audio stops or glitches, please report!

SLAYER - Have you overwritten previous version with some new version? If so, you may need to update scripts and/or config file. Since scripts are still being written, you can catch a crash if script version isn't proper. Scripts are placed here: https://sourceforge.net/projects/ope...files/scripts/ - just put them into corresponding OpenTomb subdirectories and see if something changes.

Last edited by Lwmte; 20-04-14 at 19:02.
Lwmte is offline   Reply With Quote
Old 20-04-14, 20:05   #507
Relic Hunter
-Roli-'s Avatar
Join Date: Jul 2007
Posts: 5,486

Wow, guys, you're amazing!
I'm so happy to see all these progress!

Keep up the great work!
-Roli- is offline   Reply With Quote
Old 20-04-14, 20:47   #508
Turbo Pascal
Join Date: Jan 2004
Location: Central America
Posts: 111

Hi Ensi.

Cdaudio.wav is just a simple *.wav collection files embeded in one big file with a header chunk; every wave inside is a full wave file, if you extract one wave chunk and save it like file01.wav then you can play that file with any wave player.

You will need to found a C++ lib that open *.wav file but from stream memory instead from file disk ( i mean, instead passing the file name you also have option to pass the stream and the offset position in memory).

This Lib has to be capable to read ADPCM data and give you back normal PCM data to feed your openal buffer; even better if that lib can play directly the sound.

Cdaudio.wav file format:

It has two sections:
- Directory section with fixed amount entries, where every entry store a filename, a file offset position and a file size.
- Full wave files stored one after other.

* Directory section.
If i remember well there is space for 128 entries (you have to check yourself) some entries are unused (free or blanks) in the original cdadio.wad; first two entries are blanks entries.

Entry format is:
- 260 bytes, File name description.
- 4 Bytes, File offset where the wave sound begins. This value start counting after the directory section; so you have to add to this value the file directory section size to get the real file position inside cdaudio.wav.
- 4 bytes, File wave size; with this pair offset/size you can extract the sound chunk and/or pass to your C++ library to play this sound.

Good luck.
Turbo Pascal is offline   Reply With Quote
Old 20-04-14, 22:19   #509
Lwmte's Avatar
Join Date: Aug 2010
Posts: 1,317


I looked at source code of OpenAL Soft, which is used in OpenTomb, and it seems there is built-in support for ADPCM codec... The difference is, it's called IMA4 in sources, I suppose it's the same thing as MS-ADPCM. Also, now I remember that ages ago, when audio engine was only in project, TeslaRus tried to load TR4 audios, and they played successfully without any conversion! That's advantage of OpenAL Soft over deprecated official OpenAL. So basically, my task is reduced to making these wavs stream correctly and (for TR3) extract them from cdaudio.wad. Thanks for the structure, I'll try to decipher it!

By the way, now we have another problem surfaced. In TR2, there is no direct correlation between physical CD track index and internal engine track index. I have no idea why it was done this way, maybe some regional issues which required re-arranging CD tracks... Anyway, it looks like we need to write a script which will translate track indexes correctly!
Lwmte is offline   Reply With Quote
Old 23-04-14, 11:50   #510
Lwmte's Avatar
Join Date: Aug 2010
Posts: 1,317

Ok, it seems it was harder than I thought... Although SDL/OpenAL supports ADPCM wave files, they support them only by means of buffering ALL file at once; i. e., I can load whole wav file into memory, but can't stream it... Also I couldn't find ADPCM streaming examples on the Web (it's hard for me to get into uncompressing ADPCM data into PCM on the fly, as it involves some complicated algorhitms).

So, I decided NOT to implement WAD/WAV streaming soundtracks for now. Everything will be in OGG (whatever, if we already converted TR1/2 audio to OGG, why not for all other games? ).

Finally, I have ruled out complicated TR2 soundtrack management. As I thought, there was internal routine that converted CD trigger index into internal CD audio track index and played it. Why Core did this in the first place? I suppose it happened because level designers worked seperately from Nathan McCree, so they left placeholder CD triggers, which was later linked to actual CD track indexes via this index conversion routine.

Anyway... Now ALL soundtracks are manageable via Lua script. There, you will be able to define file name for each track and track type (background, one-shot or voice). And of course, these three types could be intermixed and overlayed with fancy crossfades - here is the demonstration!

I'll update code on SF when I rule out error handling and finish audio scripts for TR3-5.
Lwmte is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT. The time now is 11:05.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.