You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
preserve speech from multi-channel microphones and audio interfaces instead of relying on Core Audio's broken implicit downmix
let users select and persist the physical input channel for multi-channel interfaces, keeping capture stable if loopback or another input is louder
invalidate that channel mapping when the active device UID or channel topology changes, falling back safely to channel 1
bind the input tap to the hardware format that is live after USB or Bluetooth route setup
make the silence timer explicitly track continuous silence and restart its full countdown whenever speech resumes
replace the 0.5 to 5 second slider with a custom field that accepts 0.5 to 300 seconds
Root cause
VocaMac converted the microphone buffer directly from the device format to mono. On macOS, that conversion reads only channel 0 for stereo input and can return an all-zero buffer for devices with more than two channels. The reported EVO4 route opened as 44.1 kHz with four channels, so its input was converted to silence.
Because no buffer crossed the speech threshold, the silence timestamp never moved. The configured silence duration then behaved like a maximum recording duration, and the final zero-sample check reported that the microphone was unavailable even though Core Audio was delivering buffers.
Multi-channel buffers are now reduced to the user-selected physical channel before sample-rate conversion. The selection remains fixed for the entire recording so a louder loopback or secondary input cannot replace the microphone.
The saved index is tied to the interface UID and channel count. Both settings and the audio engine revalidate that mapping, including after an in-progress route restart, so a system-default device change or interface mode change cannot reuse a stale channel.
The permissions reset in the supplied log separately explains the temporary Accessibility and Input Monitoring failure. Those permissions recovered before the repeated zero-audio captures.
Testing
swift test --filter AudioEngineTests (14 tests, 0 failures)
swift test --filter AppStateRecordingTests (37 tests, 0 failures)
swift test (442 tests, 1 expected hardware-dependent skip, 0 failures)
swift build
added deterministic coverage for selected-channel conversion on four-channel input, competing loopback input, stale device/layout mappings, invalid-index fallback, selection forwarding, silence countdown reset after speech, live tap format selection, and custom duration bounds
This PR fixes multi-channel microphone capture by persisting a physical input-channel selection, validating it against the live device identity and topology, and extracting that channel before sample-rate conversion. It also resets silence timing after speech and expands the configurable silence duration.
Centralizes silence-duration defaults and validation bounds.
Tests/VocaMacTests/ServiceTests.swift
Adds regression coverage for fixed-channel capture, stale mappings, live tap format, conversion, and silence countdown reset.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Saved device UID, channel count, and channel] --> B[Recording startup or route restart]
B --> C{Mapping matches live UID and topology?}
C -- Yes --> D[Use selected physical channel]
C -- No --> E[Fall back to channel 1]
D --> F[Extract mono buffer]
E --> F
F --> G[Convert to 16 kHz Float32]
G --> H[Speech and silence detection]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
VocaMac converted the microphone buffer directly from the device format to mono. On macOS, that conversion reads only channel 0 for stereo input and can return an all-zero buffer for devices with more than two channels. The reported EVO4 route opened as 44.1 kHz with four channels, so its input was converted to silence.
Because no buffer crossed the speech threshold, the silence timestamp never moved. The configured silence duration then behaved like a maximum recording duration, and the final zero-sample check reported that the microphone was unavailable even though Core Audio was delivering buffers.
Multi-channel buffers are now reduced to the user-selected physical channel before sample-rate conversion. The selection remains fixed for the entire recording so a louder loopback or secondary input cannot replace the microphone.
The saved index is tied to the interface UID and channel count. Both settings and the audio engine revalidate that mapping, including after an in-progress route restart, so a system-default device change or interface mode change cannot reuse a stale channel.
The permissions reset in the supplied log separately explains the temporary Accessibility and Input Monitoring failure. Those permissions recovered before the repeated zero-audio captures.
Testing
swift test --filter AudioEngineTests(14 tests, 0 failures)swift test --filter AppStateRecordingTests(37 tests, 0 failures)swift test(442 tests, 1 expected hardware-dependent skip, 0 failures)swift build