Skip to content

Commit c581768

Browse files
authored
Add bgnidle (#833)
1 parent bbf5cbd commit c581768

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

sound/effect.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,13 @@ EFFECT(preon);
712712
EFFECT(pstoff);
713713

714714
// Monophonic fonts
715+
716+
// Idle effect, plays when blade is off.
715717
#ifdef ENABLE_IDLE_SOUND
716718
EFFECT2(idle, idle);
717-
EFFECT2(boot, idle);
718-
EFFECT2(font, idle);
719+
EFFECT2(bgnidle, idle);
720+
EFFECT2(boot, bgnidle);
721+
EFFECT2(font, bgnidle);
719722
#else
720723
EFFECT(boot);
721724
EFFECT(font); // also polyphonic

sound/hybrid_font.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ class HybridFont : public SaberBase, public Looper {
484484
bool most_blades = location.on_blade(0);
485485
#ifdef ENABLE_IDLE_SOUND
486486
if (most_blades) {
487-
Effect* idle = AvoidIdleSDAccess() ? nullptr : &SFX_idle;
487+
Effect* bgnidle = AvoidIdleSDAccess() ? nullptr : &SFX_bgnidle;
488488
if (SFX_pstoff) {
489489
SFX_in.SetFollowing(&SFX_pstoff);
490-
SFX_pstoff.SetFollowing(idle);
490+
SFX_pstoff.SetFollowing(bgnidle);
491491
} else {
492-
SFX_in.SetFollowing(idle);
492+
SFX_in.SetFollowing(bgnidle);
493493
}
494494
} else {
495495
SFX_in.SetFollowing(nullptr);
@@ -507,7 +507,11 @@ class HybridFont : public SaberBase, public Looper {
507507
StopIdleSound();
508508
break;
509509
case OFF_FAST:
510+
#ifdef ENABLE_IDLE_SOUND
511+
SFX_in.SetFollowing(&SFX_bgnidle);
512+
#else
510513
SFX_in.SetFollowing(nullptr);
514+
#endif
511515
[[gnu::fallthrough]];
512516
case OFF_NORMAL:
513517
if (!SFX_in) {
@@ -861,13 +865,14 @@ class HybridFont : public SaberBase, public Looper {
861865

862866
void StopIdleSound() {
863867
#ifdef ENABLE_IDLE_SOUND
864-
RefPtr<BufferedWavPlayer> idlePlayer = GetWavPlayerPlaying(&SFX_idle);
868+
RefPtr<BufferedWavPlayer> idlePlayer = GetWavPlayerPlaying(&SFX_bgnidle);
869+
if (!idlePlayer) idlePlayer = GetWavPlayerPlaying(&SFX_idle);
865870
if (idlePlayer) {
866871
idlePlayer->set_fade_time(0.5);
867872
idlePlayer->FadeAndStop();
868873
idlePlayer.Free();
869-
PVLOG_NORMAL << "**** Stopped idle wav\n";
870-
}
874+
PVLOG_DEBUG << "**** Stopped idle or bgnidle wav\n";
875+
}
871876
#endif
872877
}
873878

0 commit comments

Comments
 (0)