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
+90
View File
@@ -0,0 +1,90 @@
<Window x:Class="ytLive.MicPickerDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Select Microphone" Height="340" Width="460"
Icon="/Assets/llama-logo-icon.png"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize"
ShowInTaskbar="False" Background="#1a1a2e">
<Window.Resources>
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<Style x:Key="CandidateItem" TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Bd" Background="Transparent" CornerRadius="4" Padding="6,5" Margin="0,2">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="#1c2a52"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="#2a2450"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid Margin="24">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Select Microphone" FontSize="18" FontWeight="Bold"
Foreground="#e0e0e0" Margin="0,0,0,14"/>
<TextBlock Grid.Row="1" Text="Pick the microphone to use as your voice source."
Foreground="#a0a0b0" FontSize="13" TextWrapping="Wrap" Margin="0,0,0,12"/>
<Grid Grid.Row="2">
<ListBox Background="Transparent" BorderThickness="0"
ItemContainerStyle="{StaticResource CandidateItem}"
ItemsSource="{Binding Microphones}"
SelectedItem="{Binding SelectedMic, Mode=TwoWay}"
Visibility="{Binding HasMicrophones, Converter={StaticResource BoolToVis}}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="🎙️" FontSize="15" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="{Binding Name}" Foreground="#e0e0e0" FontSize="13"
VerticalAlignment="Center" TextTrimming="CharacterEllipsis"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"
Visibility="{Binding IsLoading, Converter={StaticResource BoolToVis}}">
<TextBlock Text="Searching for microphones…" Foreground="#a0a0b0" FontSize="13"/>
</StackPanel>
<StackPanel VerticalAlignment="Center"
Visibility="{Binding NoMicrophones, Converter={StaticResource BoolToVis}}">
<TextBlock Text="No microphones found" Foreground="#e0e0e0" FontSize="15"
FontWeight="SemiBold" HorizontalAlignment="Center"/>
<TextBlock Text="Check that a microphone is connected and that Windows microphone access is enabled."
Foreground="#a0a0b0" FontSize="13" TextWrapping="Wrap" MaxWidth="360"
TextAlignment="Center" HorizontalAlignment="Center" Margin="0,8,0,0"/>
</StackPanel>
</Grid>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
<Button Content="Cancel" Command="{Binding CancelCommand}"
Style="{StaticResource YtButtonSecondary}" Margin="0,0,8,0"/>
<Button Content="Use Selected" Command="{Binding UseSelectedCommand}"
Style="{StaticResource YtButton}" MinWidth="110"/>
</StackPanel>
</Grid>
</Window>