Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Master volume level setting #5268

Merged
merged 2 commits into from
Oct 20, 2018
Merged

Conversation

MSuih
Copy link
Member

@MSuih MSuih commented Oct 19, 2018

The idea with this PR is to allow users to modify the loudness of game sounds without having to tinker with OS settings, and add the possibility of having game-specific volume settings.

Notes:

  • Does not include any changes for the settings menu, and thus the setting has to be modified by altering config.yml manually.

If someone wants to do GUI support (@Megamouse perhaps?) for this setting then I could cherrypick your commits into this PR, or those can be submitted as separate PR's after this one has been merged.

@isshininu
Copy link
Contributor

I don't understand the idea of this.
Most games comes with their own audio volume settings, that stored in save settings.

@@ -121,7 +121,7 @@ void XAudio2Thread::xa27_open()
return;
}

s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0f : 4.0f);
s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0f * (g_cfg.audio.volume / 100.0) : 4.0f * (g_cfg.audio.volume / 100.0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0f * (g_cfg.audio.volume / 100.0) : 4.0f * (g_cfg.audio.volume / 100.0));
s_tls_source_voice->SetVolume((g_cfg.audio.downmix_to_2ch ? 1.0f : 4.0f) * g_cfg.audio.volume / 100.0f);

@@ -123,7 +123,7 @@ void XAudio2Thread::xa28_open()
return;
}

s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0 : 4.0);
s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0 * (g_cfg.audio.volume / 100.0) : 4.0 * (g_cfg.audio.volume / 100.0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
s_tls_source_voice->SetVolume(g_cfg.audio.downmix_to_2ch ? 1.0 * (g_cfg.audio.volume / 100.0) : 4.0 * (g_cfg.audio.volume / 100.0));
s_tls_source_voice->SetVolume((g_cfg.audio.downmix_to_2ch ? 1.0f : 4.0f) * g_cfg.audio.volume / 100.0f);

@@ -508,6 +508,7 @@ struct cfg_root : cfg::node
cfg::_bool downmix_to_2ch{this, "Downmix to Stereo", true};
cfg::_int<2, 128> frames{this, "Buffer Count", 32};
cfg::_int<1, 128> startt{this, "Start Threshold", 1};
cfg::_int<0, 100> volume{this, "Master volume", 100};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the options are capitalized:

Suggested change
cfg::_int<0, 100> volume{this, "Master volume", 100};
cfg::_int<0, 100> volume{this, "Master Volume", 100};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of them are capitalized and some of them are not, f.ex. "Dump to file" in start of the audio section and other examples include "Camera type", "Enter button assignment", "Log shader programs" and so on. But I guess uppercase is the more common variation.

@MSuih
Copy link
Member Author

MSuih commented Oct 19, 2018

@isshininu I've seen some users request this option as they want to reduce game sounds without having to fiddle with the cubersome volume mixer in Windows. Having to set the volume level game-by-game is a tedious process. And there could be a rare title out there with no support for volume adjustments as well, not to mention games that don't let you fiddle with settings before an introduction movie or something similar.

@Nekotekina
Copy link
Member

The volume should be applied on cellAudio.cpp side, this way it doesn't rely on audio API.
Also the max limit can be bigger than 100, it's useful in some cases where the audio is too quiet.

@Hirato
Copy link

Hirato commented Oct 20, 2018

With Pulseaudio you should be able to manipulate RPCS3's 'Application Specific Volume' - then you'd just leave the mixing to the PulseAudio Daemon.

The volume setting I'm talking about is exposed in KDE like this:
image

Just be mindful with manipulating it haphazardly if pusleaudio's flat-volumes setting is on.

@MSuih
Copy link
Member Author

MSuih commented Oct 20, 2018

@Nekotekina My idea with this was to just modify the audio output and leave the whole emulation side untouched. But I'll look into your proposal. Setting volume beyond 100% can cause distortion or reduction in quality, but I guess that's up for user to decide.

@Hirato Yes, the actual volume changes woudn't be too hard to implement. The problem is that RPCS3 uses a simplified version of the PulseAudio API that has just enough functionality to play audio and pretty much nothing else. Getting any additional features to work would require rewriting the whole PulseAudio support as there doesn't seem to be any "bridges" between simple and compicated APIs.

@MSuih MSuih force-pushed the audio branch 2 times, most recently from fd2661a to c86130a Compare October 20, 2018 06:42
@MSuih
Copy link
Member Author

MSuih commented Oct 20, 2018

Alirght, I switched to manipulating the port levels directly. I still prefer my eariler idea, but if neko wishes this implementation then I'll comply. Now it does not require any support from the audio backends at least. I tried modifying the three cellAudioAddData functions but games seem to be able to bypass these.

@Megamouse
Copy link
Contributor

I'd prefer to add my own PR for hacktoberfest

@MSuih
Copy link
Member Author

MSuih commented Oct 20, 2018

That's understandable, I guess this PR is ready for merge then. I tried fiddling around with the settings menu files but I couldn't get the layout to behave nicely.

@@ -679,6 +679,7 @@ error_code cellAudioSetPortLevel(u32 portNum, float level)
cellAudio.trace("cellAudioSetPortLevel(portNum=%d, level=%f)", portNum, level);

const auto g_audio = g_idm->lock<named_thread<audio_thread>>(0);
level *= g_cfg.audio.volume / 100.0f;
Copy link
Contributor

@Megamouse Megamouse Oct 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you move this to line 700?
Right now this line will be redundant in case any of those other checks fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really make a huge difference, but I guess it's a more logical location.

@MSuih MSuih changed the title Partial support for Master volume level setting Support for Master volume level setting Oct 20, 2018
@Nekotekina Nekotekina merged commit 56ea45f into RPCS3:master Oct 20, 2018
@MSuih MSuih deleted the audio branch October 20, 2018 14:43
@Catcher40
Copy link

Not that this has anything to do with this emulator but there is an app on the m$ store called eartrumpet that lets you control the sound levels for individual apps, i've been using it for quite awhile now and it works brilliantly for everything, games, emulators, web browsers the lot and its free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants