Files
dante_beacon/test_dsoundcard.sh
2025-12-12 16:27:31 +01:00

93 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Test recording script using dsoundcard ALSA plugin
# This plugin bridges DEP audio without requiring hardware clocking
OUTPUT_DIR="./recordings"
DURATION=10 # seconds
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
OUTPUT_FILE="${OUTPUT_DIR}/dsoundcard_${TIMESTAMP}.wav"
# Create output directory
mkdir -p "$OUTPUT_DIR"
echo "=========================================="
echo "DEP dsoundcard ALSA Plugin Test"
echo "=========================================="
echo "Recording from DEP via dsoundcard plugin"
echo "Duration: $DURATION seconds"
echo "Output file: $OUTPUT_FILE"
echo "=========================================="
echo ""
# Check if DEP is running
if ! pgrep -f "dep_manager" > /dev/null; then
echo "ERROR: DEP is not running!"
echo "Start DEP first: cd /home/caster/dante_beacon && sudo bash dep.sh start"
exit 1
fi
# Check if dsoundcard is available
if ! aplay -L | grep -q "dsoundcard"; then
echo "ERROR: dsoundcard ALSA plugin not found!"
echo "Make sure dsoundcard.so is installed in /opt/dep/"
echo "And ~/.asoundrc is configured correctly"
exit 1
fi
echo "Starting recording..."
echo ""
# Record with larger buffer to avoid overruns
# -D: ALSA device
# -c: channels (6 for DEP RX)
# -f: format (S16_LE = 16-bit signed little endian)
# -r: sample rate (48000 Hz)
# -d: duration
# --buffer-size: larger buffer to prevent overruns
arecord -D dsoundcard -c 6 -f S16_LE -r 48000 -d $DURATION --buffer-size=4096 "$OUTPUT_FILE"
RECORD_EXIT=$?
echo ""
echo "=========================================="
if [ $RECORD_EXIT -eq 0 ]; then
echo "Recording complete!"
else
echo "Recording completed with warnings"
fi
echo "=========================================="
# Check if file was created
if [ -f "$OUTPUT_FILE" ]; then
FILE_SIZE=$(ls -lh "$OUTPUT_FILE" | awk '{print $5}')
echo "Output file: $OUTPUT_FILE"
echo "File size: $FILE_SIZE"
echo ""
# Try to get audio info if sox is available
if command -v sox &> /dev/null; then
echo "Audio file info:"
sox "$OUTPUT_FILE" -n stat 2>&1 | grep -E "Sample Rate|Channels|Duration|Length|Maximum amplitude|RMS"
fi
echo ""
echo "To play the recording:"
echo " aplay $OUTPUT_FILE"
echo ""
echo "To split into individual channels:"
echo " for i in {1..6}; do"
echo " sox $OUTPUT_FILE ${OUTPUT_FILE%.wav}_ch\$i.wav remix \$i"
echo " done"
else
echo "ERROR: Recording file was not created!"
fi
echo ""
echo "=========================================="
echo ""
echo "NOTE: The dsoundcard plugin provides direct access to DEP"
echo "audio buffers without requiring hardware clock synchronization."
echo "This is the recommended method for ALSA integration with DEP."
echo ""