Aureal 3D (A3D) restoration/achieving better (3D) sound quality in Rayman 2 and Tonic Trouble (SE/Retail) | UPDATE! 6

Discuss tools to aid in the modification and running of Rayman games.

Moderators: English moderators, Modding and utilities team

Post Reply
deton24
Roméo Patti
Posts: 1010
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 7996

Aureal 3D (A3D) restoration/achieving better (3D) sound quality in Rayman 2 and Tonic Trouble (SE/Retail) | UPDATE! 6

Post by deton24 »

How to achieve better sound quality in Rayman 2 PC

Restoring Aureal 3D (A3D) by Alchemy
(or by DSOAL)
Or alternatively

Restoring just DirectSound by DSOAL,
and
overwriting \DLL sound libraries.

I. New instruction for (I think) crashless and sound disappear-free A3D in Rayman 2:

To restore Aureal 3D effects in Rayman 2:
1. Install Creative Alchemy
(for non-Creative cards check Alchemy for All tool
http://forums.thedarkmod.com/topic/1824 ... soundcard/)
2. Then install the game in the Alchemy (or make sure that Alchemy's dsound.dll and dsound.ini are present near Rayman2.exe in the game folder)

3. Copy these files into Rayman2\DLL folder
https://yadi.sk/d/qJbaZ20a3aSYLC
4. Then install A3D Live
http://www.worknd.ru/A3D-Live.exe (mirror: https://yadi.sk/d/6T0eYWdQ15Tx6A)
5. Most probably game will crash on A3D splash sound, so navigate to Windows folder and search for a3dsplhs.exe and delete it.

* A3D Live with Alchemy permanently crashes for me when new drivers from 2019 dedicated for Creative cards and W10 1803 build are installed. Previously I had PAX_SBXF_PCDRV_L11_2_30_0011_2017v1.00 drivers and it works with them on older W10 build. Be aware, that every new soundcard driver installation replaces a3d drivers (so also A3D Live installation which will need to be reinstalled).

* In some cases you must load the game very fast fast to avoid crash in main menu (especially when using dgVoodoo/DX6 since it loads slower than nGlide, but with nGlide it may happen as well).

* Using Alchemy on Creative cards you can also encounter a bug (probably on old 2017 drivers) that won't let you go through main menu and load the save even fast (Rayman2.exe crash in dsound.dll). The solution for it, is just to restart the computer. This particular bug exist when you cannot switch to Entertainment/Creation/Game Mode when you switched already once after system boot (Creative Audio Control Panel will return error that driver is in use and your new choice will be executed after restart).

6*. Update. For further changes in sound/spatialization quality download this ini and copy it to DLL folder. Open it, and edit line
GUID for WinNT=
Write there what you have written here described as "default device" - e.g.
GUID for WinNT= Speakers/Headphones (Realtek High Definition Audio) (rewrite your diactric letters if present as well!)
If the full device name there ends shortened with "..." go to Device Manager to get the full name.
The name can be generated to ini automatically with this: tool
The tool to work requires copying to DATA folder along with dsound.dll/ini, and then replacing all other generated info with provided config which we edited to preserve all my changes.
The new generated ini file not only relies just on changing Primary Sound Driver to your sound card name driver and changing buffer to 128, it contains also few previous valuable edits, but has some additional ones which can affect sound quality so be aware.
I used headphones, but stereo setting (default) in ini generates better spatialization effects than headphones setting.
Also please note that manual GUID for WinNT keeps resetting to "Primary Sound Driver", so keep it read only if changes made in this point sound better for you in comparison to ini from point 3. Long story short - spatialization in point 3 is more recognisable, but sounds are less present on a sound stage. It's up to you.

**7. For further changes in quality, alternatively get Donald Duck game sound libraries if it won't start causing unbearable crashes, but as it comes from my testing, it may cause crashes after level completion in comparison to the original Rayman 2 library:
https://yadi.sk/d/McvOBFGk3U6Tdz
[the same cheksums of WAVa1BVR.dll as patch hosted on fanpage.de and A3D patch (ttsndfix.zip) on torrent sites or achive.org under Fixes/Sound Fix/WAVa1BVR.dll].

If you have unbearable crashes of the game on startup, just uninstall A3D Live - go to Control Panel and uninstall it like other programs, but sound disapearing will be more frequent and will persist until you load next level from portal.

Even with A3D Live, you can encounter from time to time some sound disapearing, but it won't be so frequent and permament. Exception is Precipice Part 3, when you can encounter permament sound disapearing, but only till you get to the fight with ninja pirate - it doesn't require resetting level to restore SFX back.

Note
I tested also A3D Alchemy (A3D driver with IndirectSound wrapper hardcoded), but it somehow generates worse specialization effect, and also requires putting Creative Alchemy's dsoundl.dll to the game folder to fix massive sound issues.

DSOAL
Alternatively instead of Alchemy you can use universal DSOAL wrapper for better spatialization and in case of unbearable crashes using method above, but once it didn't work for me (with both A3D set in snd.cpa and with A3D Live installed). Later when I somehow managed to make it work, the game sound effects disappeared after some period of time even when A3D Live was installed (Alchemy with A3D Live seems to fix it).

DSOAL probably doesn't work on W10 build 1803 and up.

The guy here https://www.youtube.com/watch?v=3CvgxWhZhXU gives more details on DSOAL using this game, read the description; I just didn't use A2D linked there, it's not strictly necessary)


Snd_Cpa.ini file from step 3 (for archive purposes):

Code: Select all

[Options]
Sound_ON_OFF=ON
MPEG_ON_OFF=ON
WAV_ON_OFF=ON
ADPCM_ON_OFF=ON
CD_ON_OFF=OFF
SUPERVISATER_ON_OFF=ON
SXD_DIST_SATUR=8
SXD_DIST_FADE=30
FORCE_LOAD_BANKS=ON

[DLL_Test]
File0=WAVa1

[DLL_Sxd]
Unconditionnal=WAVa1
File0=WAVa1
[email protected]
File1=WAVMW
[email protected]
Default=WAVMW

[DLL_Adpcm]
Unconditionnal=None
File0=APMMX
[email protected]
Default=APMP5
[Directx3D Options]
GUID for WinNT=Primary Sound Driver
Disable A3D=No
Speakers Configuration=Stereo
Nb Voices=64
Attached WAVa1BVR.dll in Rayman 2 A3D ini.zip main link is just original A3D OpenSpace engine-exclusive Rayman 2's DLL; for better performance use this original R2 file when using my Reshade/SweetFX mod rather than Donald Duck/fanpage.de. Although all performance issues with this game are rather patched out by this Dege's patch. Once more, be aware about level ending crashes with this library.

II. For Tonic Trouble (Special Edition) A3D restoration:
Use the same steps as above, but in the end, use this ini:
https://yadi.sk/d/4-E0nyOsxLmTvw

For retail/final version see PCGamingWiki Tonic Trouble page if it doesn't work
https://www.pcgamingwiki.com/wiki/Tonic_Trouble

Without A3D Live it may happen that error about outdated A3D library error will be shown instead of splash. If sound won't disappear in the game permanently, you can ignore it, and press Alt+Tab to return to the game immediately after A3D splash screen to avoid game crash on startup if you will wait to long. If sound disappears, and error shows, try installing A3D Live again.

As an alternative for A3D Live for fix error on startup, and to avoid A3D issues, copy other a3d.dll driver from this DLL archive site (but none of a3d.dll libaries beside A3D Live will prevent from sound disapearing issue):
https://www.dll-files.com/a3d.dll.html (pick version 80.x 64 KB, it may fix startup splash error issue, and not cause the game to crash)
Copy it and overwrite in Windows\syswow64
(Safe mode or Take ownership tool (W10) executing might be necessary.
Sometimes you need to manually register the library in CMD to make it work:
http://www.ctimls.com/Support/KB/How%20 ... er_dll.htm

Tested on GOG version, nGlide, and W10 (dgVoodoo might be more problematic or even won't you go through main menu fast in some cases and configurations).


In case of unbearable crashes of the game, check out this method (DSOAL) listed in description of the video (it will generate sound disappearing issue, though):
https://www.youtube.com/watch?v=3CvgxWhZhXU


Notes
Synthesis couldn’t restore 44kHz support by the sound engine, despite the fact of achieving properly decoding 44kHz custom music – but played in 22kHz:
viewtopic.php?f=66&t=4782&p=1151131#p1147786
(but A3D/dsound wrapper/edited snd_cpa.ini generally helps achieving better output frequency in this game).

Even when Synthesis overwrote sound libraries from Donald Duck Quack Attack (2000) which actually helped kooz in Tonic Trouble to actually change engine’s sample rate:
viewtopic.php?f=66&t=5981&start=80#p1183649
enabling A3D also didn't solve the problem. Full 44kHz can't be played by the game even with 44kHz game music files. The game still lowers sample rate.


III. Instruction about enhancing sound quality without using A3D (e.g. if someone doesn't like 3D HRTF effect)

Introduction
What is the purpose of Alchemy/DSOAL dsound.dll file?
It’s restoring DirectSound, which had been deprecated since Windows Vista (by worsening overall sound quality in lots of older games), and served to hardware acceleration of sound cards. It was used by many sound engines in those times.

Sound engine of Rayman 2 has:
- 2D driver (default),
- Aureal3D (A3D),
- buggy DirectSound (no music; or I failed with ini editing or wrapper).

Alchemy/DSOAL is still required to make all of them work like intended in Win 9.x times, and enhancing overall sound quality, even in 2D mode.

In R2, in scenario without using A3D, I recommend using DSOAL as a tool of restoration DirectSound (IMHO – positioning in this library is better than in Alchemy, even when it is not using HRTF (like the version linked in the thread), though general sound quality is better in Alchemy for me).

For even better sound quality I also prefer overwriting game sound libraries to these used in Donald Duck Quack Attack. Then I recommend combining DSOAL with DD libraries for better results.

For A3D - Alchemy, A3D Live, and stock library (or DD if you don't notice performance difference - but I didn't test it entirely in matter of crashes, bugs, sound disappearing [though without A3D Live, DD library may behave a bit better]
For better spatialization with A3D - newest DSOAL (with sound diapering issues) downloaded from Nexus for Fallout with HRTF in ini activated (link given in description of the video linked at the top)

Instruction for old DSOAL and default (2D) sound renderer (without Alchemy and A3D):
1. Copy dsoal (dsound.dll and openal32.dll) to root game directory (\Rayman 2)
http://kcat.strangesoft.net/dsoal.zip
2. Overwrite sound libraries from Donald Duck in folder Rayman 2\DLL
https://yadi.sk/d/McvOBFGk3U6Tdz (R2 only)
3. Speaker configuration (2.0, 5.1) may have an influence on sound quality even for 2.0 only playback (look dsoal readme for reference).
4. Music may become quieter (if so, just adjust it in game options).
5. The game stops using injected dsound.dll/OpenAL32 after you press Alt+Tab (e.g. during using Reshade/SweetFX dll injector), the game completely stops working after alt tabbing – not all injected dll’s starts to work again afterwards). Be aware.

Note
In below site, uploaded sound library seems to be a bit newer than that from Donald Duck, but has the same checksums. You can find it here:
http://www.rayman-fanpage.de/rayman2/ra ... ysound.exe
Snd_Cpa.ini in the link https://yadi.sk/i/owh-f8QH3ZYDiB (I think it's for A3D, not 2D unlike just above).
It is another OpenSpace engine library responsible for enabling A3D along with Creative Alchemy (dsoal/indirect sound cause glitches in R2).
Claimed to fix sound disappearing issues, although it didn't when I tested. You can try out.
Main page: http://www.rayman-fanpage.de/rayman2/ra ... nglish.htm
Original library has the best performance during recording via Windows DVR when using Reshade/SweetFX (without tex mod performance patch yet).
Donald Duck maybe sounds a bit better, and that from the fanpage prevented from achieving 60 FPS while using fast scroll lock toggling hack without the patch (details in my R2 Reshade/SweetFX thread).
From time to time, unfortunately sound disappears in the middle of the level, or certain sound.
DD library and fanpage library can be a bit less vulnerable for the bug with disapearing sound.
Probably just A3D in this game wasn't exactly intended to work, and it's not refined.
And there are some sound distortions introduced, like change of pitch of some jingles during movement using A3D.

Another interesting bunch of information about sound drivers in the game:
https://tcrf.net/Proto:Rayman_2:_The_Gr ... und_Script

_______________________________________________________________________________________

down @Synthesis
Thanks a lot for your exhaustive answers in the case.
dsound.dll almost never exists nearby any game files, but it doesn't mean that they won't be used if present (it's easy to check it in Process Explorer.

The same goes for ddraw.dll in R2 (when DX6 is set), dinput, or d3d8, d3d9, dxgi (when nGlide reroots it to dxgi) used in other games.

I think that Rayman 2 itself, apart from Tonic Trouble, causes just specific problems with getting work 44kHz. dsoal only changes the way of mixing the sound, not really a sample rate. In dsoal readme we can also find that 5.1 configuration can force the library to use WASAPI (so speaker level in control panel wouldn't be visible). That's the last thing which comes to my mind about library itself which may change anything in this case.

More information about A3D wrapping here:
https://docs.google.com/document/d/1SyO ... Tpyhc/edit


@down
22kHz
Last edited by deton24 on Wed Oct 07, 2020 7:35 pm, edited 89 times in total.
WizardMinecraft
Électoon
Posts: 502
Joined: Wed Nov 15, 2017 4:53 am
Location: DEATH HILL
Tings: 7

Re: How to achieve better sound quality in Rayman 2 PC – restoring DirectSound by dsoal, and overwriting other sound DLL

Post by WizardMinecraft »

Wait, wasn't the PC version of R2's audio quality good enough?
Image
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: How to achieve better sound quality in Rayman 2 PC – restoring DirectSound by dsoal, and overwriting other sound DLL

Post by Synthesis »

Alright... I have to admit I didn't start taking the time to experiment what you suggested, because I noticed something wrong with my encoded 44k tracks.

Actually, the DC offset that was slowly building up over time was not at all due to the downsampling... in fact it's my compression tool itself.
Here's my thought process: if the DC offset buildup is caused by downsampling, I'll just mark my custom files as 22kHz in their header. That way, the game will play them twice slower, but they should be decoded just fine. Turns out I was wrong, the DC offset was still there.

Which means I must have gotten something wrong somewhere, my (IMA-ADPCM-based) APM decoder doesn't seem to behave quite like Rayman 2's.
Which also means I'll have to investigate further on that, and the thought of having to load up the code in a debugger (if I'm lucky enough to make it work at all), locate the piece of code that decodes an apm file, try to understand what the heck it does and figure out the actual instructions that generated the asm code, so I can eventually make up an algorithm that would do the reversed process... is really overwhelming, not gonna lie.

And as a matter of fact, my knowledge of ADPCM and its variations is pretty limited. I hit a brick wall with Ray3Get, and Ray2Get is merely a C implementation of some algorithm in pseudo-code I had read on MultimediaWiki without really trying to understand its ins and outs back then. I was fumbling around blindly, and eventually managed to make its output files sound pretty darn close to what could be heard in-game, but I never did proper comparisons (ie. phase-cancellation tests); and today I have become pretty confident that it isn't as accurate as it could be.

I think I understand how ADPCM works, but there are still a lot of details that elude me, particularly about the APM format. Here's what I inferred from what I observed in the APM file header:

Code: Select all

Offset | Size    | Type   | Information
-------|---------|--------|----------------------------------------------------
0x0    | 2       | short  | Format tag (0x0020 for Ubisoft ADPCM)
0x2    | 2       | short  | Channel count
0x4    | 4       | int    | Sample rate
0x8    | 4       | int    | Byte rate, as if it were uncompressed 16-bit PCM
0xC    | 2       | short  | Block alignment (usually = 1)
0xE    | 2       | short  | Bits per sample
0x10   | 4       | int    | Size of the next APM description chunk (including
       |         |        | this value) ; should be 0x50 (80 in decimal)
0x14   | 4       | char*4 | APM signature/version number? (default value is
       |         |        | "vs12")
0x18   | 4       | int    | Total file size, in bytes
0x1C   | 4       | int    | Audio data length, in nibbles
0x20   | 4       | ?      | ?? (four consecutive 0xFF bytes)
0x24   | 4       | int    | ?? (four consecutive null bytes)
0x28   | 4       | int    | Odd/even nibble indicator (*real-time, see below)
0x2C   | 12*chan | -      | For each channel, last to first:
       |         |        |     (eg. stereo files stores right channel first)
       |   4     | int    | Initial PCM value (with 16-bit sign extension)
       |   4     | int    | Initial ADPCM step index
       |   4     | byte*4 | Beginning of the APM data (wtf?) (**see below)
0x38   |         |        | and so on...
...    | ?       | -      | Null bytes for padding
0x60   | 4       | char*4 | Data chunk header ("DATA")
0x64   | ?       | char*? | APM audio data

The APM audio data is stored as follows: the channels are interleaved, and
since each sample takes only 4 bytes, they are stored in pairs. For example,
the beginning of a stereo file would look like
    0xAB 0xCD 0xEF 0xGH ...
A: left channel, 1st APM sample
B: left channel, 2nd sample
C: right channel, 1st sample
D: right channel, 2nd sample
E: left channel, 3rd sample
F: left channel, 4th sample
G: right channel, 3rd sample
H: right channel, 4th sample, and so on.

If the total number of sample is odd, then for each channel, the last byte will
be filled halfway. The least significant bits are left to 0. For example, the
end of a stereo file would look like
    ... 0xY0 0xZ0
with Y and Z being the last samples of respectively the left and right
channels.

(*) At address 0x28, there's a 4-bit reserved value which should be equal to 0.
This is because the header is copied in memory while the game runs, and some
areas of the header are actually used (but the file itself is untouched).
This particular value is an even/odd indicator: since ADPCM is 4-bit, there are
two samples per byte; this value is used in the decoding algorithm to indicate
if it is currently processing the odd (most significant) or even (least
significant) nibble.

(**) For some reason, the beginning of the APM chunk is stored in the header in
an unusual way: the 4-byte value corresponds to the first four bytes of the
(multi-channel interleaved) APM data, starting from the byte corresponding to
the channel. Say we have a stereo file. In the header appears the following
sequence:
0x2C   | 4       | int    | Initial PCM value for right channel
0x30   | 4       | int    | Initial ADPCM step index for right channel
0x34   | 4       | byte*4 | Bytes 2 through 5 of the APM data chunk     <---
0x38   | 4       | int    | Initial PCM value for left channel
0x3C   | 4       | int    | Initial ADPCM step index for left channel
0x40   | 4       | byte*4 | First four bytes of APM data                <---
0x44   | 28      | -      | Null bytes for padding

Note: there are 52 bytes for storing the initial ADPCM variables, which means
that the APM format could support up to 4 channels, leaving 4 null bytes for
padding.
There's still a lot of data which I don't know what it is used for. Furthermore, the initial ADPCM index values are just blind guesses, and I'm not sure if the channels are actually in reverse order. I have no idea why it would be the case. Let alone why the beginning of the audio data would be copied in the header.

Edit: just thought of another reason why my tool would produce inaccurate files: maybe the game uses a slightly different ADPCM step table, which could result in decoded PCM values being slightly off.
Edit 2: I just compared, my ADPCM table and the one in Rayman 2's DLL (APMmxBVR.dll) are identical. Other hypothesis: some values in the APM header aren't exactly what I think they are, and I got the initial values wrong.
Edit 3: Oooooh! I just stumbled upon OpenRayman, which is an open source reimplementation of the Rayman 2 engine. It's hosted on GitHub, and the code provides some more info about the APM file format! I just updated my current description above.
Edit 4: Finally! I found what the error was in my own decoder. There's a variable which, for some reason, has its least significant 3 bits masked in the decoding process, while those bits are left in their original states in the standard ADPCM algorithm.
Last edited by Synthesis on Sun Apr 15, 2018 8:00 pm, edited 4 times in total.
Harpic fraîcheur
Électoon
Posts: 26126
Joined: Sat Jan 18, 2014 7:57 pm
Tings: 0

Re: How to achieve better sound quality in Rayman 2 PC – restoring DirectSound by dsoal, and overwriting other sound DLL

Post by Harpic fraîcheur »

Hello détron24! :)
Une nouvelle vague de fraîcheur, Harpic fraîcheur verte ! 8)
ImageImage
boomboleros7 wrote:Harpic est imbattable. Harpic est légendaire. Harpic est divin.
Sanhedrin wrote:“Il est autorisé d’avoir des rapports sexuels avec une fille de trois ans et un jour »
Synthesis
Barbara
Posts: 47
Joined: Fri Jan 02, 2009 7:48 pm
Location: France
Tings: 10235

Re: How to achieve better sound quality in Rayman 2 PC – restoring DirectSound by dsoal, and overwriting other sound DLL

Post by Synthesis »

Welp... sounds like bad news. I followed your steps and didn't manage to set the game's sample rate to 44100Hz. Even worse, I noticed that there's no anti-aliasing before downsampling, so any 44100Hz audio file will have the upper half of its spectrum folded back into the lower, audible, half.

Here's what I did:
1. Downloaded the zip files you provided for the dsoal library and the DLL folder.
2. Copied dsound.dll and openal32.dll to the game root directory, next to the Rayman2 executable. Surprisingly there didn't seem to be any already existing file called dsound.dll. So I assume the game wouldn't do any DirectSound call in the first place, which would make dsoal essentially useless in our case.
3. Renamed the DLL directory to prev_DLL (in case of screw-ups, so I still have a backup copy).
4. Copied the DLL folder you provided.

I tried with both the Rayman2 and Quack Attack "Snd_cpa.ini" and "GliVd1vf.dll" files. In both cases, the audio engine still would run at 22050 Hz with aliasing.

I must have missed something...?

But in other (related) news... something really cool is about to be released.

Edit: Interesting... the game engine doesn't seem to support mono APM files. I tried that by replacing MM01.apm (the beginning of the Hall of Doors music, which happens to be used for the main menu) with outro1.apm (the only mono file provided with the game); it just isn't played at all. Good to know.
deton24
Roméo Patti
Posts: 1010
Joined: Fri Jan 14, 2011 1:22 am
Location: Poland
Tings: 7996

Re: Aureal 3D (A3D) restoration / achieving better sound quality in Rayman 2 | UPDATE!

Post by deton24 »

Update. I managed to set Aureal 3D (A3D) in ini:

To restore Aureal 3D in the game:

1. install Creative Alchemy,
2. install the game in the Alchemy
(for non-Creative cards see http://forums.thedarkmod.com/topic/1824 ... soundcard/)
3. copy these files into Rayman2\DLL folder
https://yadi.sk/d/qJbaZ20a3aSYLC
4. Then install A3D Live
http://www.worknd.ru/A3D-Live.exe
5. Press alt+tab to return to the game immediately after A3D splash screen to avoid game crash on startup.
6. If game will crash on splash sound, navigate to Windows folder and search for a3dsplhs.exe and delete it.

If all above only gives you crashes, look for this video description (alternative method):
https://www.youtube.com/watch?v=3CvgxWhZhXU



Rayman 2 with 3D sound is really cool... :>

Looks like RibShark knows how to enable A3D in Tonic Trouble.
edit.
Use the same steps like above, but in the end, use this ini:
https://yadi.sk/d/4-E0nyOsxLmTvw
Last edited by deton24 on Sun Sep 08, 2019 8:28 pm, edited 5 times in total.
Harpic fraîcheur
Électoon
Posts: 26126
Joined: Sat Jan 18, 2014 7:57 pm
Tings: 0

Re: Aureal 3D (A3D) restoration / achieving better sound quality in Rayman 2 | UPDATE!

Post by Harpic fraîcheur »

Wow, it's been so long détron24! It's nice to see you're still up to bring the best shit to us. :)
Une nouvelle vague de fraîcheur, Harpic fraîcheur verte ! 8)
ImageImage
boomboleros7 wrote:Harpic est imbattable. Harpic est légendaire. Harpic est divin.
Sanhedrin wrote:“Il est autorisé d’avoir des rapports sexuels avec une fille de trois ans et un jour »
Post Reply