def midi(self):
        """
        Return the (nearest) MIDI note to the tone's frequency. This will be an
        integer number in the range 0 to 127. If the frequency is outside the
        range represented by MIDI notes (which is approximately 8Hz to 12.5KHz)
        :exc:`ValueError` exception will be raised.
        """
        result = int(round(12 * log2(self.frequency / 440) + 69))
        if 0 <= result < 128:
            return result
        raise ValueError('%f is outside the MIDI note range' % self.frequency)
Return the (nearest) MIDI note to the tone's frequency. This will be an
        integer number in the range 0 to 127. If the frequency is outside the
        range represented by MIDI notes (which is approximately 8Hz to 12.5KHz)
        :exc:`ValueError` exception will be raised.