diff --git a/assets/opensb/interface/optionsmenu/body_blank.png b/assets/opensb/interface/optionsmenu/body_blank.png index 7d5b0f1..dcb6112 100644 Binary files a/assets/opensb/interface/optionsmenu/body_blank.png and b/assets/opensb/interface/optionsmenu/body_blank.png differ diff --git a/assets/opensb/interface/optionsmenu/optionsmenu.config.patch b/assets/opensb/interface/optionsmenu/optionsmenu.config.patch index cc8568b..b428f37 100644 --- a/assets/opensb/interface/optionsmenu/optionsmenu.config.patch +++ b/assets/opensb/interface/optionsmenu/optionsmenu.config.patch @@ -2,13 +2,13 @@ "paneLayout" : { "voiceLabel" : { "type" : "label", - "position" : [119, 186], + "position" : [119, 202], "hAnchor" : "mid", "value" : "VOICE" }, "showVoiceSettings" : { "type" : "button", - "position" : [30, 169], + "position" : [30, 185], "caption" : "Settings", "base" : "/interface/optionsmenu/duocontrolsbutton.png", "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" @@ -16,7 +16,7 @@ "showVoicePlayers" : { "type" : "button", "disabled" : true, - "position" : [133, 169], + "position" : [133, 185], "caption" : "^#a0a000,font=iosevka-semiboldoblique;TODO^#aa7;:^reset; Players", "base" : "/interface/optionsmenu/duocontrolsbutton.png", "hover" : "/interface/optionsmenu/duocontrolsbuttonhover.png" @@ -42,7 +42,15 @@ "base" : "/interface/optionsmenu/tricontrolsbutton.png", "hover" : "/interface/optionsmenu/tricontrolsbuttonhover.png" }, - "sfxValueLabel" : { "position" : [192, 142] }, // this is 2px too low in vanilla lol - "musicSlider" : { "position" : [62, 126] } + + "volumeLabel" : { "position" : [119, 173] }, + "musicSlider" : { "position" : [62, 126] }, + + "sfxLabel" : { "position" : [32, 142], "value" : "Sound" }, + "sfxValueLabel" : { "position" : [192, 142] }, + + "instrumentSlider" : { "type" : "slider", "position" : [62, 158], "gridImage" : "/interface/optionsmenu/largeselection.png" }, + "instrumentLabel" : { "type" : "label", "position" : [32, 158], "value" : "Tunes" }, + "instrumentValueLabel" : { "type" : "label", "position" : [192, 158], "hAnchor" : "mid", "value" : "Replace Me" } } } \ No newline at end of file diff --git a/source/base/StarMixer.cpp b/source/base/StarMixer.cpp index 2ec6b9e..d3c7c5a 100644 --- a/source/base/StarMixer.cpp +++ b/source/base/StarMixer.cpp @@ -172,6 +172,7 @@ Mixer::Mixer(unsigned sampleRate, unsigned channels) { m_groupVolumes[MixerGroup::Effects] = {1.0f, 1.0f, 0}; m_groupVolumes[MixerGroup::Music] = {1.0f, 1.0f, 0}; m_groupVolumes[MixerGroup::Cinematic] = {1.0f, 1.0f, 0}; + m_groupVolumes[MixerGroup::Instruments] = {1.0f, 1.0f, 0}; m_speed = 1.0f; } @@ -296,7 +297,7 @@ void Mixer::read(int16_t* outBuffer, size_t frameCount, ExtraMixFunction extraMi ? approach(audioInstance->m_pitchMultiplierTarget, audioInstance->m_pitchMultiplier, audioInstance->m_pitchMultiplierVelocity * time) : audioInstance->m_pitchMultiplier; - if (audioInstance->m_mixerGroup == MixerGroup::Effects) + if (audioInstance->m_mixerGroup == MixerGroup::Effects || audioInstance->m_mixerGroup == MixerGroup::Instruments) pitchMultiplier *= speed; if (audioStopVolEnd == 0.0f && audioInstance->m_stopping) diff --git a/source/base/StarMixer.hpp b/source/base/StarMixer.hpp index f87f5be..b71a2f1 100644 --- a/source/base/StarMixer.hpp +++ b/source/base/StarMixer.hpp @@ -23,7 +23,8 @@ struct RampedValue { enum class MixerGroup : uint8_t { Effects, Music, - Cinematic + Cinematic, + Instruments }; class AudioInstance { diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index ea24c36..47e5596 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -44,6 +44,7 @@ Json const AdditionalDefaultConfiguration = Json::parseJson(R"JSON( "audioChannelSeparation" : [-25, 25], "sfxVol" : 100, + "instrumentVol" : 100, "musicVol" : 70, "windowedResolution" : [1000, 600], "fullscreenResolution" : [1920, 1080], diff --git a/source/frontend/StarMainMixer.cpp b/source/frontend/StarMainMixer.cpp index 219daa2..a0f5e2b 100644 --- a/source/frontend/StarMainMixer.cpp +++ b/source/frontend/StarMainMixer.cpp @@ -47,16 +47,16 @@ void MainMixer::update(float dt, bool muteSfx, bool muteMusic) { updateGroupVolume(MixerGroup::Effects, muteSfx, "sfxVol"); updateGroupVolume(MixerGroup::Music, muteMusic, "musicVol"); updateGroupVolume(MixerGroup::Cinematic, false, "sfxVol"); + updateGroupVolume(MixerGroup::Instruments, muteSfx, "instrumentVol"); WorldClientPtr currentWorld; if (m_universeClient) currentWorld = m_universeClient->worldClient(); if (currentWorld) { - for (auto audioInstance : currentWorld->pullPendingAudio()) { - audioInstance->setMixerGroup(MixerGroup::Effects); + for (auto audioInstance : currentWorld->pullPendingAudio()) m_mixer->play(audioInstance); - } + for (auto audioInstance : currentWorld->pullPendingMusic()) { audioInstance->setMixerGroup(MixerGroup::Music); m_mixer->play(audioInstance); diff --git a/source/frontend/StarOptionsMenu.cpp b/source/frontend/StarOptionsMenu.cpp index caa1b21..0ea1fa1 100644 --- a/source/frontend/StarOptionsMenu.cpp +++ b/source/frontend/StarOptionsMenu.cpp @@ -20,6 +20,9 @@ OptionsMenu::OptionsMenu(PaneManager* manager) GuiReader reader; + reader.registerCallback("instrumentSlider", [=](Widget*) { + updateInstrumentVol(); + }); reader.registerCallback("sfxSlider", [=](Widget*) { updateSFXVol(); }); @@ -67,6 +70,7 @@ OptionsMenu::OptionsMenu(PaneManager* manager) reader.construct(config.get("paneLayout"), this); + m_instrumentSlider = fetchChild("instrumentSlider"); m_sfxSlider = fetchChild("sfxSlider"); m_musicSlider = fetchChild("musicSlider"); m_tutorialMessagesButton = fetchChild("tutorialMessagesCheckbox"); @@ -74,10 +78,12 @@ OptionsMenu::OptionsMenu(PaneManager* manager) m_clientP2PJoinableButton = fetchChild("clientP2PJoinableCheckbox"); m_allowAssetsMismatchButton = fetchChild("allowAssetsMismatchCheckbox"); + m_instrumentLabel = fetchChild("instrumentValueLabel"); m_sfxLabel = fetchChild("sfxValueLabel"); m_musicLabel = fetchChild("musicValueLabel"); m_p2pJoinableLabel = fetchChild("clientP2PJoinableLabel"); + m_instrumentSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_sfxSlider->setRange(m_sfxRange, assets->json("/interface/optionsmenu/optionsmenu.config:sfxDelta").toInt()); m_musicSlider->setRange(m_musicRange, assets->json("/interface/optionsmenu/optionsmenu.config:musicDelta").toInt()); @@ -103,6 +109,7 @@ void OptionsMenu::toggleFullscreen() { } StringList const OptionsMenu::ConfigKeys = { + "instrumentVol", "sfxVol", "musicVol", "tutorialMessages", @@ -120,6 +127,12 @@ void OptionsMenu::initConfig() { } } +void OptionsMenu::updateInstrumentVol() { + m_localChanges.set("instrumentVol", m_instrumentSlider->val()); + Root::singleton().configuration()->set("instrumentVol", m_instrumentSlider->val()); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); +} + void OptionsMenu::updateSFXVol() { m_localChanges.set("sfxVol", m_sfxSlider->val()); Root::singleton().configuration()->set("sfxVol", m_sfxSlider->val()); @@ -154,6 +167,9 @@ void OptionsMenu::updateAllowAssetsMismatch() { } void OptionsMenu::syncGuiToConf() { + m_instrumentSlider->setVal(m_localChanges.get("instrumentVol").toInt(), false); + m_instrumentLabel->setText(toString(m_instrumentSlider->val())); + m_sfxSlider->setVal(m_localChanges.get("sfxVol").toInt(), false); m_sfxLabel->setText(toString(m_sfxSlider->val())); diff --git a/source/frontend/StarOptionsMenu.hpp b/source/frontend/StarOptionsMenu.hpp index b984f02..d98fb20 100644 --- a/source/frontend/StarOptionsMenu.hpp +++ b/source/frontend/StarOptionsMenu.hpp @@ -29,6 +29,7 @@ private: void initConfig(); + void updateInstrumentVol(); void updateSFXVol(); void updateMusicVol(); void updateTutorialMessages(); @@ -43,6 +44,7 @@ private: void displayModBindings(); void displayGraphics(); + SliderBarWidgetPtr m_instrumentSlider; SliderBarWidgetPtr m_sfxSlider; SliderBarWidgetPtr m_musicSlider; ButtonWidgetPtr m_tutorialMessagesButton; @@ -51,10 +53,12 @@ private: ButtonWidgetPtr m_clientP2PJoinableButton; ButtonWidgetPtr m_allowAssetsMismatchButton; + LabelWidgetPtr m_instrumentLabel; LabelWidgetPtr m_sfxLabel; LabelWidgetPtr m_musicLabel; LabelWidgetPtr m_p2pJoinableLabel; + //TODO: add instrument range (or just use one range for all 3, it's kinda silly.) Vec2I m_sfxRange; Vec2I m_musicRange; diff --git a/source/game/StarSongbook.cpp b/source/game/StarSongbook.cpp index 98c9ec7..68db655 100644 --- a/source/game/StarSongbook.cpp +++ b/source/game/StarSongbook.cpp @@ -138,6 +138,7 @@ void Songbook::playback() { } AudioInstancePtr audioInstance = make_shared(*m_uncompressedSamples[note.file]); + audioInstance->setMixerGroup(MixerGroup::Instruments); audioInstance->setPitchMultiplier(note.velocity); auto start = m_timeSourceInstance->epoch + (int64_t)(note.timecode * 1000.0);