hex/ios/HEXShared/VoiceIsolationSettings.swift
Kit Langton d02624fad3
iOS: call Settings' unfinished features Labs (#2613)
* iOS: call Settings' unfinished features Labs

* Desktop: drop the leftover Experiments translations
2026-11-24 23:36:26 -08:00

29 lines
1.2 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Foundation
/// Labs › Voice isolation, in the shared App Group so in-keyboard dictation
/// reads it too. Off by default. While it is on, the app records in
/// `AVAudioSession.Mode.voiceChat` instead of `.measurement`, so Control Center's Mic Mode
/// can offer Voice Isolation while Hex records, and in-keyboard dictation asks WebKit for
/// echo cancellation and noise suppression. Off, both record exactly as before.
nonisolated struct VoiceIsolationSettings {
static let enabledKey = "experiments.voiceIsolation"
static let launchArgument = "--experiment-voice-isolation"
private let defaults: UserDefaults?
init(defaults: UserDefaults? = UserDefaults(suiteName: KeyboardBridge.appGroup)) {
self.defaults = defaults
}
var isEnabled: Bool {
get { defaults?.bool(forKey: Self.enabledKey) ?? false }
nonmutating set { defaults?.set(newValue, forKey: Self.enabledKey) }
}
/// Simulator scenes pass `--experiment-voice-isolation` to turn the experiment on.
func applyLaunchArguments(_ arguments: [String] = ProcessInfo.processInfo.arguments) {
if arguments.contains(Self.launchArgument) {
isEnabled = true
}
}
}