OpenTomb icon indicating copy to clipboard operation
OpenTomb copied to clipboard

sndfile and CDAUDIO.WAD support needs backporting

Open Lwmte opened this issue 8 years ago • 12 comments

Also, gone with "refactored old master".

Lwmte avatar Jun 27 '16 06:06 Lwmte

wad audio file loading had been implemented, only audio scripts should be updated / tuned

TeslaRus avatar Sep 03 '16 13:09 TeslaRus

Script_GetSoundtrack doesn't allow to omit the file name in every track. And duplicating it a hundred times serve no purpose. So, it might require to modify Lua support code as well.

vvs- avatar Sep 03 '16 19:09 vvs-

for wad file using script should return only CDAUDIO.WAD and type = WAD, track number are used iside audio module (by track number audio module access to wad header, takes offset to the track and loads track)

TeslaRus avatar Sep 03 '16 21:09 TeslaRus

And this doesn't work because Script_GetSoundtrack concatenates the track path and file names which are stored in an array. You'd need to put the same file name into each array entry for this to work. And it requires the file names to be present.

EDIT: Ok, I was mistaken. It's actually getTrackInfo which concatenates these names.

This will do the trick:

diff --git a/scripts/audio/soundtrack.lua b/scripts/audio/soundtrack.lua
index 9972f70..1b409b0 100644
--- a/scripts/audio/soundtrack.lua
+++ b/scripts/audio/soundtrack.lua
@@ -728,8 +728,9 @@ function getTrackInfo(ver, id)
         else
             tbl  = tr3_old_track_tbl;    -- TR_III (OLD)
         end
-        path   = "data/tr3/audio/";
-        method = OGG;
+        path   = "data/tr3/audio/cdaudio.wad";
+        method = WAD;
+       return path, tbl[id].mode, method;
     elseif(ver < 8) then                -- TR_IV, TR_IV_DEMO
         tbl    = tr4_track_tbl;
         path   = "data/tr4/audio/";

vvs- avatar Sep 04 '16 08:09 vvs-

Just not to forget: no any WAD file support exists in current OpenTomb master, nor any support for MS-ADPCM WAV files. There is no any streaming routines except OGG streaming, which currently doesn't work as it should (as it loads WHOLE ogg files into memory on level start).

Solution 1: Brace ourselves and integrate sndfile once again. Solution 2: Find working code for MS-ADPCM streaming somewhere.

Lwmte avatar Oct 10 '16 01:10 Lwmte

What do you mean? The above Lua script patch actually makes it possible to use WAD file for TR3.

Also, similar patch is needed for Lua scripts to use WAV files for TR4/5. Only file names extensions and method need to be changed. I'm able to successfully use such a patch locally.

It's true that there is no streaming support yet. All files are preloaded at the level start.

vvs- avatar Oct 10 '16 11:10 vvs-

I just mean that preloading soundtrack files on level start instead of streaming couldn't in any way count as "support". Sorry. It's absolutely ridiculous and wrong way to work with long audio files.

Lwmte avatar Nov 16 '16 21:11 Lwmte

@Lwmte Seems that streaming is working now. Should this be closed?

vvs- avatar Oct 08 '17 19:10 vvs-

This time audio streaming works itself, but it preload ALL audio data to the buffer (it is bad); Only one streaming works correctly: RPL video playing (streaming system); May be it will be more correct to create task for real streaming system (I though about moving all audio streaming format support to rpl code part)

TeslaRus avatar Oct 09 '17 05:10 TeslaRus

BTW, streams can't be stopped now except when Lara dies. This means that several streams can now be played simultaneously which wasn't intended.

vvs- avatar Oct 09 '17 08:10 vvs-

Streams stopped by next logic [type filtered]: only one type==background or type==chat may be played, type==one_shot do not stop other one_shot streams Stream types was introduced by Lwmte

TeslaRus avatar Oct 09 '17 09:10 TeslaRus

Yes. But ONCE streams were stopped before recent audio refactoring. And now it's possible to play several ONCE streams at once. This sounds awful and wasn't intended in original Core levels. This isn't obvious in PC version because it just lacks anything besides LOOP and CHAT streams. But in OT it's now perfectly possible to do that, e.g. in Caves.

EDIT: It's impossible to play the same ONCE stream twice, but nothing prevents from playing different streams.

vvs- avatar Oct 09 '17 10:10 vvs-