mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-04 07:40:42 -07:00
audio: WASAPI exclusive resampling, buffer size increase options (#727)
## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change Resampler: Implement resampler for exclusive mode streams, as we are seeing more and more devices - not just laptops but onboard audio devices - that only support 48khz and not 44.1khz. Should work with volume boost (gain calculated inside resample) and also downmixer (hands off intermediate scratch buffers). Buffer size increase: By default many of these games request a tiny buffer when in shared mode (TDJ uses 3ms). On some audio setup this results in crackling due to underflow. Add an option to forcibly increase the buffer size. ## Testing With resampler set to 48kHz and buffer set to 20ms I can reliably boot and play IIDX on my display port monitor's speakers; previously this wasn't possible. IIDX is event-driven. Tested SDVX7 as well at 48kHz, which opens timer-driven streams.
This commit is contained in:
@@ -1106,6 +1106,18 @@ int main_implementation(int argc, char *argv[]) {
|
||||
hooks::audio::VOLUME_BOOST = (float) std::pow(10.0, decibels / 20.0);
|
||||
}
|
||||
}
|
||||
if (options[launcher::Options::AudioResample].is_active()) {
|
||||
const uint32_t rate = options[launcher::Options::AudioResample].value_uint32();
|
||||
if (rate > 0) {
|
||||
hooks::audio::RESAMPLE_RATE = rate;
|
||||
}
|
||||
}
|
||||
if (options[launcher::Options::AudioExclusiveBuffer].is_active()) {
|
||||
const uint32_t ms = options[launcher::Options::AudioExclusiveBuffer].value_uint32();
|
||||
if (ms > 0) {
|
||||
hooks::audio::EXCLUSIVE_BUFFER_MS = ms;
|
||||
}
|
||||
}
|
||||
|
||||
if (options[launcher::Options::AudioBackend].is_active()) {
|
||||
auto &name = options[launcher::Options::AudioBackend].value_text();
|
||||
|
||||
@@ -1984,6 +1984,37 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = {
|
||||
{"30", "+30 dB"},
|
||||
},
|
||||
},
|
||||
{
|
||||
// AudioResample
|
||||
.title = "WASAPI Exclusive Mode Resampling",
|
||||
.name = "resample",
|
||||
.desc = "Resamples the hooked audio output to a fixed sample rate before it reaches the "
|
||||
"device. Useful when a game requests a sample rate the device cannot output in "
|
||||
"exclusive mode (e.g. the game wants 44100 Hz but the device is locked to 48000 Hz).\n\n"
|
||||
"Select the TARGET sample rate (one that your audio card supports).\n\n"
|
||||
"Will result in couple milliseconds of latency and increased CPU usage when active.",
|
||||
.type = OptionType::Enum,
|
||||
.category = "Audio",
|
||||
.elements = {
|
||||
{"44100", "44.1 kHz"},
|
||||
{"48000", "48 kHz"},
|
||||
{"88200", "88.2 kHz"},
|
||||
{"96000", "96 kHz"},
|
||||
{"176400", "176.4 kHz"},
|
||||
{"192000", "192 kHz"},
|
||||
},
|
||||
},
|
||||
{
|
||||
// AudioExclusiveBuffer
|
||||
.title = "WASAPI Exclusive Buffer Size",
|
||||
.name = "exclusivebuffer",
|
||||
.desc = "Enlarges the WASAPI exclusive-mode device buffer to the specified duration in milliseconds.\n\n"
|
||||
"Try setting this to 10 or even 20 if you hear crackling or glitches "
|
||||
"(at the cost of slightly increased latency).",
|
||||
.type = OptionType::Integer,
|
||||
.setting_name = "16",
|
||||
.category = "Audio",
|
||||
},
|
||||
{
|
||||
// DelayBy5Seconds
|
||||
.title = "Delay by 5 Seconds (DEPRECATED - use -sleepduration instead)",
|
||||
|
||||
@@ -201,6 +201,8 @@ namespace launcher {
|
||||
AudioDummy,
|
||||
DownmixAudioToStereo,
|
||||
VolumeBoost,
|
||||
AudioResample,
|
||||
AudioExclusiveBuffer,
|
||||
DelayBy5Seconds,
|
||||
spice2x_DelayByNSeconds,
|
||||
LoadStubs,
|
||||
|
||||
Reference in New Issue
Block a user