#
# Copyright (C) by Stefano Falsetto
# e-mail contact ....: mailto:stefko5@inwind.it
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
# Normalize plugin

end_normalize () {
  if [ ! -z "$NORM" ] && [ ! -z "$WROTE" ]; then
    lechoc CYAN $"Normalizing in %s mode..." "$NORM"
    $NORMALIZE $OPZNORM $METHODNORM $WROTE
  fi
}

syntax_normalize () {
  echo $"  -n <mix|batch>, --normalize <mix|batch>"
  echo $"    Normalize all the song with the method specified."
  echo $"    Default method is $DEFNORM"
}

sanity_check_normalize () {
  if [ ! -z "$NORM" ] && [ "$TIPO" != "wav" ]; then
    STRERROR="Can't normalize file type other than WAV! Must use wav output for all files!"
    USCITA=$ERR_CANT_NORM_CDR
  fi
}

parse_param_normalize () {
  case "$1" in
    -n|--normalize)
       if [ -z "$2" ]; then
         NORM=$DEFNORM
         METHODNORM=$DEFMETNORM
         SHIFT=1
         return 1 
       fi
       NORM=$(echo "$2"|tr A-Z a-z)
       case "$NORM" in
         batch)
           METHODNORM=" -b "
           SHIFT=2
           return 1
           ;;
         mix)
           METHODNORM=" -m "
           SHIFT=2
           return 1
           ;;
         -*)
           # Metodo di Default
           NORM=$DEFNORM
           METHODNORM=$DEFMETNORM
           SHIFT=1
           return 1
           ;;
         *)
           STRERR="Unknown normalize method $NORM!"
           USCITA=$ERR_BAD_NORM_METHOD
           return -1
           ;;
       esac
       ;;
    *)
       return 0
       ;;
  esac
}

