mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
6bcadccf09
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change This new option, `-wasapishared`, detects when the game opens WASAPI Exclusive stream and forcibly opens a shared mode stream instead on the real device. #### Benefits of this: 1. No need for `force wasapi shared` patches 2. No need to change sample rate of audio devices before starting up games 3. Adds ability to boot in shared mode even for games that do not have shared wasapi changes (old GITADORA, popn HC) As a result, this option is strictly better than `shared wasapi` patches available for many games. #### Downsides: 1. OS resampling will add a small latency, but not big enough to be noticeable. 2. Using shared mode instead of exclusive mode adds latency, of course. (If you cared about latency, you would use the low latency option, or use exclusive or asio) Basically it's the "make things work" button for audio that should work for almost all games that we support. The option has no effect if the game opens in shared mode. ## Testing SDVX7 - ok GITADORA GW - ok popn HC - ok IIDX - ok
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include <windows.h>
|
|
#include <mmreg.h>
|
|
#ifndef _MSC_VER
|
|
#include <ks.h>
|
|
#include <ksmedia.h>
|
|
#endif
|
|
|
|
namespace hooks::audio {
|
|
enum class Backend {
|
|
Asio,
|
|
WaveOut,
|
|
};
|
|
|
|
// surround-to-stereo downmix algorithm
|
|
enum class DownmixAlgorithm {
|
|
FrontOnly, // keep only the front channels
|
|
RearOnly, // keep only the rear/back channels
|
|
SideOnly, // keep only the side channels
|
|
AC4, // AC-4 stereo downmix coefficients (ETSI TS 103 190-1)
|
|
Normalize, // all channels equally loud, LFE dropped
|
|
};
|
|
|
|
extern bool ENABLED;
|
|
extern bool VOLUME_HOOK_ENABLED;
|
|
extern std::optional<DownmixAlgorithm> DOWNMIX_ALGORITHM;
|
|
extern float VOLUME_BOOST;
|
|
|
|
// target sample rate the hooked output is resampled to, if set
|
|
extern std::optional<uint32_t> RESAMPLE_RATE;
|
|
|
|
// minimum WASAPI exclusive buffer duration (milliseconds), if set. enlarges the device buffer
|
|
// to avoid underrun crackle on endpoints that cannot service a tiny buffer in time.
|
|
extern std::optional<uint32_t> EXCLUSIVE_BUFFER_MS;
|
|
|
|
// when true, WASAPI compatibility mode is active: exclusive-mode streams are redirected to
|
|
// shared mode. the Windows audio engine performs any required sample-rate / channel / bit-depth
|
|
// conversion, so the game's format is passed through unchanged and other applications can play
|
|
// audio simultaneously.
|
|
extern bool WASAPI_COMPATIBILITY_MODE;
|
|
extern bool USE_DUMMY;
|
|
extern WAVEFORMATEXTENSIBLE FORMAT;
|
|
extern std::optional<Backend> BACKEND;
|
|
|
|
// when true, a synthetic "Realtek" render endpoint is injected into device enumeration that
|
|
// discards all audio. used by gitadora arena, whose device search crashes when no render
|
|
// endpoint reports a "Realtek" friendly name.
|
|
extern bool INJECT_FAKE_REALTEK_AUDIO;
|
|
extern std::optional<size_t> ASIO_DRIVER_ID;
|
|
extern std::string ASIO_DRIVER_NAME;
|
|
extern bool ASIO_FORCE_UNLOAD_ON_STOP;
|
|
extern bool LOW_LATENCY_SHARED_WASAPI;
|
|
|
|
void init();
|
|
void stop();
|
|
|
|
inline std::optional<Backend> name_to_backend(const char *value) {
|
|
if (_stricmp(value, "asio") == 0) {
|
|
return Backend::Asio;
|
|
} else if (_stricmp(value, "waveout") == 0) {
|
|
return Backend::WaveOut;
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
}
|