Skip to content

Commit

Permalink
Merge pull request #78 from denis-stepanov/76-make-volume-control-and…
Browse files Browse the repository at this point in the history
…-mute-keys-truly-tv-control-keys

76 make volume control and mute keys truly tv control keys
  • Loading branch information
denis-stepanov authored Apr 26, 2024
2 parents 2bf61c9 + e0d19c7 commit 893a350
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,27 @@ Refer to `advent -h` for full synopsys.

### Interactive Controls

AdVent allows dynamically adjusting some parameters at run-time by hitting keys in the console. Here is the summary:
AdVent allows recognition process steering at run-time by hitting keys in the console. Here is the summary:

```
h - help
t / T - emulate a hit / unconditionally
a - toggle TV 'in action' status
space - toggle mute
m / M - mute / unmute
v / V - volume lower / raise
a - toggle 'in action' status
i / I - interval decrease / increase
c / C - confidence decrease / increase
space - TV toggle mute
m / M - TV mute / unmute
v / V - TV volume lower / raise
q - quit
```

`t` just emulates a hit. This action could be useful when AdVent for some reason would not react where it should, so you could give it a hand. Like any other hit, it would respect the TV dead time, i.e. will not act on TV if there has been another action recently. If you want to override this - e.g., to "undo" an erroneous AdVent hit - use `T`.
`t` just emulates a hit. This action could be useful when AdVent for some reason would not react where it should have, so you could give it a hand. Like with any other hit, it would respect the TV dead time, i.e. will not act on TV if there has been another action happening recently. If you want to override this - e.g., to "undo" an erroneous AdVent hit which has just occured - use `T`.

`a` toggles the TV internal "in action" status, without making any specific action on a TV. This action could be useful when AdVent for some reason comes out of sync with TV status (e.g., when TV has been manually muted using its own remote).

`space`, `m / M` and `v / V` act as TV control buttons, i.e., send the corresponding commands directly to a TV. AdVent will nevertheless keep track of these events in order to avoid conflict between user actions and its own actions. Also, activating these controls will change the TV action mode to the last one requested by user (i.e., if `space` is pressed, AdVent would change is action type to `mute`).
`i / I` and `c / C` allow tuning the corresponding [AdVent parameters](#recognition-tuning-options) at run-time. Interval can be changed from 0 to infinity in steps of 0.5 s (but remember that intervals below 1 s [are rather useless](#advent-tuning)). Confidence can be changed from 0 to 100% in 1% steps. Changing the number of threads `n` on the fly is currently not supported (upvote the issue [#68](https://github.com/denis-stepanov/advent/issues/68) if you need this).

`i / I` and `c / C` allow tuning the corresponding [AdVent parameters](#recognition-tuning-options) at run-time. Changing number of threads `n` on the fly is currently not possible (see issue [#68](https://github.com/denis-stepanov/advent/issues/68)).
`space`, `m / M` and `v / V` act as TV remote buttons, i.e., send the corresponding commands directly to a TV bypassing AdVent engine. This is just a bonus, because the TV control module would allow that. However, these commands have to be used conciously, as they might cause desync in some situations, e.g., leaving TV indefinitely in "mute" while AdVent would believe it is unmuted. If you want AdVent to take into account your actions, you need to manipulate "in action" flag manually using the `a` command.

### Manual Tuning

Expand Down
2 changes: 1 addition & 1 deletion advent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="1.6b5"
__version__="1.6b6"
19 changes: 5 additions & 14 deletions advent/advent.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,34 +149,28 @@ def handleKeyboard(self, key):
stop_listening()
LOGGER.info('User: quit')
elif key == 'space':
self.updateActionTime()
# NB: direct TV actions could potentially race condition with recognition threads, but the probability of this is rather low
if self.tvc.toggleMute():
LOGGER.info(f'User: toggle mute. TV is %s', "muted" if self.tvc.isMuted() else "unmuted")
else:
LOGGER.info('User: toggle mute. TV action failed')
self.setAction('mute')
elif key == 'm':
if self.tvc.isMuted():
LOGGER.info('User: mute. TV is already muted')
else:
self.updateActionTime()
if self.tvc.toggleMute():
LOGGER.info('User: mute. TV is muted')
else:
LOGGER.info('User: mute. TV action failed')
self.setAction('mute')
elif key == 'M':
if self.tvc.isMuted():
self.updateActionTime()
if self.tvc.toggleMute():
LOGGER.info('User: unmute. TV is unmuted')
else:
LOGGER.info('User: unmute. TV action failed')
self.setAction('mute')
else:
LOGGER.info('User: unmute. TV is already unmuted')
elif key == 'v':
self.updateActionTime()
if not self.tvc.isUnidirectional():
vol = self.tvc.getVolume()
if self.tvc.changeVolume(-self.tvc.VOLUME_STEP):
Expand All @@ -186,9 +180,7 @@ def handleKeyboard(self, key):
LOGGER.info(f'User: lower volume. TV volume lowered by {self.tvc.VOLUME_STEP} (%d --> %d)', vol, self.tvc.getVolume())
else:
LOGGER.info('User: lower volume. TV action failed')
self.setAction('lower_volume')
elif key == 'V':
self.updateActionTime()
if not self.tvc.isUnidirectional():
vol = self.tvc.getVolume()
if self.tvc.changeVolume(self.tvc.VOLUME_STEP):
Expand All @@ -198,7 +190,6 @@ def handleKeyboard(self, key):
LOGGER.info(f'User: raise volume. TV volume raised by {self.tvc.VOLUME_STEP} (%d --> %d)', vol, self.tvc.getVolume())
else:
LOGGER.info('User: raise volume. TV action failed')
self.setAction('lower_volume')
elif key == 'c':
if REC_CONFIDENCE > 0:
REC_CONFIDENCE -= 1
Expand Down Expand Up @@ -235,13 +226,13 @@ def handleKeyboard(self, key):
elif key == 'h':
print('h - help')
print('t / T - emulate a hit / unconditionally')
print('a - toggle TV \'in action\' status')
print('space - toggle mute')
print('m / M - mute / unmute')
print('v / V - volume lower / raise')
print('a - toggle \'in action\' status')
# n / N is reserved for potential change of threads at runtime
print('i / I - interval decrease / increase')
print('c / C - confidence decrease / increase')
print('space - TV toggle mute')
print('m / M - TV mute / unmute')
print('v / V - TV volume lower / raise')
print('q - quit')

# Recognizer
Expand Down

0 comments on commit 893a350

Please sign in to comment.