Skip to content

Commit

Permalink
Add blackhole audiodevice for macOS Big sur, add sox and Switchaudio-…
Browse files Browse the repository at this point in the history
…osx versions to the docs (#3542)
  • Loading branch information
miketimofeev authored Jun 8, 2021
1 parent 2ae7ebd commit 4da3c8e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 8 deletions.
11 changes: 11 additions & 0 deletions images/macos/helpers/SoftwareReport.Helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ function Get-PathWithLink {
$link = Get-LinkTarget($inputPath)
return "${inputPath}${link}"
}

function Get-BrewPackageVersion {
param (
[string] $CommandName
)

(Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?<version>(\d+.){2}\d+)" | Out-Null
$packageVersion = $Matches.Version

return $packageVersion
}
23 changes: 17 additions & 6 deletions images/macos/provision/core/audiodevice.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#!/bin/bash -e -o pipefail
source ~/utils/utils.sh

echo "install soundflower"
brew install --cask soundflower

echo "install switchaudio-osx"
brew_smart_install "switchaudio-osx"

echo "install sox"
brew_smart_install "sox"

echo "set Soundflower (2ch) as input/output device"
SwitchAudioSource -s "Soundflower (2ch)" -t input
SwitchAudioSource -s "Soundflower (2ch)" -t output
# Big Sur doesn't support soundflower installation without user interaction https://github.com/mattingalls/Soundflower/releases/tag/2.0b2
# Install blackhole-2ch for Big Sur instead
if is_Less_BigSur; then
echo "install soundflower"
brew install --cask soundflower

echo "set Soundflower (2ch) as input/output device"
SwitchAudioSource -s "Soundflower (2ch)" -t input
SwitchAudioSource -s "Soundflower (2ch)" -t output
else
echo "install blackhole-2ch"
brew_smart_install "blackhole-2ch"

echo "set BlackHole 2ch as input/output device"
SwitchAudioSource -s "BlackHole 2ch" -t input
SwitchAudioSource -s "BlackHole 2ch" -t output
fi

invoke_tests "System" "Audio Device"
10 changes: 10 additions & 0 deletions images/macos/software-report/SoftwareReport.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,16 @@ function Get-CabalVersion {
return "Cabal $cabalVersion"
}

function Get-SwitchAudioOsxVersion {
$switchAudioVersion = Get-BrewPackageVersion -CommandName "SwitchAudioSource"
return "Switchaudio-osx $switchAudioVersion"
}

function Get-SoxVersion {
$soxVersion = Get-BrewPackageVersion -CommandName "sox"
return "Sox $soxVersion"
}

function Get-StackVersion {
$stackVersion = Run-Command "stack --version" | Take-Part -Part 1 | ForEach-Object {$_.replace(",","")}
return "Stack $stackVersion"
Expand Down
7 changes: 7 additions & 0 deletions images/macos/software-report/SoftwareReport.Generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ if ($os.IsLessThanBigSur) {
)
}

if (-not $os.IsHighSierra) {
$utilitiesList += @(
(Get-SwitchAudioOsxVersion),
(Get-SoxVersion)
)
}

$markdown += New-MDList -Style Unordered -Lines ($utilitiesList | Sort-Object)
$markdown += New-MDNewLine

Expand Down
1 change: 1 addition & 0 deletions images/macos/templates/macOS-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"./provision/core/nginx.sh",
"./provision/core/postgresql.sh",
"./provision/core/mongodb.sh",
"./provision/core/audiodevice.sh",
"./provision/core/vcpkg.sh",
"./provision/core/miniconda.sh",
"./provision/core/chrome.sh",
Expand Down
8 changes: 6 additions & 2 deletions images/macos/tests/System.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Describe "Certificate" {
}
}

Describe "Audio device" -Skip:($os.IsHighSierra -or $os.IsBigSur) {
Describe "Audio device" -Skip:($os.IsHighSierra) {
It "Sox is installed" {
"sox --version" | Should -ReturnZeroExitCode
}
Expand All @@ -26,9 +26,13 @@ Describe "Audio device" -Skip:($os.IsHighSierra -or $os.IsBigSur) {
"SwitchAudioSource -c" | Should -ReturnZeroExitCode
}

It "Audio channel Soundflower (2ch)" {
It "Audio channel Soundflower (2ch)" -Skip:($os.IsBigSur) {
SwitchAudioSource -c | Should -BeLikeExactly "Soundflower (2ch)"
}

It "Audio channel BlackHole 2ch" -Skip:($os.IsLessThanBigSur) {
SwitchAudioSource -c | Should -BeLikeExactly "BlackHole 2ch"
}
}

Describe "Screen Resolution" -Skip:($os.IsHighSierra) {
Expand Down

0 comments on commit 4da3c8e

Please sign in to comment.