Commit 08e3f8dd authored by multrus's avatar multrus
Browse files

make work on macOS

parent ede8df0e
Loading
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -38,20 +38,45 @@ then
  exit 1
fi

InfoAudio=InfoAudio
file=$1

system=`uname -s`

InfoAudio=InfoAudio
if [ "$system" = "Darwin" ]; then
    md5=md5
else
    md5=md5sum
fi

# check, whether we have set md5 correctly
if ! command -v $md5 &> /dev/null
then
    echo "Executable for calculating md5 could not be dected. Aborting."
    exit
fi

filename=`basename $file`
md5sum=`md5sum -b $1 | cut -d" " -f1`
if [ "$md5" = "md5sum" ]; then
    md5sum=`$md5 -b $file | cut -d" " -f1`
elif [ "$md5" = "md5" ]; then
    md5sum=`$md5 -r $file | cut -d" " -f1`
else
    echo "No valid executable for calculating md5. Aborting."
    exit
fi

# getting all info from InfoAudio - storing in res
res=`$InfoAudio $file`

# paring res
sampleFreq=`echo "$res" | grep -m1 "Sampling frequency" | sed -e 's/\([a-zA-Z\. ]*: \)\([0-9]*\)\(.*\)/\2/g'`

numberSamples=`echo "$res" | grep -m1 "No. frames" | sed -e 's/\([a-zA-Z\. ]*: \)\([0-9]*\)\(.*\)/\2/g'`

aligned20ms=false
if [ $(expr $numberSamples % 960) == "0" ]; then
remainder=$(expr $numberSamples % 960)
if [ $remainder -eq 0 ]; then
  aligned20ms=true
fi

@@ -61,5 +86,6 @@ dataType=`echo "$res" | grep -m1 "Data type" | sed -e 's/\([a-zA-Z\. ]*: \)\([[a

dataByteOrder=`echo "$res" | grep -m1 "Data byte order" | sed -e 's/\([a-zA-Z\. ]*: \)\([[a-zA-Z0-9-]*\)\(.*\)/\2/g'`

# printing out
echo "${filename};${md5sum};${sampleFreq};${numberSamples};${aligned20ms};${numberChannels};${dataType};${dataByteOrder}"