Play the given *tone*. This can either be an instance of
        :class:`~gpiozero.tones.Tone` or can be anything that could be used to
        construct an instance of :class:`~gpiozero.tones.Tone`.

        For example::

            >>> from gpiozero import TonalBuzzer
            >>> from gpiozero.tones import Tone
            >>> b = TonalBuzzer(17)
            >>> b.play(Tone("A4"))
            >>> b.play(Tone(220.0)) # Hz
            >>> b.play(Tone(60)) # middle C in MIDI notation
            >>> b.play("A4")
            >>> b.play(220.0)
            >>> b.play(60)

def play(self, tone):
        """
        Play the given *tone*. This can either be an instance of
        :class:`~gpiozero.tones.Tone` or can be anything that could be used to
        construct an instance of :class:`~gpiozero.tones.Tone`.

        For example::

            >>> from gpiozero import TonalBuzzer
            >>> from gpiozero.tones import Tone
            >>> b = TonalBuzzer(17)
            >>> b.play(Tone("A4"))
            >>> b.play(Tone(220.0)) # Hz
            >>> b.play(Tone(60)) # middle C in MIDI notation
            >>> b.play("A4")
            >>> b.play(220.0)
            >>> b.play(60)
        """
        if tone is None:
            self.value = None
        else:
            if not isinstance(tone, Tone):
                tone = Tone(tone)
            freq = tone.frequency
            if self.min_tone.frequency <= tone <= self.max_tone.frequency:
                self.pwm_device.pin.frequency = freq
                self.pwm_device.value = 0.5
            else:
                raise ValueError("tone is out of the device's range")