106 lines
2.8 KiB
Bash
Executable File
106 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test recording script using drecord to capture from DEP shared memory
|
|
# Records for 10 seconds and saves to recordings directory
|
|
|
|
DRECORD_PATH="/home/caster/dante_beacon/dep_examples-1.2.2.1_aarch64_Linux/dep_examples/apps/drecord"
|
|
OUTPUT_DIR="./recordings"
|
|
DURATION=10 # seconds
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
OUTPUT_FILE="${OUTPUT_DIR}/dante_drecord_${TIMESTAMP}.wav"
|
|
|
|
# Create output directory
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
echo "=========================================="
|
|
echo "Dante DEP drecord Test"
|
|
echo "=========================================="
|
|
echo "Recording from DEP shared memory"
|
|
echo "Duration: $DURATION seconds"
|
|
echo "Output file: $OUTPUT_FILE"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Check if drecord exists
|
|
if [ ! -f "$DRECORD_PATH" ]; then
|
|
echo "ERROR: drecord not found at $DRECORD_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if drecord is executable
|
|
if [ ! -x "$DRECORD_PATH" ]; then
|
|
echo "Making drecord executable..."
|
|
chmod +x "$DRECORD_PATH"
|
|
fi
|
|
|
|
# Check if DEP is running
|
|
if ! pgrep -f "dep_manager" > /dev/null; then
|
|
echo "WARNING: DEP does not appear to be running!"
|
|
echo "Start DEP first: cd /home/caster/dante_beacon && sudo bash dep.sh start"
|
|
echo ""
|
|
read -p "Continue anyway? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "Starting drecord..."
|
|
echo ""
|
|
|
|
# Start drecord in background
|
|
"$DRECORD_PATH" -o "$OUTPUT_FILE" &
|
|
DRECORD_PID=$!
|
|
|
|
echo "Recording started (PID: $DRECORD_PID)"
|
|
echo "Recording for $DURATION seconds..."
|
|
echo ""
|
|
|
|
# Show progress
|
|
for i in $(seq $DURATION -1 1); do
|
|
echo -ne "Time remaining: $i seconds\r"
|
|
sleep 1
|
|
done
|
|
echo -ne "\n"
|
|
|
|
# Stop drecord gracefully with SIGINT (Ctrl+C)
|
|
echo "Stopping recording..."
|
|
kill -INT $DRECORD_PID 2>/dev/null
|
|
|
|
# Wait for drecord to finish writing the WAV header
|
|
echo "Waiting for drecord to finalize WAV file..."
|
|
sleep 2
|
|
wait $DRECORD_PID 2>/dev/null
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Recording complete!"
|
|
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 analyze with sox:"
|
|
echo " sox $OUTPUT_FILE -n stat"
|
|
else
|
|
echo "ERROR: Recording file was not created!"
|
|
echo "Check if DEP is running and receiving Dante audio."
|
|
fi
|
|
|
|
echo ""
|
|
echo "=========================================="
|