Skip to content

feat(macos): add menu bar microphone switcher and auto-switch on connect - #195

Open
MrEGAMERZ wants to merge 2 commits into
karansinghgit:mainfrom
MrEGAMERZ:main
Open

MrEGAMERZ wants to merge 2 commits into
karansinghgit:mainfrom
MrEGAMERZ:main

Conversation

@MrEGAMERZ

Copy link
Copy Markdown

Summary

Adds direct microphone switching from the top macOS menu bar popover and automatic switching when a new microphone is connected.

Why This Is Needed

Previously, when a user had two or more microphones connected (for example, the MacBook built-in microphone plus an external USB microphone or Bluetooth headset):

  1. No Auto-Switch on Connect: Plugging in or connecting a secondary microphone left SpeakType pinned to the previous microphone until changed manually.
  2. High-Friction Switching: Switching between connected microphones required opening the full Dashboard → Audio Input screen rather than toggling directly from the menu bar popover where daily statistics are displayed.

What Changed

  • Automatic Switch on Connect (speaktype/Services/AudioRecordingService.swift):
    • Listens to AVCaptureDevice.wasConnectedNotification and automatically switches selectedDeviceId to the newly connected microphone (ignoring virtual Microsoft Teams devices).
    • Reconfigures AVCaptureSession inputs in-place on audioQueue using beginConfiguration() / commitConfiguration() when a session already exists, so switching microphones while pre-warmed or mid-recording preserves the running session and clock without dropping audio.
    • Guards selectedDeviceId.didSet against redundant assignments.
  • Direct Stacked Two-Arrow Switcher in Menu Bar (speaktype/Views/Components/MenuBarDashboardView.swift):
    • Adds microphoneSwitcherSection directly below the statistics grid in the menu bar popover.
    • Displays the active microphone name and a stacked two-arrow button (arrow.left.arrow.right) that immediately switches/cycles through connected microphones on click without opening the dashboard.
  • Documentation & Tests:
    • Updated CHANGELOG.md and the helper note in AudioInputView.swift.
    • Added deterministic unit tests in speaktypeTests/AudioRecordingServiceTests.swift covering 0, 1, 2, and 3+ device cycling and wrap-around.

Why this is needed:
- Previously, when connecting a secondary microphone (e.g., Bluetooth headset or external USB mic alongside the built-in laptop microphone), SpeakType stayed pinned to the previously selected microphone and required opening the full Dashboard -> Audio Input settings to switch inputs.
- Users who frequently connect external microphones or switch between multiple connected inputs needed a zero-friction way to switch devices directly from the top macOS menu bar popover and have newly connected microphones become active automatically.

Changes:
- Auto-switch to newly connected audio input devices via AVCaptureDevice.wasConnectedNotification in AudioRecordingService (while ignoring virtual Teams audio devices).
- Reconfigure AVCaptureSession input in-place on audioQueue when switching devices so active/pre-warmed sessions preserve their running state and session clock without interruption.
- Add cycleDevice(step:), nextCycledDeviceId(from:currentDeviceId:step:), and selectedDeviceName helpers to AudioRecordingService.
- Add a Microphone section to MenuBarDashboardView displaying the active microphone and a direct stacked two-arrow switch button (arrow.left.arrow.right) when multiple microphones are connected.
- Document in CHANGELOG.md and AudioInputView, and add unit tests in AudioRecordingServiceTests.
feat(macos): add menu bar microphone switcher and auto-switch on connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant