From 91cf2d82515583d7627ce3fd452f81e345918144 Mon Sep 17 00:00:00 2001 From: Bottinator22 Date: Tue, 2 Jan 2024 23:08:51 -0800 Subject: [PATCH] Add fork changes (move instruments to their own audio group) --- source/base/StarMixer.cpp | 3 ++- source/base/StarMixer.hpp | 3 ++- source/client/StarClientApplication.cpp | 1 + source/frontend/StarMainMixer.cpp | 5 +++++ source/game/StarEntityRendering.hpp | 2 ++ source/game/StarSongbook.cpp | 2 +- source/game/StarWorldClient.cpp | 9 +++++++++ source/game/StarWorldClient.hpp | 4 ++++ 8 files changed, 26 insertions(+), 3 deletions(-) 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..16fb736 100644 --- a/source/frontend/StarMainMixer.cpp +++ b/source/frontend/StarMainMixer.cpp @@ -47,6 +47,7 @@ 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) @@ -57,6 +58,10 @@ void MainMixer::update(float dt, bool muteSfx, bool muteMusic) { audioInstance->setMixerGroup(MixerGroup::Effects); m_mixer->play(audioInstance); } + for (auto audioInstance : currentWorld->pullPendingInstrumentAudio()) { + audioInstance->setMixerGroup(MixerGroup::Instruments); + m_mixer->play(audioInstance); + } for (auto audioInstance : currentWorld->pullPendingMusic()) { audioInstance->setMixerGroup(MixerGroup::Music); m_mixer->play(audioInstance); diff --git a/source/game/StarEntityRendering.hpp b/source/game/StarEntityRendering.hpp index c131a81..cc78748 100644 --- a/source/game/StarEntityRendering.hpp +++ b/source/game/StarEntityRendering.hpp @@ -22,6 +22,7 @@ public: virtual void addDrawable(Drawable drawable, EntityRenderLayer renderLayer) = 0; virtual void addLightSource(LightSource lightSource) = 0; virtual void addParticle(Particle particle) = 0; + virtual void addInstrumentAudio(AudioInstancePtr audio) = 0; virtual void addAudio(AudioInstancePtr audio) = 0; virtual void addTilePreview(PreviewTile preview) = 0; virtual void addOverheadBar(OverheadBar bar) = 0; @@ -31,6 +32,7 @@ public: void addDrawables(List drawables, EntityRenderLayer renderLayer, Vec2F translate = Vec2F()); void addLightSources(List lightSources, Vec2F translate = Vec2F()); void addParticles(List particles, Vec2F translate = Vec2F()); + void addInstrumentAudios(List audios, Vec2F translate = Vec2F()); void addAudios(List audios, Vec2F translate = Vec2F()); void addTilePreviews(List previews); void addOverheadBars(List bars, Vec2F translate = Vec2F()); diff --git a/source/game/StarSongbook.cpp b/source/game/StarSongbook.cpp index 98c9ec7..cba60f3 100644 --- a/source/game/StarSongbook.cpp +++ b/source/game/StarSongbook.cpp @@ -153,7 +153,7 @@ void Songbook::playback() { void Songbook::render(RenderCallback* renderCallback) { for (auto& a : m_pendingAudio) - renderCallback->addAudio(a); + renderCallback->addInstrumentAudio(a); m_pendingAudio.clear(); } diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index b2a79fb..3c83d4d 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -165,6 +165,7 @@ void WorldClient::removeEntity(EntityId entityId, bool andDie) { m_particles->addParticles(move(renderCallback.particles)); m_samples.appendAll(move(renderCallback.audios)); + m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios)); } if (auto version = m_masterEntitiesNetVersion.maybeTake(entity->entityId())) { @@ -545,6 +546,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { m_particles->addParticles(move(renderCallback.particles)); m_samples.appendAll(move(renderCallback.audios)); + m_instrumentSamples.appendAll(move(renderCallback.instrumentAudios)); previewTiles.appendAll(move(renderCallback.previewTiles)); renderData.overheadBars.appendAll(move(renderCallback.overheadBars)); @@ -685,6 +687,9 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) { List WorldClient::pullPendingAudio() { return take(m_samples); } +List WorldClient::pullPendingInstrumentAudio() { + return take(m_instrumentSamples); +} List WorldClient::pullPendingMusic() { return take(m_music); @@ -2137,6 +2142,10 @@ void WorldClient::ClientRenderCallback::addAudio(AudioInstancePtr audio) { audios.append(move(audio)); } +void WorldClient::ClientRenderCallback::addInstrumentAudio(AudioInstancePtr audio) { + instrumentAudios.append(move(audio)); +} + void WorldClient::ClientRenderCallback::addTilePreview(PreviewTile preview) { previewTiles.append(move(preview)); } diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp index 3e9d15e..bb8facb 100644 --- a/source/game/StarWorldClient.hpp +++ b/source/game/StarWorldClient.hpp @@ -149,6 +149,7 @@ public: // calculations. It is not necessary on the light array. void render(WorldRenderData& renderData, unsigned borderTiles); List pullPendingAudio(); + List pullPendingInstrumentAudio(); List pullPendingMusic(); bool playerCanReachEntity(EntityId entityId, bool preferInteractive = true) const; @@ -182,6 +183,7 @@ private: void addLightSource(LightSource lightSource) override; void addParticle(Particle particle) override; void addAudio(AudioInstancePtr audio) override; + void addInstrumentAudio(AudioInstancePtr audio) override; void addTilePreview(PreviewTile preview) override; void addOverheadBar(OverheadBar bar) override; @@ -189,6 +191,7 @@ private: List lightSources; List particles; List audios; + List instrumentAudios; List previewTiles; List overheadBars; }; @@ -308,6 +311,7 @@ private: ParticleManagerPtr m_particles; List m_samples; + List m_instrumentSamples; List m_music; HashMap m_masterEntitiesNetVersion;