Skip to content

Commit

Permalink
Adds an option to mute game audio during fast forward
Browse files Browse the repository at this point in the history
  • Loading branch information
LitRitt committed Feb 8, 2024
1 parent e071c50 commit a3fd89d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cores/DeltaCore
15 changes: 14 additions & 1 deletion Ignited/Emulation/GameViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,8 @@ private extension GameViewController
func updateEmulationSpeed()
{
self.emulatorCore?.rate = Settings.gameplayFeatures.quickSettings.fastForwardSpeed

self.updateAudio()
}

func updateControllerSkinCustomization()
Expand Down Expand Up @@ -1950,6 +1952,13 @@ private extension GameViewController
self.emulatorCore?.audioManager.playWithOtherMedia = Settings.gameplayFeatures.gameAudio.playOver
}

let isFastForwarding = self.emulatorCore?.rate != self.emulatorCore?.deltaCore.supportedRates.lowerBound
let mutedByFastForward = Settings.gameplayFeatures.gameAudio.fastForwardMutes && isFastForwarding

if self.emulatorCore?.audioManager.mutedByFastForward != mutedByFastForward {
self.emulatorCore?.audioManager.mutedByFastForward = mutedByFastForward
}

self.emulatorCore?.audioManager.audioVolume = Float(Settings.gameplayFeatures.gameAudio.volume)
}
}
Expand Down Expand Up @@ -2440,6 +2449,8 @@ extension GameViewController
{
self.presentToastView(text: text)
}

self.updateAudio()
}

func updateFastForwardSpeed(speed: Double)
Expand All @@ -2452,6 +2463,8 @@ extension GameViewController
{
emulatorCore.rate = speed
}

self.updateAudio()
}

func performQuickSettingsAction()
Expand Down Expand Up @@ -3194,7 +3207,7 @@ private extension GameViewController
case Settings.snesFeatures.allowInvalidVRAMAccess.settingsKey:
self.updateCoreSettings()

case Settings.gameplayFeatures.gameAudio.$respectSilent.settingsKey, Settings.gameplayFeatures.gameAudio.$playOver.settingsKey, Settings.gameplayFeatures.gameAudio.$volume.settingsKey:
case Settings.gameplayFeatures.gameAudio.$respectSilent.settingsKey, Settings.gameplayFeatures.gameAudio.$playOver.settingsKey, Settings.gameplayFeatures.gameAudio.$volume.settingsKey, Settings.gameplayFeatures.gameAudio.$fastForwardMutes.settingsKey:
self.updateAudio()

case Settings.touchFeedbackFeatures.touchAudio.$sound.settingsKey:
Expand Down
4 changes: 4 additions & 0 deletions Ignited/Features/Gameplay/GameAudioOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ struct GameAudioOptions
description: "Enable to play game audio over other media, such as voice chat or videos.")
var playOver: Bool = true

@Option(name: "Mute During Fast Forward",
description: "Enable to mute game audio while fast forwarding.")
var fastForwardMutes: Bool = false

@Option(name: "Restore Defaults",
description: "Reset all options to their default values.",
detailView: { _ in
Expand Down
2 changes: 2 additions & 0 deletions Ignited/Quick Settings/QuickSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ struct QuickSettingsView: View
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle("Play Over Other Media", isOn: Settings.gameplayFeatures.gameAudio.$playOver.valueBinding)
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle("Mute During Fast Forward", isOn: Settings.gameplayFeatures.gameAudio.$fastForwardMutes.valueBinding)
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
}
} header: {
Expand Down

0 comments on commit a3fd89d

Please sign in to comment.