VOGONS


Audiopack revival

Topic actions

Reply 180 of 301, by Glidos

User metadata
Rank l33t
Rank
l33t

Oh, that's a shame.

I wonder if there are floats further back in the process. Does sound far more difficult. Well, at least now we know.

Reply 181 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Okay, back to the audio pack.

Everyone here has been putting lots of work (re)defining the triggers. Has anyone confirmed whether or not the audio triggers are actually still in the levels? I wouldn't be surprised if they are.

Looking at the game code, it seems that it's using audio effect numbers that correspond to the PlayStation CD track numbers given in the post by slube on page 4 of the thread.

Only at the last minute does it map these numbers to actual PC CD track numbers.

Here is what it does for each internal effect number:

2: play CD track 2 (title)
3..12,14..21: ignored (the missing PS tracks)
13: played internally (secret chimes: internal sound effect 173)
22..25: mapped to CD tracks 7..10 (cut scene dialogues)
26..56: played internally? (internal sound effects 174-204?)
57..60: mapped to CD tracks 3..6 (new? background ambience)

So internal effect numbers 2 to 25 directly correspond to PlayStation CD tracks. 😮 And it looks like it has knowledge of the missing PlayStation audio tracks, and just knows not to look for them on the CD. 😁

Now, I'm wondering...

What's the deal with PlayStation ambient tracks? Does it really only have 1 ambience? Is PlayStation track 13 the secret chimes?

And if the levels did still contain have PlayStation audio triggers, why would they leave them off the CD? Space? Is the PC data bigger than the PlayStation? Performance? Were they having problems with game judder on audio cues? So they settled for more ambience instead?

Shall we have a go at patching this up to Glidos for a quick test? It's an easy patch - I can make a dummy Glide call giving the requested internal track number.

Alternatively, if someone wants to make an ISO image containing the game and the audio tracks, we could test it that way - I could patch it to access the full set of CD tracks. I'd suggest a new mapping though to make the patch easy - put them in PlayStation order (2..25), then put the three new ambiences as 26..28. I'll deal with the odd case of the shared ambience.

I'm not thinking about how we actually distribute the audio yet - I just want a quick way to check to see if the levels have the audio triggers.

Reply 182 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Hmm, no it's not going to be quite that easy. The audio code is only called in a few places that I can find, and there's nothing taking an arbitrary effect number. 😢 Still, it could be there in the level data.... Anyone know anything about TR level file formats? But some new code would have to be added to operate the trigger.

Reply 183 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Good news everybody! 😁 😁 😁

The audio triggers are in the PC level files.

For example, looking at level 1 with the Fexinspect tool, we have:

Soundtrack 5, triggered on Lara's starting position
Soundtrack 9, triggered when you pull the switch to open a door at the bottom of a shallow slope.
Soundtrack 8, triggered along with two wolves when you enter an open area.
Soundtrack 12, triggered when you pull the switch at the other side of that area to open the double doors.
Soundtrack 9, triggered as you turn right into a corridor with a couple of dart traps.
Soundtrack 16, triggered along with a wolf as you move along the gallery above the big trench with darts.

So, unless the level data is buggy, there's no need for any scripting. I can patch it to request the audio tracks already coded in the levels!

Reply 184 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

My next question is what happens with ambient background on the PlayStation? Is there any? The PC executable is hard-coded with the ambient track for each level, but I see that level 1 has an explicit trigger for track 5 (the track that the PC uses later for St. Francis' Folly, according to slube).

What does the PlayStation do? Does it have any looping ambience?

Reply 185 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Ah, found the audio trigger code. 😁 The triggers in the level files are used, at least for Lara's tuition at her home. (Although those get redirected to run from the PC audio). And there are special cases built into the executable for "only trigger this audio if she's clutching a ledge". (Which is nice, because that immediately tells me the "clutching a ledge" state value etc. 😀)

So, a patch to use the level triggers should be extremely easy - we just need to spec out exactly how it should communicate with Glidos. How does the current audio pack stop the game playing audio from the CD?

Also, the games built-in audio is extremely ropey. How about we replace it with high-quality stuff? We could easily replace all the tracks with the PlayStation CD ones, if we stop the game playing itself.

Reply 186 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

How to get all the music triggers working with 8 bytes of data...

(Sorry to those of you who slogged your guts out making those texture triggers. 😳)

As a test of concept only, here's a very short patch that shows that the triggers in the level files work. If you want to try it you'll need to burn a replacement TR1 CD with the PlayStation track order on, so tracks 2..25 are as described for the PSX in slube's list. (Track 13 is the secret chime, and won't be used - put a dummy in, or use track 43 off of the TR2 CD). I also popped PC tracks 3-6 on as 26-29, but they're not being used yet.

Alternatively, if you have 2+ CD drives, put an PlayStation TR1 CD in your first drive, and put your PC TR1 CD in another. (Sloppy coding from Core there - getting the audio off the first drive rather than the same drive as the data - maybe I should patch that. Handy for this though). This trick may also be useful if you have a CD burner that can't do mixed-mode data+audio disks.

Then change the following bytes of tomb.exe with a hex editor:

[code]Addr Change
5D434 7E -> EB
5D4AC 7C -> EB
5D4C0 7E -> 7F
5F4C7 36 -> 00
6EFE3 66 83 3D -> 90 C6 05
6EFEB 74 -> EB[/code]

And hey presto, you now have a PC Tomb Raider that plays all the PlayStation audio cues. And you don't even need Glidos, or the Audio Pack trigger files.

Drawbacks of this very simple patch:

  1. No more ambient background (but the ambient is triggered at the very start once in level 1).
  2. It's clunky - maybe 3 to 5 second pause while it starts a track.
  3. Some performance issues - the drive is left running after a track completes, and this seems to induce a bit of judder (didn't TR2 get a patch for that? hmmm...). Should be easy to fix this - just get it to issue a STOP command when it detects the track's done.
  4. It's no longer compatible with the original CD; if you wanted to do it like this, it would probably be better to use slube's remapped order, and add code to do the remapping.
  5. The title track doesn't loop (does this matter?)

But on the other hand:

  1. You have all the triggers in all the right places (I hope - anyone want to playtest?).

I suspect drawback 2 is why they dropped the cues. But by TR2 they seem to have figured it out. I think part of the secret is to SEEK first - the SEEK is non-blocking. Oddly, TR1 already uses that trick when looping ambience - it does a SEEK, and 4 seconds later does a PLAY. But I guess that's not sharp enough to get an urgent cue up.

Reply 187 of 301, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

there is also a prefetch read call. Maybe that one is used as well.

Water flows down the stream
How to ask questions the smart way!

Reply 188 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Turns out TR2 is using a totally different API - makes sense, as it's now a Windows app. Instead of MSCDEX, it's using Windows MCI. This deals with the blocking for them - they just don't set the MCI_WAIT flag on the MCI_PLAY call, and it does its stuff in the background.

I think I'm going to have to assume that the CD stalls aren't easily resolvable with MSCDEX - if they were, I imagine Core would have done so. So let's concentrate on getting Glidos to play the tracks from HDD.

Let's talk about interfacing to Glidos. Can we generalise the interface in case other games want similar patches? What can Glidos currently do? My thoughts are that a fully featured RedBook replacement API would offer:

int InitialiseGlidosAudio(const char *game_name);
// this tells Glidos which game this is, so it can look in an appropriate directory. Tells us whether or not audio support is enabled in the Glidos config (so the user has the option to fall back to normal behaviour).

int GetTrackLength(int track_num);
// in CD frame units (1/75 of a second). 0 if not available

int GetCurrentPlayPosition(int track_num);
// return current play position in frames, -1 for not playing.

int PlayTrack(int track_num, int flags);
// reports success; flags are
// bit 0: clear = stop any existing audio; set = play on top of any current audio (and ignore call if currently playing)
// bit 1: clear = play once, set = play continuously

void StopTrack(int track_num);
// track_num = 0 to stop all tracks.

If Glidos could offer all those calls, then it would be pretty easy to patch any RedBook CD-based program to use them, if available. If it detects that it's not running with Glidos, or that the tracks aren't available, it could default to normal CD behaviour.

Can Glidos actually play multiple sounds simultaneously? Also, can Glidos play WAV versions of the audio, if we want better than MP3?

And on another note, a correspondent on tombraiderforums confirms that the PlayStation has no general ambience - just the one ambient track (equal to the PC Peru one - slube's table has a slight error, but the MP3 tracks are right), which is triggered occasionally like any other cue.

Presumably we want to get the game to do both general ambience and cues, like TR2 on the PC (and PlayStation?). It might need a little bit of jiggery-pokery to ignore the ambient cues if the ambient loops are available. My thoughts are that the patched version should work like this:

If Glidos is not in use, or audio pack support is disabled:

  • Map cues (2,22..25,57..60) to CD tracks (2..10) like the original PC version
  • Map cues (13,26..56) to internal audio like the original PC version
  • Map cues (3,4,6..12,14..21) to CD tracks 11..27, and attempt to play them if available on the CD
  • Ignore cue 5.

This gives people the option of making a CD if they don't want to use Glidos. But they will suffer pauses when it plays; Glidos will work better. And I will have to muck around a bit to make it resume ambience afterwards. But I should be able to do it.

If Glidos is in use and has Audio Pack support enabled:

  • Never attempt Red Book audio.
  • Tell Glidos to play cues (2..4,6..60) (but not 5 by default). Remap numbers to match and extend slube's ordering.
  • If Glidos reports track unavailable for 57..60, treat this as an indication that the user doesn't want looping ambience, and enable playing of track 5.
  • If Glidos reports track unavailable for (13,26..56), fall back to internal audio. (Possibly useful if someone is still using the current audio pack without those sounds).
  • If Glidos reports track unavailable for any other track, don't worry.

We need to extend the audio track pack up to include PlayStation tracks 13,26..56. The remapping is ugly, but it makes sense to try and keep a single coherent ordering. I'd rather start counting from 2, but I guess we should stick with what we've already got.

It will go:
Audio pack index = Internal cue number (PS track number)
01 = cue 2 (title)
02..05 = cues 57..60 (PC ambient tracks)
06..09 = cues 22..25 (cut scenes)
10..26 = cues 3,4,6..12,14..21 (missing music cues)
27 = cue 5 (PlayStation ambience)
28 = cue 13 (secret chimes)
29..59 = cues 26..56 (tutorials, baddy dialogue)

Thus tracks 01..26 are the current audio pack ordering, and the ordering that the game will support if running off CD (where they will be tracks 02..27). That'll make people's life easier if they're using the Audio Pack to burn a CD.

I've separated the PlayStation ambience off for greater flexibility. Cues 5 and 59 are distinct in the code, so they probably should remain so in the track list.

How's all that sound?

Reply 189 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Should we move detailed discussion of Glidos API interfacing to the Glidos development forum, by the way? It's going to be a bit more intricate than the general principles, and it's probably only going to be between me and Paul. Or should we keep all discussion in this thread?

Reply 190 of 301, by Kaminari

User metadata
Rank Oldbie
Rank
Oldbie

Excellent findings, KMO. Hopefully it will ring the end of the texture triggers 😵

KMO wrote:

What's the deal with PlayStation ambient tracks? Does it really only have 1 ambience?

Yes, it's the one in the caves of Vilcabamba (which IIRC you hear nowhere else in the game, as far as the PS1 version is concerned). The other three (wind, grunts, heartbeats) are specific to the PC version, but interestingly enough, you can also hear them in TR2 (both PS1 and PC versions) in a remixed form -- for example, the industrial ambience track you hear at the offshore platform is a mix between the heartbeats in Atlantis and the croc sounds in The Cistern.

I know nothing about the PHD/TUB level formats, but I believe they can be opened and edited with the third-party TRe3D level editor, which is compatible with every classic episode from 1 to 5. Though I'm not sure if it supports audio triggers.

Reply 191 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

The caves ambience is the wind isn't it, on both the PC and PS1?

The other three being wet (Cistern/Mines), general random noises (drums beats/chimes - Egypt), and heartbeats (Atlantis).

I've also noted that my Unfinished Business CD (disc 2 of the pack) seems to have the wrong audio tracks on - tombub.exe seems to want to use the general and heartbeat ambience as usual for Egypt and Atlantis, and it expects them to be in the same place as TR1, but they're not in the right place on the TRUB CD. So you should play Unfinished Business with the TR1 CD in.

You can inspect the levels easily with Fexinspect, available here. Trigger points are shown in bright purple, and it can search for the "Soundtrack" ones.

Reply 192 of 301, by Kaminari

User metadata
Rank Oldbie
Rank
Oldbie
KMO wrote:

The caves ambience is the wind isn't it, on both the PC and PS1?[/url]

Nope, it's the one with atmospheric beats/chimes (track 05 on the PS1, French version). I'm pretty positive the wind is not in the console versions; on the PC, it plays in the folly and I think in Egypt. In TRUB, wind is definitely heard in Egypt and heartbeats in Atlantis.

KMO wrote:

I've also noted that my Unfinished Business CD (disc 2 of the pack) seems to have the wrong audio tracks on - tombub.exe seems to want to use the general and heartbeat ambience as usual for Egypt and Atlantis, and it expects them to be in the same place as TR1, but they're not in the right place on the TRUB CD. So you should play Unfinished Business with the TR1 CD in.

Could be because you're trying to play at the downloadable TRUB levels with the TRUB CD, which will not work correctly because, as you found out, the TRUB tracks are not mapped the same way as the TR1 tracks, and the downloadable levels specifically require the TR1 CD.

But playing at the TRUB CD levels with the TRUB CD exe and the TRUB CD in the tray works as intended -- under DOS only (Glidos doesn't seem to detect any track at all with this version).

Reply 193 of 301, by Glidos

User metadata
Rank l33t
Rank
l33t

We could just do something really simple. Just signal the cues with an unused int 2fh ah=15 command.

Reply 194 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie
Kaminari wrote:
KMO wrote:

The caves ambience is the wind isn't it, on both the PC and PS1?[/url]

Nope, it's the one with atmospheric beats/chimes (track 05 on the PS1, French version).

Ah, you're quite right. I've just gotten muddled somehow. Got my wind and beat/chime ambiences the wrong way round.

KMO wrote:

I've also noted that my Unfinished Business CD (disc 2 of the pack) seems to have the wrong audio tracks on

Could be because you're trying to play at the downloadable TRUB levels with the TRUB CD, which will not work correctly because, as you found out, the TRUB tracks are not mapped the same way as the TR1 tracks, and the downloadable levels specifically require the TR1 CD.

Ah, makes sense. I'd be using a downloaded tombub.exe for the dgVoodoo/Glidos support. Thanks!

Reply 195 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie
Glidos wrote:

We could just do something really simple. Just signal the cues with an unused int 2fh ah=15 command.

It's not totally simple though, if we're trying to deal with looping ambience too. We need to stop the ambience to play the cues, and then resume the ambience. Can Glidos deal with that automatically? Or do you just play all cues on top of the ambience? Possibly appropriate for some of them, but not all, I would have thought.

Reply 196 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

Well, it looks like I've got a first passable CD patch working.

It plays the usual PC tracks, and if the CD has extra tracks on, it plays them as the extra missing cues (it assumes they're in the same order as the current audio pack). Once it's played a cue, it goes back to the ambient.

I've managed to knock out most of the CD start-up delay - at least on my machine (XP, dgVoodoo, VDMSound) it now appears to be nearly as good as TR2. The problem seemed to be that it stopped the CD first then played the new track, rather than just switching immediately. It's now a fraction of a second, rather than 5 seconds

As ever, you get better all-round performance if you use a utility (like Nero DriveSpeed or Naiobrin CD-ROM Tool) to slow a fast drive down to 4x or 8x speed.

So, if you can intercept INTs, could the Glidos Audio Pack now work just by intercepting the CD-ROM calls? If I could avoid adding Glidos-specific code, it would be good. Patching the binary is really fiddly.

You'd need to make sure that the "Track Info" ioctl said there were extra tracks available (audio tracks 2-27). You'd also need to make sure the CD-ROM reported "busy" to the "QChannel Info" ioctl as long as a track was playing.

If we added the extra audio MP3s for baddies/tutorials/secrets to it as described above, I could probably further engineer it to use those extra tracks instead of internal audio, to boost the quality.

If any of the audio pack developers want a copy to test, PM me. I still don't want to distribute it publicly yet.

(Indeed, I'm still wary of distributing it at all - don't want Eidos coming down on me like a ton of bricks. Should probably have a word with the TRAI authors about what the deal is with any patches they're doing.)

Reply 197 of 301, by Glidos

User metadata
Rank l33t
Rank
l33t

Oh ok, that does make more sense the way you are suggesting, although a lot more work for me. Glidos already intercepts CD interrupts. I'll have a look at this when I get a chance.

Reply 198 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

I think I've basically finished the first version of the patch. I may just leave it at that for now. I'll consider it as a problem for Glidos to intercept the DOS CD calls to substitute MP3s. I'm not going to put any Glidos-specific code in. I've never had to program by entering hex machine code manually before, and it's not that fun. 😵 I'm also running out of space for new code.

Performance testing has been interesting. If I run my patch in "TR2 mode" with both ambience and cues, performance is good. But if I run it in "PlayStation mode", with no looping ambience, there's a few second freeze as a cue starts. Presumably that freeze is what made them abandon the cues and invent looping ambience. But ironically, the looping ambience makes the cues work well. 🤣 It's much faster to seek from ambience to a cue than spin the disc up for a cue. But maybe a 3rd-party CD utility could be used to tell the drive to never spin down.

One technical hitch has been that a nasty crash caused some disc corruption which took out the spreadsheet I was using to log all the patch changes, which means I'll have to redo some work before I make any more alterations. (Fortunately my IDA Pro disassembly database and patched binary are intact. 🙄 )

I'm speaking to people about how to get it distributed.

The only other significant thing I'd like to do would be to support CD/external audio for the other sounds that are built-in and horrible quality on the PC version, but CD-based on the PlayStation. That would also solve the only remaining bug, which remains from the original version - the ambience doesn't resume after internal audio. In practice this only affect the baddie dialogue (Pierre, Larson, Skater Boy, etc). Oddly enough, I never noticed that bug when playing through recently. I saw the flaw in the code first, and then went to double-check the game. 😮

To give me an incentive me to do this work, I'd need to get a copy of the tracks, as they're not in the Audio Pack. I think I'll cough up for a genuine PlayStation CD off eBay - I assume this has standard Red Book audio tracks? That'll give me better quality than MP3 too. 😉

Reply 199 of 301, by KMO

User metadata
Rank Newbie
Rank
Newbie

As an aside, I've only just twigged that the Paul Gardiner of Glidos is the Paul Gardiner of WSS. Kind of funny that we Acorn folk have had to travel over from our defunct platform to get games from another defunct platform working. 🤣

Albeit a game published by an Acorn company, using Acorn video file formats... Dammit, can't these PC people do anything themselves? 😏

Would have been much easier to patch TR1 if it was in ARM code. 😉