def __init__(self):
        self._volume = self.MINVOL
        self.playing = True

        automat = TimedFiniteAutomaton("idle")
        automat.add_state("volume_up")
        automat.add_state("volume_down")
        automat.add_state("nudge_up")
        automat.add_state("nudge_down")
        automat.add_state("volume_up_or_toggle")
        automat.add_state("volume_down_or_toggle")
        automat.add_state("toggle_play_pause")

        # waiting for either volume change or toggling play/pause
        automat.add_transition("idle", "volume_up_or_toggle", "volume+pressed")
        automat.add_transition("idle", "volume_down_or_toggle", "volume-pressed")
        # after self.SAME_TIME_THRESHOLD seconds, we will transition to volue up/down
        # we will re-enter the state on .5 timer events to further increase volume
        automat.add_transition("volume_up_or_toggle", "volume_up", self.SAME_TIME_THRESHOLD)
        automat.add_transition("volume_down_or_toggle", "volume_down", self.SAME_TIME_THRESHOLD)
        automat.add_transition("volume_up", "volume_up", .5)
        automat.add_transition("volume_down", "volume_down", .5)
        automat.add_transition("volume_up", "idle", "volume+released")
        automat.add_transition("volume_down", "idle", "volume-released")
        # when we wait for toggle_play_pause, but already release,
        # just nudge the volume once in the respective direction!
        automat.add_transition("volume_up_or_toggle", "nudge_up", "volume+released")
        automat.add_transition("nudge_up", "idle")
        automat.add_transition("volume_down_or_toggle", "nudge_down", "volume-released")
        automat.add_transition("nudge_down", "idle")
        # if within this timeframe the opposite key was pressed, toggle!
        automat.add_transition("volume_up_or_toggle", "toggle_play_pause", "volume-pressed")
        automat.add_transition("volume_down_or_toggle", "toggle_play_pause", "volume+pressed")
        # from play_pause, transition automatically back to idle
        automat.add_transition("toggle_play_pause", "idle")

        self._automat = automat
        self._automat.add_state_change_listener(self._react_to_state_changes)

        print(automat.dot())