Mic audio UX: realtime read-only meter + mic picker

- Meter is a READ-ONLY realtime level display: fill = Math.Min(1, AudioLevel * MicVolume) (AudioLevel = live input from the future mixer, 0 with no input; MicVolume is gain on ambient noise). While the slider is dragged the bar previews the slider position (PreviewMouseLeftButtonDown/Up + LostMouseCapture -> SetVolumeAdjusting); on release it returns to the live level (bounces to 0 with no input). Clicking the meter does nothing.
- MicVolume drives MicMuted (read-only, muted <=> volume 0): sliding to 0 flips the speaker to the red slashed mute icon, sliding up from 0 clears it; speaker button runs volume to 0 or restores the prior level (_volumeBeforeMute, default 0.8) and flashes the meter to the restored position for ~300ms (BeginVolumeFlash/EndVolumeFlash DispatcherTimer, cancelled if the slider is grabbed).
- MIC label opens MicPickerDialog (WinRT audio-capture device enumeration, mirrors camera picker, no new packages); the chosen voice source name shows left-justified INSIDE the meter bar (fill at 75% opacity so text + ruler markings show through).
- New files: Services/IMicrophoneEnumerator, MicrophoneDeviceInfo, WinRtMicrophoneEnumerator; ViewModels/MicPickerViewModel; MicPickerDialog.
- Docs updated (ai.md, TASKS.md, Services/index.md, ViewModels/index.md); build 0 warnings, 65 tests passing
This commit is contained in:
2026-08-07 17:44:16 -07:00
parent 4b3fb04322
commit b00a4cbd5e
14 changed files with 536 additions and 78 deletions
+10
View File
@@ -0,0 +1,10 @@
namespace ytLive.Services;
/// <summary>
/// Enumerates audio capture (microphone) devices. Seam so the picker never
/// touches WinRT directly (tests inject fakes).
/// </summary>
public interface IMicrophoneEnumerator
{
Task<IReadOnlyList<MicrophoneDeviceInfo>> GetMicrophonesAsync();
}
+13
View File
@@ -0,0 +1,13 @@
namespace ytLive.Services;
public sealed class MicrophoneDeviceInfo
{
public string Id { get; }
public string DisplayName { get; }
public MicrophoneDeviceInfo(string id, string displayName)
{
Id = id;
DisplayName = displayName;
}
}
+15
View File
@@ -0,0 +1,15 @@
using Windows.Devices.Enumeration;
namespace ytLive.Services;
public sealed class WinRtMicrophoneEnumerator : IMicrophoneEnumerator
{
public async Task<IReadOnlyList<MicrophoneDeviceInfo>> GetMicrophonesAsync()
{
var devices = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture);
var result = new List<MicrophoneDeviceInfo>(devices.Count);
foreach (var device in devices)
result.Add(new MicrophoneDeviceInfo(device.Id, device.Name));
return result;
}
}
+3
View File
@@ -14,6 +14,9 @@ External-facing logic: YouTube API, persistence. See
| `ICameraEnumerator.cs` | `GetCamerasAsync()` — seam so the picker/`CameraManager` never touch WinRT (tests inject fakes) |
| `ICameraFrameSource.cs` | `StartAsync`/`StopAsync`/`FrameAvailable(VideoFrame)` — seam for a running capture source |
| `MediaCaptureCameraEnumerator.cs` | WinRT enumeration via `DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)` |
| `MicrophoneDeviceInfo.cs` | `(Id, DisplayName)` for an audio capture (mic) device |
| `IMicrophoneEnumerator.cs` | `GetMicrophonesAsync()` — seam so the mic picker never touches WinRT (tests inject fakes) |
| `WinRtMicrophoneEnumerator.cs` | WinRT mic enumeration via `DeviceInformation.FindAllAsync(DeviceClass.AudioCapture)` (no NAudio needed — capture libs stay deferred to the audio pipeline milestone) |
| `MediaCaptureFrameSource.cs` | CPU-first MediaCapture source (`MemoryPreference = Cpu`, BGRA8 via `CreateFrameReaderAsync`); frames arrive on a worker thread |
| `CameraManager.cs` | Webcam capture ownership: refcounted by `DeviceId`, one shared `WriteableBitmap` per camera, dispatcher-coalesced ~render-rate UI updates (latest-frame drop); `PreviewBitmapChanged`/`CameraFailed` events. `ReleaseAsync` decrements a ref (stops at zero); `ReleaseAllAsync` force-drops every ref + stops the source (webcam swap / layout reload). `GetPreviewBitmap(deviceId)` returns the current shared bitmap so a `WebcamSceneConfig` added mid-session (after the first frame already created the bitmap) still receives the live frames |
| `IFullScreenDetector.cs` | Seam for the win32 full-screen detector: `int? GetForegroundFullScreenMonitorIndex()`, `int PrimaryMonitorIndex()`, `IReadOnlyList<DisplayInfo> GetDisplays()` |