Master Volume

This commit is contained in:
CatWindow 2026-08-12 13:08:19 +03:00
parent 831354ade8
commit b622b5dcdf
7 changed files with 38 additions and 3 deletions

View file

@ -18,8 +18,7 @@ Target of sunshine mod - improve original game.
* pixman
* SDL3_image
* SDL3_ttf
* [SDL3_sound](https://github.com/icculus/SDL_sound)
* OpenAL
* SDL3_mixer
* PhysFS
* sigc++-2.0
* vorbisfile

View file

@ -46,6 +46,15 @@ static VALUE rb_audio_destroyGroup(VALUE self, VALUE groupId) {
return Qnil;
}
static VALUE rb_audio_getMasterVolume(VALUE self) {
return DBL2NUM(shState->audio().getMasterVolume());
}
static VALUE rb_audio_setMasterVolume(VALUE self, VALUE volume) {
shState->audio().setMasterVolume(NUM2DBL(volume));
return Qnil;
}
static VALUE rb_audio_getGroupVolume(VALUE self, VALUE groupId) {
return DBL2NUM(shState->audio().getGroupVolume(FIX2INT(groupId)));
}
@ -108,6 +117,9 @@ void audioBindingInit(){
rb_define_singleton_method(module, "create_group", RUBY_METHOD_FUNC(rb_audio_createGroup), 0);
rb_define_singleton_method(module, "destroy_group", RUBY_METHOD_FUNC(rb_audio_destroyGroup), 1);
rb_define_singleton_method(module, "master_volume", RUBY_METHOD_FUNC(rb_audio_getMasterVolume), 0);
rb_define_singleton_method(module, "master_volume=", RUBY_METHOD_FUNC(rb_audio_setMasterVolume), 1);
rb_define_singleton_method(module, "get_group_volume", RUBY_METHOD_FUNC(rb_audio_getGroupVolume), 1);
rb_define_singleton_method(module, "set_group_volume", RUBY_METHOD_FUNC(rb_audio_setGroupVolume), 2);
rb_define_singleton_method(module, "stop_group_sounds", RUBY_METHOD_FUNC(rb_audio_stopGroupSounds), -1);

View file

@ -55,3 +55,5 @@ Fixed Office teleport bug
Added Crash Screen
Added In-Memory Log buffer
Added setting "Use Old Self Contained Universe(Reprise) version"
Rewrited audio system from SDL3_sound and OpenAL to SDL_mixer
Added Master Volume setting

View file

@ -3,6 +3,7 @@ module Settings
def reset!
@data = {
# Audio
:master_volume => 100,
:bgm_volume => 100,
:sfx_volume => 100,
:use_fight_crime_track => false,
@ -154,6 +155,13 @@ class Window_Settings
},
],
"Audio" => [
{
:type => :slider,
:name => "Master Volume",
:parameter => :master_volume,
:min => 0,
:max => 100
},
{
:type => :slider,
:name => "BGM Volume",

View file

@ -11,7 +11,9 @@ module Settings
def crashlog_privacy(value)
Sunshine.crashprivacy=value
end
def master_volume(value)
Audio.master_volume = value / 100.0
end
def bgm_volume(value)
Audio.bgm_volume = value
end

View file

@ -123,6 +123,14 @@ void Audio::destroyGroup(int group) {
p->groups[group] = nullptr;
}
float Audio::getMasterVolume() const {
return MIX_GetMixerGain(mixer);
}
void Audio::setMasterVolume(float volume) {
MIX_SetMixerGain(mixer, volume);
}
float Audio::getGroupVolume(int group) const {
AudioGroup* mixGroup = getGroup(group);
if (!mixGroup)
@ -136,6 +144,7 @@ void Audio::setGroupVolume(int group, float volume) {
if (a_group)
a_group->setVolume(volume);
}
void Audio::stopSoundsInGroup(int group, float fadeoutTime) {
AudioGroup* a_group = getGroup(group);
if (a_group)

View file

@ -42,6 +42,9 @@ public:
AudioGroup* getGroup(int group) const;
void destroyGroup(int group);
float getMasterVolume() const;
void setMasterVolume(float volume);
float getGroupVolume(int group) const;
void setGroupVolume(int group, float volume);
void stopSoundsInGroup(int group, float fadeoutTime = 0.0f);