tart icon indicating copy to clipboard operation
tart copied to clipboard

Pass in Microphone

Open Nahiiko opened this issue 11 months ago • 8 comments

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 ?

Nahiiko avatar Mar 23 '24 23:03 Nahiiko

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

fkorotkov avatar Mar 24 '24 07:03 fkorotkov

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

Nahiiko avatar Mar 24 '24 08:03 Nahiiko

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.

fkorotkov avatar Mar 26 '24 08:03 fkorotkov

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 ?

Nahiiko avatar Mar 26 '24 08:03 Nahiiko

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

https://github.com/cirruslabs/tart/blob/1a3b862631fe576c62ad2adc023f7971b3f8605f/Sources/tart/VM.swift#L298-L306

Otherwise the default VZHostAudioInputStreamSource and VZHostAudioOutputStreamSink are used.

fkorotkov avatar Mar 26 '24 08:03 fkorotkov

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.

Nahiiko avatar Mar 26 '24 09:03 Nahiiko

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.

edigaryev avatar May 03 '24 08:05 edigaryev

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

Nahiiko avatar May 03 '24 10:05 Nahiiko