Skip to content

Commit 9bda7c0

Browse files
LTLT
authored andcommitted
Don't divide by zero for single output device
1 parent d18ce0d commit 9bda7c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

DynamicsIllusion/VolumeViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class VolumeViewController: NSViewController, NSTableViewDataSource {
2525
let balanceMax = (balance < 50.0) ? 100.0 - balance : balance,
2626
balanceLeft = (100.0 - balance) / balanceMax,
2727
balanceRight = balance / balanceMax,
28-
count = selectedDevices!.count,
28+
deviceCount = selectedDevices!.count,
29+
count = (deviceCount == 1) ? 1 : deviceCount - 1,
2930
balanceDelta = balanceRight - balanceLeft
3031

3132
for (index, device) in selectedDevices!.enumerated() {
32-
let bal = balanceLeft + balanceDelta * Float(index) / Float(count - 1)
33+
let bal = balanceLeft + balanceDelta * Float(index) / Float(count)
3334
Audio.setDeviceVolume(deviceID: device, leftChannelLevel: bal * value, rightChannelLevel: bal * value)
3435
}
3536
}

0 commit comments

Comments
 (0)