@@ -93,6 +93,12 @@ void Game_System::BgmPlay(lcf::rpg::Music const& bgm) {
9393 Output::Debug (" BGM {} has invalid tempo {}" , bgm.name , bgm.tempo );
9494 }
9595
96+ if (bgm.balance < 0 || bgm.balance > 100 ) {
97+ data.current_music .balance = Utils::Clamp<int32_t >(bgm.balance , 0 , 100 );
98+
99+ Output::Debug (" BGM {} has invalid balance {}" , bgm.name , bgm.balance );
100+ }
101+
96102 // (OFF) means play nothing
97103 if (!bgm.name .empty () && bgm.name != " (OFF)" ) {
98104 // Same music: Only adjust volume and speed
@@ -107,6 +113,11 @@ void Game_System::BgmPlay(lcf::rpg::Music const& bgm) {
107113 Audio ().BGM_Pitch (data.current_music .tempo );
108114 }
109115 }
116+ if (previous_music.balance != data.current_music .balance ) {
117+ if (!bgm_pending) {
118+ Audio ().BGM_Balance (data.current_music .balance );
119+ }
120+ }
110121 } else {
111122 Audio ().BGM_Stop ();
112123 bgm_pending = true ;
@@ -164,6 +175,7 @@ void Game_System::SePlay(const lcf::rpg::Sound& se, bool stop_sounds) {
164175
165176 int32_t volume = se.volume ;
166177 int32_t tempo = se.tempo ;
178+ int32_t balance = se.balance ;
167179
168180 // Validate
169181 if (volume < 0 || volume > 100 ) {
@@ -177,10 +189,16 @@ void Game_System::SePlay(const lcf::rpg::Sound& se, bool stop_sounds) {
177189 tempo = Utils::Clamp<int32_t >(se.tempo , 10 , 400 );
178190 }
179191
192+ if (balance < 0 || balance > 100 ) {
193+ Output::Debug (" SE {} has invalid balance {}" , se.name , balance);
194+ balance = Utils::Clamp<int32_t >(se.balance , 0 , 100 );
195+ }
196+
180197 FileRequestAsync* request = AsyncHandler::RequestFile (" Sound" , se.name );
181198 lcf::rpg::Sound se_adj = se;
182199 se_adj.volume = volume;
183200 se_adj.tempo = tempo;
201+ se_adj.balance = balance;
184202 se_request_ids[se.name ] = request->Bind (&Game_System::OnSeReady, this , se_adj, stop_sounds);
185203 if (EndsWith (se.name , " .script" )) {
186204 // Is a Ineluki Script File
0 commit comments