Hi there I am working on a project which require each user to use two micphones at the same time.
However I am kind of lost here.
I tried to access the available micphones but _client.AudioInputDevices.AvailableDevices.Count showed me that the list is empty with zero devices in it. However, the example does work and the default michone does work, so I am confused why. Or is there a more specific way to check the available devices in system?
I have read through the related document (https://docs.vivox.com/v5/general/unity/15_1_160000/en-us/Default.htm#Unity/developer-guide/in-game-audio-control/in-game-audio-device-selection.htm by the way do we have an example for this?) and I am running the 5.14.0 version (from unity package manager)
My idea of using two micphones at the same time is logging into the same channel with two different IDs. However, setting two new Client would lead to a “too many connection” error. Using one Client and logging into the same channel twice with different IDs did show two different player there, but the audio device selection is controlled by Client, so they are most likely using the same Mic. and I used the example scene as a visualizor for testing, it showed that only one of the two players is actually recording, the other is silent. I assume that the mic is acutally being used by only one “player”, since they are using the same “Client”.
I think you can only use 1 microphone at a time per LoginSession. You can have multiple LoginSessions using 1/the same Client tho, which is probably what you’re trying to achieve. But it seems like you want to do this for testing purposes, am I right?? If I am not right, then read no further.
If I am, it’s easier to build the project and use the built project instance along with the Unity Editor instance and hook up headphones(with a mic preferably) and have the laptop/desktop speaker active. That way you can test 2 instances of Vivox running in 2 separate processes, each with there own LoginSession, and have them join the same channel, all while developing on the same machine so you don’t need 2 laptops, or have to build a mobile version and use the Unity Editor just to test if Vivox works
Hello! I am sorry to hear you are having issues with available devices! I will answer your questions below:
1. an example about how to select audio devices.
I am sorry to hear your available devices is showing that you have no devices. Can you provide the code snippet and logs on how you are checking the _client.AudioInputDevices.AvailableDevices.count in your code?
To check the available devices, here is example code on how to check it:
foreach (IAudioDevice device in _client.AudioInputDevices.AvailableDevices)
{
Debug.Log("Device: " + device.Name);
}```
This will iterate through the Dictionary of AvailableDevices. You should be able to call this at any point after you've initialized the Vivox SDK to get the list of your available devices.
*2. How to use multiple micphones?*
To help me best answer your second question, what is your specific use case for requiring two microphones? If you just need this for testing, MurphyMurph_21 is correct and their recommendation should be perfect for your needs! If this suggestion doesn't solve your issue, please feel free to provide more context and I'm happy to help find you a solution.
Thank you both for your cooperation!!
Well, it is not for testing.
We are working on a project that requires both the voice chat and the body audio (like the steps on floor or the clothes sound). Therefore, we hope to be able to use multiple devices.
We tried to run two unity instances on one computer for testing, but we wish a more compact solution that allows running only one Unity application while using both micphones.
And a strange situation is,
_client.AudioInputDevices.AvailableDevices.Count
returns 0.
But the vivox actually working well, and the activated device is the system default.
Regarding your use-case, I have a few follow up questions:
For the body microphone, are you hoping to transmitting this audio so other players can hear it in channel as well?
Is your implementation using a 3d channel?
What type of device are you using? Is it a custom built device, or just a regular PC, mobile phone, etc.?
Regarding the _client.AudioInputDevices.AvailableDevices.Count returning 0, I have a few follow up questions as well:
Does this occur only when you are running the two unity instances simultaneously, or even when you run one build on its own?
Can you share the code where you access the input device?
If you call BeginRefresh before checking the Available Devices, do you still get 0?
The code to call BeginRefresh is as follows:
// Refresh list of devices to have it up to date
var ar = _client.AudioInputDevices.BeginRefresh(new AsyncCallback((IAsyncResult result) =>
{
Debug.Log("Available Device Count: " + _client.AudioInputDevices.AvailableDevices.Count);
}));