Construct a :class:`Tone` from a MIDI note, which must be an integer
        in the range 0 to 127. For reference, A4 (`concert A`_ typically used
        for tuning) is MIDI note #69.

        .. _concert A: https://en.wikipedia.org/wiki/Concert_pitch

def from_midi(cls, midi_note):
        """
        Construct a :class:`Tone` from a MIDI note, which must be an integer
        in the range 0 to 127. For reference, A4 (`concert A`_ typically used
        for tuning) is MIDI note #69.

        .. _concert A: https://en.wikipedia.org/wiki/Concert_pitch
        """
        midi = int(midi_note)
        if 0 <= midi_note < 128:
            A4_midi = 69
            A4_freq = 440
            return cls.from_frequency(A4_freq * 2 ** ((midi - A4_midi) / 12))
        raise ValueError('invalid MIDI note: %r' % midi)