Set the HEAD, MIDDLE, TAIL explicitly.

        If a parameter is ``None``, it will be ignored.
        If both ``middle_length`` and ``tail_length`` are specified,
        only ``middle_length`` will be applied.

        :param head_length: the length of HEAD, in seconds
        :type  head_length: :class:`~aeneas.exacttiming.TimeValue`
        :param middle_length: the length of MIDDLE, in seconds
        :type  middle_length: :class:`~aeneas.exacttiming.TimeValue`
        :param tail_length: the length of TAIL, in seconds
        :type  tail_length: :class:`~aeneas.exacttiming.TimeValue`
        :raises: TypeError: if one of the arguments is not ``None``
                            or :class:`~aeneas.exacttiming.TimeValue`
        :raises: ValueError: if one of the arguments is greater
                             than the length of the audio file

def set_head_middle_tail(self, head_length=None, middle_length=None, tail_length=None):
        """
        Set the HEAD, MIDDLE, TAIL explicitly.

        If a parameter is ``None``, it will be ignored.
        If both ``middle_length`` and ``tail_length`` are specified,
        only ``middle_length`` will be applied.

        :param head_length: the length of HEAD, in seconds
        :type  head_length: :class:`~aeneas.exacttiming.TimeValue`
        :param middle_length: the length of MIDDLE, in seconds
        :type  middle_length: :class:`~aeneas.exacttiming.TimeValue`
        :param tail_length: the length of TAIL, in seconds
        :type  tail_length: :class:`~aeneas.exacttiming.TimeValue`
        :raises: TypeError: if one of the arguments is not ``None``
                            or :class:`~aeneas.exacttiming.TimeValue`
        :raises: ValueError: if one of the arguments is greater
                             than the length of the audio file
        """
        for variable, name in [
            (head_length, "head_length"),
            (middle_length, "middle_length"),
            (tail_length, "tail_length")
        ]:
            if (variable is not None) and (not isinstance(variable, TimeValue)):
                raise TypeError(u"%s is not None or TimeValue" % name)
            if (variable is not None) and (variable > self.audio_length):
                raise ValueError(u"%s is greater than the length of the audio file" % name)
        self.log(u"Setting head middle tail...")
        mws = self.rconf.mws
        self.log([u"Before: 0 %d %d %d", self.middle_begin, self.middle_end, self.all_length])
        if head_length is not None:
            self.middle_begin = int(head_length / mws)
        if middle_length is not None:
            self.middle_end = self.middle_begin + int(middle_length / mws)
        elif tail_length is not None:
            self.middle_end = self.all_length - int(tail_length / mws)
        self.log([u"After:  0 %d %d %d", self.middle_begin, self.middle_end, self.all_length])
        self.log(u"Setting head middle tail... done")