Commit af776aea authored by Arnaud Blanchard's avatar Arnaud Blanchard

blaar_module.sh is in blaar.sh, o_speaker in o_sound

parent d9b0a8d0
......@@ -21,6 +21,30 @@ calc(){
echo $(echo "$@"|bc -l)
}
test_run() {
"$@" || {
echo executing: "$@"
exit $?
}
}
blaar_module(){
usage(){
echo
echo "Try to execute <executable> otherwise explain you need the module <module>"
echo "usage: blaar_module <module> <executable>"
echo
}
[ $# -lt 2 ] && { echo "You need at least 2 arguments but you have $#:'$*'"; usage; exit 1; }
hash $2 2>/dev/null || { echo "You need to install https://gitlab.blaar.org/$1"; exit 2; }
shift
test_run "$@"
}
blaar_add_option(){
(( $# < 5 )) && { echo "Wrong arguments number with add_option. You use '$#' instead of 5 or 6 with '$*'"; exit 1; }
(( $# > 6 )) && { echo "Wrong arguments number with add_option. You use '$#' instead of 5 or 6 with '$*'"; exit 1; }
......@@ -113,3 +137,6 @@ blaar_parse_args(){
done
return 0
}
blaar_program_name=$(basename $0)
#Use your $PATH to find bash
#!/usr/bin/env bash
# Basic Libraries And Applications for Robotics (BLAAR)
# Copyright ETIS — ENSEA, University of Cergy-Pontoise, CNRS (2011 - 2017)
# Author: Arnaud Blanchard
#
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
set -o errexit #Exit on first error
set -o nounset #Error if a variable is used but not defined
set -o pipefail #Error if a pipe fail
usage(){
echo
echo "Try to execute <executable> otherwise explain you need the module <module>"
echo "usage: blaar_module <module> <executable>"
echo
}
test_run() {
"$@" || {
echo executing: $@
exit $?
}
}
[ $# -lt 2 ] && { echo "You need at least 2 arguments but you have $#:'$*'"; usage; exit 1; }
hash $2 2>/dev/null || { echo "You need to install https://gitlab.blaar.org/$1"; exit 2; }
shift
test_run "$@"
......@@ -24,7 +24,7 @@ blaar_init_options "Acquire the sound from microphone or sound file (-f filename
blaar_add_option device D "" "device_name" "device to use for the microphone"
blaar_add_option filename f "" "filename" "file to load the sound from"
blaar_add_option output o "" "blc_channel|-" "output on blc_channel or stdout(-)"
blaar_add_option size s "" "integer" "number of itmes per sample" "4096"
blaar_add_option size s "" "integer" "number of items per buffer" "4096"
blaar_add_option samplerate S "" "integer" "Samplerate of the sound acquisition" "44100"
blaar_parse_args "$@"
......@@ -34,17 +34,17 @@ blaar_parse_args "$@"
if [ $filename ]; then
echo "Loading '$filename" >&2
[ $device ] && { echo "You cannot have file (-f) and microphone (-D) at the same time"; exit 1; }
blaar_module.sh sndfile i_sndfile --file=$filename --size=$size --samplerate=$samplerate $output_option
blaar_module sndfile i_sndfile --file=$filename --size=$size --samplerate=$samplerate $output_option
elif [ $(uname) = "Darwin" ]; then #microphone
echo "Darwin microphone" >&2
echo "Coreaudio microphone" >&2
[ $device ] && echo "On Darwin you cannot precise microphone (-D)"
blaar_module.sh coreaudio i_coreaudio --size=$size --samplerate=$samplerate $output_option
blaar_module coreaudio i_coreaudio --size=$size --samplerate=$samplerate $output_option
elif [ $(uname) = "Linux" ]; then
echo "Linux microphone" >&2
echo "ALSA microphone" >&2
[ ! $device ] && device=default
blaar_module.sh asound i_asound --device=$device --size=$size --samplerate=$samplerate $output_option
blaar_module asound i_asound --device=$device --size=$size --samplerate=$samplerate $output_option
else
echo "$0 does not work on '$(uname)' platform"
exit 1;
echo "$blaar_program_name does not work on '$(uname)' platform"
exit 1
fi
......@@ -33,7 +33,7 @@ blaar_parse_args "$@"
[ $output ] && output_option="--output=$output" || output_option=""
i_sound.sh -o:sound$$ -s$size -S$samplerate $device_option $filename_option|
blaar_module.sh fftw f_fftw_spectrum $output_option
blaar_module fftw f_fftw_spectrum $output_option
blc_channels --unlink /sound$$
......
#!/usr/bin/env bash
# Basic Libraries And Applications for Robotics (BLAAR)
# Copyright ETIS — ENSEA, University of Cergy-Pontoise, CNRS (2011 - 2017)
# Author: Arnaud Blanchard
#
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
set -o errexit #Exit on first error
set -o nounset #Error if a variable is used but not defined
set -o pipefail #Error if a pipe fail
if [ $(uname) = "Darwin" ]; then
blaar_module.sh coreaudio o_coreaudio "$@"
elif [ $(uname) = "Linux" ]; then
blaar_module.sh asound o_asound "$@"
else
echo "$0 does not work on '$(uname)' platform"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment