bsnes/higan/target-bsnes/program/audio.cpp

79 lines
2.5 KiB
C++
Raw Normal View History

auto Program::updateAudioDriver() -> void {
audio = Audio::create(settings["Audio/Driver"].text());
audio->setContext(presentation->viewport.handle());
audio->setChannels(2);
updateAudioExclusive();
updateAudioDevice();
updateAudioBlocking();
settingsWindow->advanced.updateAudioDriver();
if(!audio->ready()) {
MessageDialog({
"Error: failed to initialize [", settings["Audio/Driver"].text(), "] audio driver."
}).error();
settings["Audio/Driver"].setValue("None");
return updateAudioDriver();
}
}
auto Program::updateAudioExclusive() -> void {
if(!audio) return;
audio->clear();
audio->setExclusive(settings["Audio/Exclusive"].boolean());
updateAudioFrequency();
updateAudioLatency();
}
auto Program::updateAudioDevice() -> void {
if(!audio) return;
audio->clear();
if(!audio->availableDevices().find(settings["Audio/Device"].text())) {
settings["Audio/Device"].setValue(audio->availableDevices()(0));
}
audio->setDevice(settings["Audio/Device"].text());
updateAudioFrequency();
updateAudioLatency();
settingsWindow->audio.updateDevice();
}
auto Program::updateAudioBlocking() -> void {
audio->setBlocking(settings["Audio/Blocking"].boolean());
}
auto Program::updateAudioFrequency() -> void {
if(!audio) return;
audio->clear();
if(!audio->availableFrequencies().find(settings["Audio/Frequency"].real())) {
settings["Audio/Frequency"].setValue(audio->availableFrequencies()(0));
}
audio->setFrequency(settings["Audio/Frequency"].real());
Update to v106r44 release. byuu says: Changelog: - hiro/Windows: use `WS_CLIPSIBLINGS` on Label to prevent resize drawing issues - bsnes: correct viewport resizing - bsnes: speed up window resizing a little bit - bsnes: fix the cheat editor list enable checkbox - bsnes: fix the state manager filename display in game ROM mode - bsnes: fix the state manager save/rename/remove functionality in game ROM mode - bsnes: correct path searching for IPS and BPS patches in game ROM mode - bsnes: patch BS-X town cartridge to disable play limits - bsnes: do not load (program,data,expansion).(rom,flash) from disk in game pak mode - this is required to support soft-patching and ROM hacks - bsnes: added speed mode selection (50%, 75%, 100%, 150%, 200%); maintains proper pitch - bsnes: added icons to the menubar - this is particularly useful to tell game ROMs from game paks in the load recent game menu - bsnes: added emblem at bottom left of status bar to indicate if a game is verified or not - verified means it is in the icarus verified game dump database - the verified diamond is orange; the unverified diamond is blue - bsnes: added an option (which defaults to off) to warn when loading unverified games - working around a bug in GTK, I have to use the uglier MessageWindow instead of MessageDialog - bsnes: added (non-functional) link to <https://doc.byuu.org/bsnes/> to the help menu - bsnes: added GUI setting to toggle memory auto-save feature - bsnes: added GUI setting to toggle capturing a backup save state when closing the emulator - bsnes: made auto-saving states on exit an option - bsnes: added an option to auto-load the auto-saved state on load - basically, the two combined implements auto-resume - bsnes: when firmware is missing, offer to take the user to the online help documentation - bsnes: added fast PPU option to disable the sprite limit - increase from 32 items/line + 34 tiles/line to 128 items/line + 128 tiles/line - technically, 1024 tiles/line are possible with 128 sprites at 64-width - but this is just a waste of cache locality and worst-case performance; it'll never happen Errata: - hiro/Windows: fallthrough on Canvas `WM_ERASEBKGND` to prevent startup flicker
2018-06-28 06:28:27 +00:00
double frequency = settings["Audio/Frequency"].real() + settings["Audio/Skew"].integer();
for(auto item : presentation->speedGroup.objects<MenuRadioItem>()) {
if(item.checked()) frequency *= item.property("multiplier").real();
}
Emulator::audio.setFrequency(frequency);
settingsWindow->audio.updateFrequency();
}
auto Program::updateAudioLatency() -> void {
if(!audio) return;
audio->clear();
if(!audio->availableLatencies().find(settings["Audio/Latency"].natural())) {
settings["Audio/Latency"].setValue(audio->availableLatencies()(0));
}
audio->setLatency(settings["Audio/Latency"].natural());
settingsWindow->audio.updateLatency();
}
auto Program::updateAudioEffects() -> void {
double volume = settings["Audio/Mute"].boolean() ? 0.0 : settings["Audio/Volume"].natural() * 0.01;
Emulator::audio.setVolume(volume);
double balance = max(-1.0, min(+1.0, (settings["Audio/Balance"].integer() - 50) / 50.0));
Emulator::audio.setBalance(balance);
bool reverb = settings["Audio/Reverb"].boolean();
Emulator::audio.setReverb(reverb);
}