Skip to content

Commit

Permalink
additional blackhole drivers
Browse files Browse the repository at this point in the history
playback via mpv – sox may not see devices due to some bug
  • Loading branch information
AlexanderPavlenko committed Nov 7, 2021
1 parent 5207649 commit d7539d2
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 27 deletions.
5 changes: 3 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
brew "overmind"
brew "sox"
cask "blackhole-16ch"
cask "blackhole-2ch"
brew "mpv"
# cask "blackhole-16ch"
# cask "blackhole-2ch"
78 changes: 67 additions & 11 deletions Brewfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/overmind/blobs/sha256:1d59fd1eadd4029ec88ef668d7eeaf790c3db3137a9e5dafa7948ccd684c4dc2",
"sha256": "1d59fd1eadd4029ec88ef668d7eeaf790c3db3137a9e5dafa7948ccd684c4dc2"
},
"arm64_big_sur": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/overmind/blobs/sha256:00af66eeee076ae3bccba58a690dc73f908b6af7ea0bfebf1fc6b81c5a88c445",
"sha256": "00af66eeee076ae3bccba58a690dc73f908b6af7ea0bfebf1fc6b81c5a88c445"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/overmind/blobs/sha256:9fbe36f34b548c9945aa64d3ff72bfd7e1398be8f06dc12392e25de3ac0e0988",
"sha256": "9fbe36f34b548c9945aa64d3ff72bfd7e1398be8f06dc12392e25de3ac0e0988"
},
"big_sur": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/overmind/blobs/sha256:f0a2458bfe0cbe0a38ca8579b774e45262f68bf8a9f9d1d2ff70a9c388c21446",
Expand Down Expand Up @@ -41,11 +51,21 @@
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_monterey": {
"cellar": ":any",
"url": "https://ghcr.io/v2/homebrew/core/sox/blobs/sha256:f006a58fcfffdff435bcdf79c10249b1ad979cd82a64a99d081b651ca4ea70a7",
"sha256": "f006a58fcfffdff435bcdf79c10249b1ad979cd82a64a99d081b651ca4ea70a7"
},
"arm64_big_sur": {
"cellar": ":any",
"url": "https://ghcr.io/v2/homebrew/core/sox/blobs/sha256:8070949420a9a02f3d5e1a99bd460d064e34c361798bae5c4554ac8e1aeb2d49",
"sha256": "8070949420a9a02f3d5e1a99bd460d064e34c361798bae5c4554ac8e1aeb2d49"
},
"monterey": {
"cellar": ":any",
"url": "https://ghcr.io/v2/homebrew/core/sox/blobs/sha256:9384cdaee989d5ec7ffcf1585b81a2197d7d8ce68cc0c4134c56b204099f6b32",
"sha256": "9384cdaee989d5ec7ffcf1585b81a2197d7d8ce68cc0c4134c56b204099f6b32"
},
"big_sur": {
"cellar": ":any",
"url": "https://ghcr.io/v2/homebrew/core/sox/blobs/sha256:e3f62a35b06c9e79516f575a923b3aafc5357f370f4ae5c2812c67c8862ae11c",
Expand Down Expand Up @@ -78,26 +98,62 @@
}
}
}
}
},
"cask": {
"blackhole-16ch": {
"version": "0.2.10",
"options": {
"full_name": "blackhole-16ch"
},
"mpv": {
"version": "0.33.1",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_monterey": {
"cellar": "/opt/homebrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:c3ef442c5e83fd6540a01fc6376c5cade89b7bd5f07abf7811f1a06fdc664d81",
"sha256": "c3ef442c5e83fd6540a01fc6376c5cade89b7bd5f07abf7811f1a06fdc664d81"
},
"arm64_big_sur": {
"cellar": "/opt/homebrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:dd487a80e5586c93ccde6942170d026e9eba5b403d95e409ad55282cea818790",
"sha256": "dd487a80e5586c93ccde6942170d026e9eba5b403d95e409ad55282cea818790"
},
"monterey": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:48cff8a1e5ce3e63982e586a114d3ebee3d689e8bd5b23ad1db78323c1e088b0",
"sha256": "48cff8a1e5ce3e63982e586a114d3ebee3d689e8bd5b23ad1db78323c1e088b0"
},
"big_sur": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:76b0fc9d207aee16f65b8b1782bc35dec5a870952ebba6ae7a74e6ede9bdd34a",
"sha256": "76b0fc9d207aee16f65b8b1782bc35dec5a870952ebba6ae7a74e6ede9bdd34a"
},
"catalina": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:8ab98fffc330dea03f2732fa17c7f53753601c49c3f9dec2a7d727bdc901c484",
"sha256": "8ab98fffc330dea03f2732fa17c7f53753601c49c3f9dec2a7d727bdc901c484"
},
"mojave": {
"cellar": "/usr/local/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:87df95e8f4f723a5b6fe163d5ac740fef9f5ffa9c318c82c9a6b0844aa7203b9",
"sha256": "87df95e8f4f723a5b6fe163d5ac740fef9f5ffa9c318c82c9a6b0844aa7203b9"
},
"x86_64_linux": {
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/mpv/blobs/sha256:6a037de38402f73783c5b403e6aada7388373eda6593b21e43844043cf6496d6",
"sha256": "6a037de38402f73783c5b403e6aada7388373eda6593b21e43844043cf6496d6"
}
}
}
}
}
},
"system": {
"macos": {
"big_sur": {
"HOMEBREW_VERSION": "3.2.17-63-g5a5a8d5",
"HOMEBREW_VERSION": "3.3.2-64-gcb24983",
"HOMEBREW_PREFIX": "/opt/homebrew",
"Homebrew/homebrew-core": "df940f25efdeaec9913a76c9119e6cb44b7632cf",
"Homebrew/homebrew-core": "549b4d59ef5ad82918a323313f9db3bb8dbb84a4",
"CLT": "12.5.0.22.9",
"Xcode": "13.0",
"macOS": "11.6"
"Xcode": "13.1",
"macOS": "11.6.1"
}
}
}
Expand Down
11 changes: 2 additions & 9 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
host: PI_IP=apaw.local; sleep 3; sox -V1 --type coreaudio "BlackHole 16ch" --type raw --rate 44100 --encoding signed-integer --bits 24 --channels 2 - remix 1 2 | nc $PI_IP 2150 | sox -V1 --type raw --rate 44100 --encoding signed-integer --bits 24 --channels 2 - --type coreaudio "BlackHole 2ch"
pi: ssh -S none root@pi 'killall -v -s SIGKILL nc arecord aplay; nice -n -20 arecord --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type raw --device hw:CARD=UAC2Gadget,DEV=0 --buffer-time 75000 - | nice -n -20 nc -l 2150 -k | nice -n -20 aplay --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type raw --device hw:CARD=UAC2Gadget,DEV=0 --buffer-time 75000 -'

# an attempt of monitoring via HDMI output
# fixme: still too much latency...
#pi: ssh -S none root@pi 'killall -v -s SIGKILL nc arecord aplay; nice -n -20 arecord --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type raw --device hw:CARD=UAC2Gadget,DEV=0 - | nice -n -20 stdbuf -i0 -o0 -e0 tee >(nice -n -19 nc -l 2150 -k | nice -n -19 aplay --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type raw --device hw:CARD=UAC2Gadget,DEV=0 -) >(nice -n -20 stdbuf -i0 -o0 -e0 aplay --verbose --disable-resample --disable-channels --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type raw --device plughw:CARD=b1,DEV=0 --buffer-time 50000 -) > /dev/null'

# fixme: why sshd suddenly exits?
#ipad: trap 'ssh ipad "killall cat socat"' EXIT > /dev/null; ssh ipad ./pi-socat.sh
host: PI_IP=apaw.local; sleep 5; sox -V1 --type coreaudio "RpIn" --type wav --rate 44100 --encoding signed-integer --bits 24 --channels 2 - | nc $PI_IP 2150 | mpv --no-config --audio-device=coreaudio/RpOut_UID --profile=low-latency -
pi: ssh -S none root@pi 'killall -v -s SIGKILL nc arecord aplay; nice -n -20 arecord --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type wav --device hw:CARD=UAC2Gadget,DEV=0 --buffer-time 100000 - | nice -n -20 nc -l 2150 | nice -n -20 aplay --verbose --disable-resample --disable-channels --disable-format --disable-softvol --mmap --nonblock --rate 44100 --format S24_3LE --channels 2 --file-type wav --device hw:CARD=UAC2Gadget,DEV=0 --buffer-time 100000 -'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ pass: raspberry

# after deploy.sh change cmdline.txt: modules-load=dwc2,libcomposite
```

`RpIn` and `RpOut` are [BlackHole Drivers](https://github.com/ExistentialAudio/BlackHole/wiki/Running-Multiple-BlackHole-Drivers).
7 changes: 4 additions & 3 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/zsh

scp rc.local root@pi:/etc/rc.local
scp usb.sh root@pi:/root/usb.sh
ssh root@pi reboot
PI=root@pi
scp rc.local $PI:/etc/rc.local
scp usb.sh $PI:/root/usb.sh
ssh $PI reboot
4 changes: 2 additions & 2 deletions iSH-socat.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# run via https://ish.app
cat /dev/location > /dev/null & # granting "allow always" enables running in background
socat TCP-LISTEN:2122,bind=0.0.0.0,fork,su=nobody,reuseaddr TCP:169.254.1.1:22 &
socat TCP-LISTEN:2150,bind=0.0.0.0,fork,su=nobody,reuseaddr TCP:169.254.1.1:2150
socat TCP-LISTEN:2122,bind=0.0.0.0,fork,su=nobody,reuseaddr,nodelay TCP:169.254.1.1:22,nodelay &
socat TCP-LISTEN:2150,bind=0.0.0.0,fork,su=nobody,reuseaddr,nodelay TCP:169.254.1.1:2150,nodelay &
8 changes: 8 additions & 0 deletions usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@ echo "ECM + UAC2" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower

# Ethernet
# https://www.kernel.org/doc/html/latest/usb/gadget-testing.html#ecm-function
mkdir -p functions/ecm.usb0
# first byte of address must be even
echo "48:6f:73:74:50:43" > functions/ecm.usb0/host_addr
echo "42:61:64:55:53:42" > functions/ecm.usb0/dev_addr
ln -s functions/ecm.usb0 configs/c.1/

# UAC2 audio
# https://www.kernel.org/doc/html/latest/usb/gadget-testing.html#uac2-function
mkdir -p functions/uac2.usb0
echo 3 > functions/uac2.usb0/c_ssize
echo 3 > functions/uac2.usb0/p_ssize
echo 44100 > functions/uac2.usb0/c_srate
echo 44100 > functions/uac2.usb0/p_srate
echo 3 > functions/uac2.usb1/с_chmask
echo 3 > functions/uac2.usb1/p_chmask
# todo: capture more channels via the Raspberry Pi Zero 2
# USB Device Class Definition for Audio Devices: 4.1 Audio Channel Cluster Descriptor
# "110011".to_i(2) = 51
#echo 51 > functions/uac2.usb0/c_chmask
ln -s functions/uac2.usb0 configs/c.1/

# End functions
Expand Down

0 comments on commit d7539d2

Please sign in to comment.