Skip to content

Audio modes demystified

sp2xdev edited this page Apr 28, 2024 · 57 revisions

Audio output method from games supported by spice

DirectSound (DSound)

DDR, popn, etc, including many older versions of games (IIDX24 and below).

Highest latency, but compatible with basically everything. Allows for multiple audio streams. Audio can be captured.

WASAPI shared mode

Used by some games.

High latency, compatible with most devices. Allows for multiple streams. Audio can be captured.

You may need to set "Default Format" to the correct sample rate in Windows audio settings before starting the game.

WASAPI exclusive mode

IIDX25-30 (LDJ), SDVX (nemsys), Gitadora, etc. Used by most newer games. Only allows one audio stream at a time (i.e., the game takes over all of audio)

Some games using WASAPI exclusive mode can be patched (DLL hex edit) to use shared mode instead.

Low latency, requires that audio device supports exclusive mode at the correct sample rate. Needs "Allow applications to take exclusive control" setting enabled in Windows audio settings, on by default.

Audio cannot be directly captured by another application, so a workaround is needed to record or share the audio stream.

ASIO

Lowest latency. Requires special audio device to support ASIO, at specific format (e.g., https://iidx.org/infinitas_asio for IIDX, which needs Int24LSB), as the game directly communicates with the audio card, skipping Windows audio layers.

Audio cannot be directly captured by another application, so a workaround is needed to record or share the audio stream.

There are also software ASIO endpoints (e.g., FlexASIO) that will receive ASIO streams and convert them to other modes, such as exclusive or shared WASAPI. Keep in mind that this is just a software conversion, so you pay latency cost, which is not desirable.

So far, only IIDX and SDVX support ASIO. The games look for a specific sound card, Asus Xonar AE. If you purchase this card and install it, it will just work. Alternatively, you can use options in Spice (-iidxasio and -sp2x-sdvxasio) to override this to use your own ASIO device.

Game-specific information

IIDX

IIDX 24 and below

  • Uses DirectSound.
  • See Hypersonik DLL hook (linked below) to output audio via exclusive WASAPI.

IIDX 25-26

  • Uses exclusive WASAPI.
  • See Backend Conversion section below if you want to output as shared mode WASAPI.

IIDX 27-30

  • By default, Spice will tell the game to use exclusive WASAPI.
    • This is done by Spice automatically setting SOUND_OUTPUT_DEVICE environment variable to wasapi.
  • Patches exist to use shared mode WASAPI.
  • To use native ASIO, use IIDX Sound Output Device (-iidxsounddevice) and IIDX ASIO Driver (-iidxasio).

IIDX 31

  • All DLL types use ASIO.
  • Patches exist to use exclusive WASAPI or shared WASAPI.
  • IIDX ASIO Driver (-iidxasio) option no longer works, due to the game ignoring SOUND_OUTPUT_DEVICE environment variable
    • (note: very early versions of 31 are special and -iidxasio may continue to work)
    • You will see this message in the log:
W:iidx: This game does not accept SOUND_OUTPUT_DEVICE environment variable; it will be ignored
W:iidx: Make sure you applied appropriate patches to use the correct sound device (ASIO or WASAPI)

SDVX

SDVX 1-4

Uses DirectSound.

SDVX VW

Uses exclusive WASAPI. Patches exist to use shared mode WASAPI.

SDVX EG

  • The game will look for ASIO device first (use SDVX ASIO Driver (-sp2x-sdvxasio) to override device). It seems to require 8 channels, 44.1kHz and 24-bit depth. If you only have 2 audio channels for ASIO, initialization fails. If bit-depth is 16 bit, you can garbled audio. There may be other requirements for ASIO that are not clearly known.
  • If ASIO initialization fails, it automatically switches over to exclusive WASAPI
  • Patches exist to use shared mode WASAPI
  • (all of this applies to both KFC and UFC modes)

Gitadora

Newer games will use exclusive WASAPI.

For Guitar, you'll probably want to use cab type 3 (white cab, single guitar) so that you get guitar sounds from both speakers. In other cab types, they have two guitars, so you only hear guitar sounds from one speaker.

Popn

All versions of Popn use DirectSound.

Spice audio hook

Audio latency reduction for DSound and Shared Mode WASAPI

Use Low Latency Shared Audio option (-sp2x-lowlatencysharedaudio) to reduce latency. If your audio device supports it, it can lower the round-trip latency from a typical 10ms down to 2-3ms, which is enough for most people to notice.

Requires Windows 10. Works for DirectSound and shared mode WASAPI, but does not work for exclusive WASAPI or ASIO.

Enable the option and check log.txt. It'll look something like this

Good scenario (reduction, 10ms -> 2.67ms) - using Windows inbox driver on Realtek audio device

I:audio::lowlatency: low latency shared mode audio client initialized successfully
I:audio::lowlatency: this is NOT used to output sound, but rather to reduce buffer sizes when the game requests an audio client at a later point
I:audio::lowlatency: ... sample rate         : 48000 Hz
I:audio::lowlatency: ... min buffer size     : 128 samples (2.6666667 ms)
I:audio::lowlatency: ... max buffer size     : 480 samples (10 ms)
I:audio::lowlatency: ... default buffer size : 480 samples (10 ms)
I:audio::lowlatency: ... Windows will use minimum buffer size (instead of default) for shared mode audio clients from now on

Bad scenario (no reduction, stays at 10ms) - using Realtek drivers on the same device as above

I:audio::lowlatency: low latency shared mode audio client initialized successfully
I:audio::lowlatency: this is NOT used to output sound, but rather to reduce buffer sizes when the game requests an audio client at a later point
I:audio::lowlatency: ... sample rate         : 48000 Hz
I:audio::lowlatency: ... min buffer size     : 480 samples (10 ms)
I:audio::lowlatency: ... max buffer size     : 480 samples (10 ms)
I:audio::lowlatency: ... default buffer size : 480 samples (10 ms)
I:audio::lowlatency: ... Windows will use minimum buffer size (instead of default) for shared mode audio clients from now on

For best results, use Windows inbox audio driver.

Basically, it's the same as running REAL, using Windows audio APIs to accomplish the same thing.

Backend conversion

Spice has an audio hook that can accept WASAPI exclusive mode as input, and output as ASIO.

Configuring Spice to convert Exclusive WASAPI to ASIO backend, use the following:

  • -audiobackend asio
  • -asiodriverid <index> to change your ASIO output device used by the audio hook. For most people with just one ASIO device, index should be 0. If you have multiple ASIO devices, open up log.txt and look for a section that looks like the following
audio::asio: initializing ASIO thread
audio::asio: Driver 0
audio::asio: ... Name : FlexASIO
audio::asio: ... Path : C:\Program Files\FlexASIO\x64\FlexASIO.dll
audio::asio: Driver 1
audio::asio: ... Name : Realtek ASIO
audio::asio: ... Path : c:\windows\system32\rthdasio64.dll

in the example above, the user has two ASIO devices. If they want to use Realtek ASIO, then -asiodriverid 1 should be used.

For example, this technique can be used with IIDX 25-26 to output shared WASAPI audio. The game would output as exclusive WASAPI, spice converts that to ASIO and pipes to FlexASIO, and FlexASIO converts to shared WASAPI. (Consult FlexASIO documentation on how to accomplish this).

Whenever possible, you should use the native audio output from the game, instead of going through the Spice audio backend conversion, as it will add a bit of latency.

Volume change prevention

Some games like to set the volume of your default audio device to 100% as it launches, which is very fun! Spice2x now has hooks to prevent this from happening, which means you might not need to patch your DLLs to do the same. This is enabled by default.

Spice only hooks some of Windows volume APIs, which should cover most games. For most games, there are also patches that can be applied.

Other audio hooks and hacks

REAL to minimize DSound and shared mode WASAPI latency - works well for popn. No longer needed as the feature has been integrated into spice2x as of 2023-11-23 (see Audio latency reduction for DSound and Shared Mode WASAPI section above)

hypersonik for hooking older IIDX versions (IIDX24 and below) to use WASAPI instead of DSound. Can be used if -sp2x-lowlatencysharedaudio is not effective with your audio device.

win-capture-audio OBS plugin for capturing audio from specific application