import math


def frequency_to_midi(freqency):
    """ converts a frequency into a MIDI note.

    Rounds to the closest midi note.

    ::Examples::

    >>> frequency_to_midi(27.5)
    21
    >>> frequency_to_midi(36.7)
    26
    >>> frequency_to_midi(4186.0)
    108
    """
    return int(
        round(
            69 + (
                12 * math.log(freqency / 440.0)
            ) / math.log(2)
        )
    )