#hs.audiodevice
Manipulate the system's audio devices
This module is based primarily on code from the previous incarnation of Mjolnir by Steven Degutis.
#Submodules
#API Overview
Functions - API calls offered directly by the extension
- allDevices
- allInputDevices
- allOutputDevices
- current
- defaultEffectDevice
- defaultInputDevice
- defaultOutputDevice
- findDeviceByName
- findDeviceByUID
- findInputByName
- findInputByUID
- findOutputByName
- findOutputByUID
Methods - API calls which can only be made on an object returned by a constructor
- allInputDataSources
- allOutputDataSources
- balance
- currentInputDataSource
- currentOutputDataSource
- inputMuted
- inputVolume
- inUse
- isInputDevice
- isOutputDevice
- jackConnected
- muted
- name
- outputMuted
- outputVolume
- setBalance
- setDefaultEffectDevice
- setDefaultInputDevice
- setDefaultOutputDevice
- setInputMuted
- setInputVolume
- setMuted
- setOutputMuted
- setOutputVolume
- setVolume
- supportsInputDataSources
- supportsOutputDataSources
- transportType
- uid
- volume
- watcherCallback
- watcherIsRunning
- watcherStart
- watcherStop
#API Documentation
#Functions
#Methods
| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.audiodevice:watcherCallback(fn) -> hs.audiodevice
| | Type | Method | | Description | Sets or removes a callback function for an audio device watcher | | Parameters |
- fn - A callback function that will be called when properties of this audio device change, or nil to remove an existing callback. The function should accept four arguments: A string containing the UID of the audio device (see
hs.audiodevice.findDeviceByUID()
) A string containing the name of the event. Possible values are: vmvc - Volume changed mute - Mute state changed jack - Jack sense state changed (usually this means headphones were plugged/unplugged) span - Stereo pan changed diff - Device configuration changed (if you are caching audio device properties, this event indicates you should flush your cache) gone - The device's "in use" status changed (ie another app started using the device, or stopped using it) A string containing the scope of the event. Possible values are: glob - This is a global event pertaining to the whole device inpt - This is an event pertaining only to the input functions of the device outp - This is an event pertaining only to the output functions of the device A number containing the element of the event. Typical values are: 0 - Typically this means the Master channel 1 - Typically this means the Left channel 2 - Typically this means the Right channel
- The
hs.audiodevice
object
- You will receive many events to your callback, so filtering on the name/scope/element arguments is vital. For example, on a stereo device, it is not uncommon to receive a
volm
event for each audio channel when the volume changes, or multiplemute
events for channels. Dragging a volume slider in the system Sound preferences will produce a large number ofvolm
events. Plugging/unplugging headphones may triggervolm
events in addition tojack
ones, etc. - If you need to use the
hs.audiodevice
object in your callback, usehs.audiodevice.findDeviceByUID()
to obtain it fro the first callback argument