diff --git a/README.md b/README.md index ae22776..f0a635c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index caa7898..1a098ad 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -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); diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt index cf4d907..971bbb2 100644 --- a/changelogs/0.1.2.txt +++ b/changelogs/0.1.2.txt @@ -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 \ No newline at end of file diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb index d371379..57f6e33 100644 --- a/scripts/Data_Settings.rb +++ b/scripts/Data_Settings.rb @@ -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", diff --git a/scripts/Settings_Setters.rb b/scripts/Settings_Setters.rb index 961c454..aa1dc6f 100644 --- a/scripts/Settings_Setters.rb +++ b/scripts/Settings_Setters.rb @@ -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 diff --git a/src/sound/audio.cpp b/src/sound/audio.cpp index 5b5aa5b..6827588 100644 --- a/src/sound/audio.cpp +++ b/src/sound/audio.cpp @@ -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) diff --git a/src/sound/audio.h b/src/sound/audio.h index 5b3763c..42dcf8a 100644 --- a/src/sound/audio.h +++ b/src/sound/audio.h @@ -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);