Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hs.audiodevice:thru() and hs.audiodevice:setThru(thru) #3716

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

bburky
Copy link
Contributor

@bburky bburky commented Nov 20, 2024

hs.audiodevice:thru() -> bool or nil
hs.audiodevice:setThru(thru) -> bool

Get or set the play through (low-latency/direct monitoring) state of the the audio device via kAudioDevicePropertyPlayThru. This is the feature of some microphones where they can play their input directly to their output (e.g. headphone jack) so you can get low-latency feedback while recording.

  • This only works on devices that have hardware support (often microphones with a built-in headphone jack)
  • This setting corresponds to the "Thru" setting in Audio MIDI Setup
  • I only have one device to test with, it's a combo input/output device. I'm unsure if they're ever split into multiple devices? I decompiled Audio MIDI Setup (before I got around to installing Xcode) and it does seem to do a conditional check, supporting both input and output devices, before setting thru.
    • I don't think we need separate hs.audiodevice:setInputThru(state) and hs.audiodevice:setOutputThru(state)?

(I have a USB microphone that annoyingly enables this every time is reconnected or I reboot, I want to script disabling it. This could also be useful for other users who like this setting, but perhaps want do something like assign it a keyboard shortcut.)

Get or set the play through (low-latency/direct monitoring) state of the the audio device via `kAudioDevicePropertyPlayThru`. This is the feature of some microphones where they can play their input directly to their output (e.g. headphone jack) so you can get low-latency feedback while recording.

* This only works on devices that have hardware support (often microphones with a built-in headphone jack)
* This setting corresponds to the "Thru" setting in Audio MIDI Setup
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['pr-fix', 'pr-change', 'pr-feature', 'pr-maintenance']

@bburky
Copy link
Contributor Author

bburky commented Nov 20, 2024

I guess I can add kAudioDevicePropertyPlayThruto watchSelectors for hs.audiodevice:watcherCallback() if that's valuable? The event name is thru. I tested it, let me know if I should add it too.

@cmsj cmsj added the pr-feature Pull Request implementing a feature label Nov 28, 2024
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 49.05660% with 27 lines in your changes missing coverage. Please review.

Project coverage is 27.45%. Comparing base (37057a0) to head (6a75b8a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3716      +/-   ##
==========================================
+ Coverage   27.37%   27.45%   +0.07%     
==========================================
  Files         191      191              
  Lines       51407    51460      +53     
==========================================
+ Hits        14074    14129      +55     
+ Misses      37333    37331       -2     

@cmsj cmsj merged commit 251f5af into Hammerspoon:master Nov 28, 2024
4 of 5 checks passed
@cmsj
Copy link
Member

cmsj commented Nov 28, 2024

Thanks!

@bburky bburky deleted the audiodevice-thru branch November 28, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature Pull Request implementing a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants