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

Pass in Microphone #764

Open
Nahiiko opened this issue Mar 23, 2024 · 8 comments
Open

Pass in Microphone #764

Nahiiko opened this issue Mar 23, 2024 · 8 comments
Labels
question Further information is requested

Comments

@Nahiiko
Copy link

Nahiiko commented Mar 23, 2024

Hi,

It seems it's not possible to pass through the microphone (or any audio input) to the VM (tried with sonoma-base only)
The Audio Output seems to work fine.

Although #161 seems to point at the fact that it is indeed supported, am I doing something wrong ?

@fkorotkov
Copy link
Contributor

VMs should use whatever is set as output/input in your preferences on the host. Do you have the microphone selected there?

@fkorotkov fkorotkov added the question Further information is requested label Mar 24, 2024
@Nahiiko
Copy link
Author

Nahiiko commented Mar 24, 2024

I see what you mean, but it doesn't seem to work for some reason, am on an M1 macbook air, here you can see the host config (you can see my voice being picked up by the mic):
Screenshot 2024-03-24 at 09 41 33
And here sonoma-base's config using tart (no voice being picked up):
Screenshot 2024-03-24 at 09 41 56

@fkorotkov
Copy link
Contributor

I just tried to reproduce and it seems I'm able both to record and output voice inside a VM. I'm using both Sonoma host and guest. Note that guest will always show "Built-in" input/output even though it's donna use what is specified on the host.

@Nahiiko
Copy link
Author

Nahiiko commented Mar 26, 2024

Mh, a few questions:

  • Is there some kind of variable I can input to force an audio input to be used ?
  • Is there a verbose mode so I can track and see if any error appears ?
  • I use sonoma-base, does it have any influence here ?
  • Host is using sonoma 14.1.1, any issue with that ?

@fkorotkov
Copy link
Contributor

BTW are you running a suspendable VM by any chance? Suspendable VMs don't support audio:

tart/Sources/tart/VM.swift

Lines 298 to 306 in 1a3b862

if audio && !suspendable {
let soundDeviceConfiguration = VZVirtioSoundDeviceConfiguration()
let inputAudioStreamConfiguration = VZVirtioSoundDeviceInputStreamConfiguration()
inputAudioStreamConfiguration.source = VZHostAudioInputStreamSource()
let outputAudioStreamConfiguration = VZVirtioSoundDeviceOutputStreamConfiguration()
outputAudioStreamConfiguration.sink = VZHostAudioOutputStreamSink()
soundDeviceConfiguration.streams = [inputAudioStreamConfiguration, outputAudioStreamConfiguration]
configuration.audioDevices = [soundDeviceConfiguration]
}

Otherwise the default VZHostAudioInputStreamSource and VZHostAudioOutputStreamSink are used.

@Nahiiko
Copy link
Author

Nahiiko commented Mar 26, 2024

I run the regular tart run sonoma-base cmd in zsh, also the sound output works fine

edit: updated to sonoma 14.4.1, still got the issue, so not related to that.

@edigaryev
Copy link
Collaborator

https://developer.apple.com/documentation/virtualization/audio says:

If your app can configure an audio input device, you must set an NSMicrophoneUsageDescription message in your app’s Info.plist. The system uses this description when asking the user’s permission to enable microphone access. If this message isn’t set or the key isn’t present, the system denies microphone access to your app.

So it seems that we need to ask for a permission first to make the microphone work.

@Nahiiko
Copy link
Author

Nahiiko commented May 3, 2024

Very interesting !

  • Any way to do this manually ? So I can play with it until you release an update
  • Why does it work for @fkorotkov ?

Or could it be that I need to give mic permission to the terminal ? Trying this asap

edit: it worked ! giving permissions to the terminal in settings :)
Screenshot 2024-05-03 at 13 45 57

Although I don't think that's a good practice long term

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants