Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the audio in blf-logger-with-audio only if the mat and the wav files have been created #693

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions devices/YarpRobotLoggerDevice/scripts/blf-logger-with-audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@ input_port_audio=$1

# Function to handle SIGINT signal
function handle_sigint {
echo "Received SIGINT signal. Forwarding to background programs..."
# Forward SIGINT to the background program
kill -SIGINT $bg_pid1 $bg_pid2
echo "Received SIGINT signal. Forwarding to background programs..."
# Forward SIGINT to the background program
kill -SIGINT $bg_pid1 $bg_pid2
}

function handle_exit {
echo "Renaming the audio"

# get the latest matfile name
latest_file=$(find . -maxdepth 1 -type f -name "*.mat" -printf "%T@ %f\n" | sort -nr | head -n 1 | awk '{print $2}' | sed 's/\.mat$//')
mv audio_out.wav $latest_file.wav
echo "Loking fro the audio file. It may take a while."
until [ -f audio_out.wav ]
do
sleep 5
done

echo "Closing"
echo "Renaming the audio"

exit
# get the latest matfile name
latest_file=$(find . -maxdepth 1 -type f -name "*.mat" -printf "%T@ %f\n" | sort -nr | head -n 1 | awk '{print $2}' | sed 's/\.mat$//')
mv audio_out.wav $latest_file.wav

echo "Closing"

exit
}

# launch the audio device recorder
Expand Down