8cd796e3dd
- USB gadget (UAC1 + MIDI) with boot persistence - USB host mode with auto-detection - Pure Data synth patch with ALSA + UDP netreceive MIDI input - MIDI rawmidi-to-UDP bridge (midi-bridge.py) - LED matrix visualization (led-matrix-viz.py via arduino-router RPC) - MCU sketch for LED matrix control (Arduino_RouterBridge + ArduinoGraphics) - Conftest/OPA Rego policy validation suite for .pd files - gen_synth_pd.py: programmatic .pd file generator - System services: midi-bridge, led-matrix-viz, pd-synth-auto, usb-role-detect - Justfile with deploy, enable, diagnostic recipes - Diagnostic script (diag.sh)
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# detect-i2s-device.sh — Probe for available I2S audio devices
|
|
# and create /run/i2s-audio-dev containing the best candidate.
|
|
# Called by detect-i2s-device.service before pd-synth-i2s starts.
|
|
|
|
set -euo pipefail
|
|
|
|
DEVICE_FILE="/run/i2s-audio-dev"
|
|
write_dev() { echo "$1" > "$DEVICE_FILE"; echo "[DETECT] I2S device: $1"; exit 0; }
|
|
|
|
# Try named I2S devices first (most reliable)
|
|
for dev in "hw:I2S,0" "hw:MI2S,0" "hw:i2s,0" "hw:mi2s,0"; do
|
|
if aplay -l 2>/dev/null | grep -qi "${dev%,*}"; then
|
|
write_dev "$dev"
|
|
fi
|
|
done
|
|
|
|
# Try probing ALSA device list for anything that looks like I2S
|
|
while read -r card; do
|
|
id=$(echo "$card" | awk '{print $2}' | tr -d ':')
|
|
name=$(echo "$card" | cut -d: -f2- | xargs)
|
|
if echo "$name" | grep -qi -E "(i2s|mi2s|quat|tert|dac|audio)"; then
|
|
write_dev "hw:$id,0"
|
|
fi
|
|
done < <(cat /proc/asound/cards 2>/dev/null || true)
|
|
|
|
# Fallback to hw:0,0 (first audio device, may be HDMI or analog)
|
|
if aplay -l 2>/dev/null | grep -q "^card 0"; then
|
|
write_dev "hw:0,0"
|
|
fi
|
|
|
|
# Nothing found
|
|
echo "[DETECT] No I2S audio device found" >&2
|
|
echo "" > "$DEVICE_FILE"
|
|
exit 1
|