Skip to content

microphone_selection

The community/plugin/microphone_selection directory contains files that implement a user interface for selecting a microphone in Talon.

The core logic is in microphone_selection.py. This file defines a module that:

  • Uses the cubeb library to get a list of available microphones.
  • Creates an imgui graphical user interface to display the list of microphones.
  • Provides actions for toggling the GUI, hiding the GUI, and selecting a microphone.
  • Registers a callback to update the list of microphones when devices change.

The update_microphone_list function populates the global microphone_device_list variable with available microphone names. It always includes "None" and "System Default" at the beginning of the list to match Talon's context menu. On Windows, it filters out microphones that are not currently enabled.

The gui function creates the imgui interface. It displays a list of buttons, each corresponding to a microphone. Clicking a button triggers the microphone_select action.

The microphone_selection_toggle action toggles the visibility of the GUI.

The microphone_select action takes an index as an argument, and uses it to select a microphone from microphone_device_list. It uses actions.sound.set_microphone to change the active microphone, and notifies the user of the change.

The on_ready function registers the devices_changed callback with cubeb and updates the list of microphones when Talon is ready.

The file microphone_selection.talon provides voice commands to interact with the functionality defined in the python file. These voice commands are:

  • microphone show: Toggles the microphone selection GUI.
  • microphone close: Hides the microphone selection GUI.
  • microphone pick <number_small>: Selects a microphone using its index from the GUI.