def midi_to_hertz(midi, a4_hertz=440.0):
    """MIDI note number to to frequency conversion.

    :param midi: MIDI note number
    :type midi: int
    :param a4_hertz: A4 reference frequency
    :type a4_hertz: float

    :returns: Frequency in Hertz
    :rtype: float

    **Examples**

    >>> midi_to_hertz(69)
    440.0

    >>> midi_to_hertz(0)
    8.175798915643707
    """
    if (not isinstance(midi, int)) or (midi not in range(0, 128)):
        raise TypeError('midi must be int and 128 > midi >= 0')
    if a4_hertz <= 0:
        raise TypeError('a4_hertz must be > 0')
    oct_div = 12  # Equal temperament
    a4_midi = 69
    return 2**((midi - a4_midi) / oct_div) * a4_hertz