Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ public struct USBChannelShortfall: Equatable, Sendable {
if let offered = offeredChannelCount, offered > usbChannelCount {
return USBChannelShortfall(usbChannelCount: usbChannelCount, reason: .systemGrantedFewer(offered: offered))
}
if let mixer, let mixerSends = capabilities?.usbChannelCount, mixerSends > usbChannelCount {
// A 1- or 2-channel input (the device's microphone, a stereo interface) isn't the Mixer's USB: recording it
// with the Mixer linked over Wi-Fi for names is on purpose, so no warning.
if usbChannelCount > Self.notTheMixerUpTo, let mixer, let mixerSends = capabilities?.usbChannelCount, mixerSends > usbChannelCount {
return USBChannelShortfall(usbChannelCount: usbChannelCount, reason: .mixerSendsMore(mixer: mixer, mixerSends: mixerSends))
}
return nil
}

/// Inputs with this many channels or fewer are never taken for the Mixer's USB.
static let notTheMixerUpTo = 2

/// The banner text. It names a Mixer only when one was identified.
public var message: String {
let sent = usbChannelCount == 1 ? "1 USB Channel" : "\(usbChannelCount) USB Channels"
Expand All @@ -49,8 +54,7 @@ public struct USBChannelShortfall: Equatable, Sendable {
return "This input offers \(offered) channels, but the system is sending the recorder \(sent), so some channels won't be recorded."
case .mixerSendsMore(let mixer, let mixerSends):
// Short enough for the banner's 2 lines on an iPhone (#292); the Mixer chip already names the Mixer.
let verb = usbChannelCount == 1 ? "is" : "are"
return "Only \(usbChannelCount) of the \(mixer.model)'s \(mixerSends) USB Channels \(verb) coming in. Arm the \(mixer.model) to record all \(mixerSends)."
return "Only \(usbChannelCount) of the \(mixer.model)'s \(mixerSends) USB Channels are coming in. Arm the \(mixer.model) to record all \(mixerSends)."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ struct USBChannelShortfallTests {
#expect(USBChannelShortfall.check(usbChannelCount: count, offeredChannelCount: nil, mixer: nil, capabilities: nil) == nil)
}

@Test("A device sending fewer USB Channels than the identified Mixer sends is a shortfall that names the Mixer, short enough for 2 lines on an iPhone (#292)", arguments: [1, 8, 16])
@Test("A device sending fewer USB Channels than the identified Mixer sends is a shortfall that names the Mixer, short enough for 2 lines on an iPhone (#292)", arguments: [3, 8, 16])
func fewerThanIdentifiedMixer(count: Int) throws {
let shortfall = try #require(USBChannelShortfall.check(
usbChannelCount: count, offeredChannelCount: nil, mixer: xr18, capabilities: xr18Capabilities))

let verb = count == 1 ? "is" : "are"
#expect(shortfall.message == "Only \(count) of the XR18's 18 USB Channels \(verb) coming in. Arm the XR18 to record all 18.")
#expect(shortfall.message == "Only \(count) of the XR18's 18 USB Channels are coming in. Arm the XR18 to record all 18.")
#expect(shortfall.message.count <= 90)
}

@Test("A 1- or 2-channel input (the iPhone's microphone, a stereo interface) with the Mixer linked over Wi-Fi is on purpose: no warning", arguments: [1, 2])
func micWithLinkedMixer(count: Int) {
#expect(USBChannelShortfall.check(usbChannelCount: count, offeredChannelCount: nil, mixer: xr18, capabilities: xr18Capabilities) == nil)
}

@Test("A device sending at least what the identified Mixer sends is fine", arguments: [18, 32])
func enoughForIdentifiedMixer(count: Int) {
#expect(USBChannelShortfall.check(usbChannelCount: count, offeredChannelCount: nil, mixer: xr18, capabilities: xr18Capabilities) == nil)
Expand Down
Loading