feat(clients): persist input settings, add mic input gain, fix iOS chat + VoiceOver
Input mode (VAD/PTT/Always-On), VAD threshold, and the new mic gain were
applied to the core + UI but never saved, so every relaunch reset to VAD
defaults. Each client now persists them and re-applies on connect:
- iOS: UserDefaults (SessionState.loadAndApplyVoiceSettings + setter writes)
- macOS: UserDefaults via MainWindowController didSet + loadPersistedAudioSettings
(settings window also restores the VAD slider from the stored threshold)
- Windows: new Models/VoiceSettings.cs (JSON at %AppData%\VoiceCat\voice.json,
mirrors FeedbackSettings) loaded/applied in MainForm
Add global send-side mic gain API vc_set_input_gain (applied to MIC PCM in
on_capture_frame before the VAD gate, clamped to int16) + Swift/C# bindings,
and a 0-300% (default 100%) mic-volume slider on all three clients.
Fix iOS chat: ChatView called sendText(scope:.channel) with no targetId (0),
so channel messages went nowhere; now passes session.currentChannelId.
Fix iOS per-user tuning for VoiceOver: the tuning sheet was long-press
.contextMenu only (invisible to VoiceOver); UserRow now also exposes the same
buttons via .accessibilityActions (no visual change).
Verified: core builds clean; ctest 24/27 (3 pre-existing teardown crashes,
reproduced with changes stashed); VoiceCatMac + VoiceCatiOS (arm64 sim) build
SUCCEEDED; VoiceCat.Interop dotnet build succeeded. Windows App not built
(WinForms can't build on macOS) — follows existing patterns.
2026-06-23 03:35:26 +02:00
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
|
|
namespace VoiceCat.App.Models;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// User's send-side voice input preferences — transmission mode, VAD sensitivity, mic input
|
|
|
|
|
|
/// gain, and the push-to-talk key. Persisted to %AppData%\VoiceCat\voice.json, same pattern as
|
|
|
|
|
|
/// <see cref="ServerListStore"/> and FeedbackSettings: a missing or corrupt file yields defaults
|
|
|
|
|
|
/// rather than throwing. Slider-position values are stored as-is so MainForm can restore the
|
|
|
|
|
|
/// TrackBars directly.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class VoiceSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Transmission mode: 0 = voice activation, 1 = push-to-talk, 2 = always on
|
|
|
|
|
|
/// (matches Interop's VcInputMode).</summary>
|
|
|
|
|
|
public int InputMode { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>VAD sensitivity slider position, 1–100 (default mirrors the designer's 76).</summary>
|
|
|
|
|
|
public int VadThresholdSlider { get; set; } = 76;
|
|
|
|
|
|
|
2026-06-24 12:18:10 +02:00
|
|
|
|
/// <summary>Microphone input gain slider position, 0–400 percent (100 = unity).</summary>
|
feat(clients): persist input settings, add mic input gain, fix iOS chat + VoiceOver
Input mode (VAD/PTT/Always-On), VAD threshold, and the new mic gain were
applied to the core + UI but never saved, so every relaunch reset to VAD
defaults. Each client now persists them and re-applies on connect:
- iOS: UserDefaults (SessionState.loadAndApplyVoiceSettings + setter writes)
- macOS: UserDefaults via MainWindowController didSet + loadPersistedAudioSettings
(settings window also restores the VAD slider from the stored threshold)
- Windows: new Models/VoiceSettings.cs (JSON at %AppData%\VoiceCat\voice.json,
mirrors FeedbackSettings) loaded/applied in MainForm
Add global send-side mic gain API vc_set_input_gain (applied to MIC PCM in
on_capture_frame before the VAD gate, clamped to int16) + Swift/C# bindings,
and a 0-300% (default 100%) mic-volume slider on all three clients.
Fix iOS chat: ChatView called sendText(scope:.channel) with no targetId (0),
so channel messages went nowhere; now passes session.currentChannelId.
Fix iOS per-user tuning for VoiceOver: the tuning sheet was long-press
.contextMenu only (invisible to VoiceOver); UserRow now also exposes the same
buttons via .accessibilityActions (no visual change).
Verified: core builds clean; ctest 24/27 (3 pre-existing teardown crashes,
reproduced with changes stashed); VoiceCatMac + VoiceCatiOS (arm64 sim) build
SUCCEEDED; VoiceCat.Interop dotnet build succeeded. Windows App not built
(WinForms can't build on macOS) — follows existing patterns.
2026-06-23 03:35:26 +02:00
|
|
|
|
public int MicGain { get; set; } = 100;
|
|
|
|
|
|
|
feat(clients): wire RNNoise mic noise reduction into Windows, macOS, and iOS
Expose the existing send-side vc_set_input_noise_reduction C ABI (MIC-only,
mono, LOCAL — denoises captured mic PCM before input gain and VAD/PTT gate)
as a persisted global toggle in each client's audio settings, applied live
and re-applied on Join Voice. Mirrors the existing mic-gain wiring pattern.
- Shared Swift (VoiceCatCore): add setInputNoiseReduction(_:) wrapper
- Windows: P/Invoke + SetInputNoiseReduction wrapper, MicNoiseReduction in
VoiceSettings, new checkbox in AudioSettingsForm (layout shifted +28px),
apply on Join Voice; also fix stale 'planned - currently passthrough'
label on the receive-side per-user NR checkbox (RNNoise now backs it)
- macOS: inputNoiseReduction state + UserDefaults in MainWindowController,
NR checkbox + nrChanged action in SettingsWindowController
- iOS: inputNoiseReduction in VoiceState + setter + restore in SessionState,
NR Toggle in SettingsView Voice section
Aux/screen are out of scope by design (core's NR guards kind == MIC). Apple
builds require a rebuilt VoiceCatCore.xcframework with VOICECAT_HAS_NS.
2026-06-23 14:11:18 +02:00
|
|
|
|
/// <summary>Send-side mic noise reduction (RNNoise) toggle. MIC stream only, mono only;
|
|
|
|
|
|
/// denoises captured mic PCM before input gain and VAD/PTT gate so everyone hears the
|
|
|
|
|
|
/// cleaned signal. Independent of the per-listener receive-side NR.</summary>
|
|
|
|
|
|
public bool MicNoiseReduction { get; set; } = false;
|
|
|
|
|
|
|
2026-06-23 20:48:26 +02:00
|
|
|
|
/// <summary>Capture the mic in stereo (interleaved L/R) instead of mono. Off by default. Real
|
|
|
|
|
|
/// stereo only reaches the wire on a stereo channel; on a mono channel the core folds the mic
|
|
|
|
|
|
/// to mono. Applied when the capture device next starts (Join Voice or an audio restart).</summary>
|
|
|
|
|
|
public bool StereoMic { get; set; } = false;
|
|
|
|
|
|
|
feat(clients): persist input settings, add mic input gain, fix iOS chat + VoiceOver
Input mode (VAD/PTT/Always-On), VAD threshold, and the new mic gain were
applied to the core + UI but never saved, so every relaunch reset to VAD
defaults. Each client now persists them and re-applies on connect:
- iOS: UserDefaults (SessionState.loadAndApplyVoiceSettings + setter writes)
- macOS: UserDefaults via MainWindowController didSet + loadPersistedAudioSettings
(settings window also restores the VAD slider from the stored threshold)
- Windows: new Models/VoiceSettings.cs (JSON at %AppData%\VoiceCat\voice.json,
mirrors FeedbackSettings) loaded/applied in MainForm
Add global send-side mic gain API vc_set_input_gain (applied to MIC PCM in
on_capture_frame before the VAD gate, clamped to int16) + Swift/C# bindings,
and a 0-300% (default 100%) mic-volume slider on all three clients.
Fix iOS chat: ChatView called sendText(scope:.channel) with no targetId (0),
so channel messages went nowhere; now passes session.currentChannelId.
Fix iOS per-user tuning for VoiceOver: the tuning sheet was long-press
.contextMenu only (invisible to VoiceOver); UserRow now also exposes the same
buttons via .accessibilityActions (no visual change).
Verified: core builds clean; ctest 24/27 (3 pre-existing teardown crashes,
reproduced with changes stashed); VoiceCatMac + VoiceCatiOS (arm64 sim) build
SUCCEEDED; VoiceCat.Interop dotnet build succeeded. Windows App not built
(WinForms can't build on macOS) — follows existing patterns.
2026-06-23 03:35:26 +02:00
|
|
|
|
/// <summary>Push-to-talk key, stored as the integer value of System.Windows.Forms.Keys.</summary>
|
|
|
|
|
|
public int PttKey { get; set; } = (int)Keys.F8;
|
|
|
|
|
|
|
2026-06-24 13:14:01 +02:00
|
|
|
|
/// <summary>Make push-to-talk work system-wide — i.e. while another app is focused. When on,
|
|
|
|
|
|
/// MainForm registers a background Raw Input keyboard device (WM_INPUT + RIDEV_INPUTSINK) so the
|
|
|
|
|
|
/// PTT key is observed even when VoiceCat is not in the foreground; when off, PTT is focus-scoped
|
|
|
|
|
|
/// (only fires while the VoiceCat window has focus). Raw Input is used instead of a low-level
|
|
|
|
|
|
/// keyboard hook to avoid antivirus keylogger heuristics.</summary>
|
|
|
|
|
|
public bool SystemWidePtt { get; set; } = true;
|
|
|
|
|
|
|
2026-06-23 12:15:18 +02:00
|
|
|
|
/// <summary>Saved device ID from the last session; null means use the system default.</summary>
|
|
|
|
|
|
public string? InputDeviceId { get; set; } = null;
|
|
|
|
|
|
|
2026-06-23 12:56:09 +02:00
|
|
|
|
/// <summary>Whether the secondary "aux" outgoing stream is enabled. The aux stream is a
|
|
|
|
|
|
/// second hardware input device the client captures itself and feeds to the core via
|
|
|
|
|
|
/// vc_stream_feed_pcm (kind = AUX_DEVICE, external_feed). Lets a user transmit e.g. mic +
|
|
|
|
|
|
/// a line-in at once.</summary>
|
|
|
|
|
|
public bool AuxEnabled { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>WASAPI endpoint id of the aux capture device; null = system default capture
|
|
|
|
|
|
/// device. NOTE: this is a WASAPI device id (from <see cref="Audio.InputDeviceEnumerator"/>),
|
|
|
|
|
|
/// NOT a core/miniaudio id — the aux device is opened client-side, so the two id spaces differ.</summary>
|
|
|
|
|
|
public string? AuxDeviceId { get; set; } = null;
|
|
|
|
|
|
|
2026-06-24 12:18:10 +02:00
|
|
|
|
/// <summary>Aux input volume slider position, 0–400 percent (100 = unity). Applied client-side
|
2026-06-23 12:56:09 +02:00
|
|
|
|
/// to the captured PCM before feeding (the core's input gain is mic-only and global).</summary>
|
|
|
|
|
|
public int AuxGain { get; set; } = 100;
|
|
|
|
|
|
|
feat(clients): persist input settings, add mic input gain, fix iOS chat + VoiceOver
Input mode (VAD/PTT/Always-On), VAD threshold, and the new mic gain were
applied to the core + UI but never saved, so every relaunch reset to VAD
defaults. Each client now persists them and re-applies on connect:
- iOS: UserDefaults (SessionState.loadAndApplyVoiceSettings + setter writes)
- macOS: UserDefaults via MainWindowController didSet + loadPersistedAudioSettings
(settings window also restores the VAD slider from the stored threshold)
- Windows: new Models/VoiceSettings.cs (JSON at %AppData%\VoiceCat\voice.json,
mirrors FeedbackSettings) loaded/applied in MainForm
Add global send-side mic gain API vc_set_input_gain (applied to MIC PCM in
on_capture_frame before the VAD gate, clamped to int16) + Swift/C# bindings,
and a 0-300% (default 100%) mic-volume slider on all three clients.
Fix iOS chat: ChatView called sendText(scope:.channel) with no targetId (0),
so channel messages went nowhere; now passes session.currentChannelId.
Fix iOS per-user tuning for VoiceOver: the tuning sheet was long-press
.contextMenu only (invisible to VoiceOver); UserRow now also exposes the same
buttons via .accessibilityActions (no visual change).
Verified: core builds clean; ctest 24/27 (3 pre-existing teardown crashes,
reproduced with changes stashed); VoiceCatMac + VoiceCatiOS (arm64 sim) build
SUCCEEDED; VoiceCat.Interop dotnet build succeeded. Windows App not built
(WinForms can't build on macOS) — follows existing patterns.
2026-06-23 03:35:26 +02:00
|
|
|
|
private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true };
|
|
|
|
|
|
|
|
|
|
|
|
private static string AppDataDir => Path.Combine(
|
|
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VoiceCat");
|
|
|
|
|
|
|
|
|
|
|
|
private static string FilePath => Path.Combine(AppDataDir, "voice.json");
|
|
|
|
|
|
|
|
|
|
|
|
public static VoiceSettings Load()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!File.Exists(FilePath)) return new VoiceSettings();
|
|
|
|
|
|
string json = File.ReadAllText(FilePath);
|
|
|
|
|
|
return JsonSerializer.Deserialize<VoiceSettings>(json) ?? new VoiceSettings();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
return new VoiceSettings();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(AppDataDir);
|
|
|
|
|
|
File.WriteAllText(FilePath, JsonSerializer.Serialize(this, JsonOptions));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|