private void UpdateRecordingWithInputFromConnectedClient() { // Use the sample data that is sent by the connected client if (!ServerSideConnectRequestManager.TryGetConnectedClientHandler(MicProfile.ConnectedClientId, out ConnectedClientHandler connectedClientHandler)) { Debug.Log($"Client disconnected: {micProfile.Name}. Stopping recording."); StopRecording(); return; } int newSamplesCount = connectedClientHandler.GetNewMicSamples(MicSamples); ApplyAmplificationAndNotifyListeners(newSamplesCount); }
private static int GetSampleRateHz(MicProfile micProfile) { if (micProfile.IsInputFromConnectedClient) { return(ServerSideConnectRequestManager.TryGetConnectedClientHandler(micProfile.ConnectedClientId, out ConnectedClientHandler connectedClientHandler) ? connectedClientHandler.SampleRateHz : DefaultSampleRateHz); } else { Microphone.GetDeviceCaps(micProfile.Name, out int minFrequency, out int maxFrequency); return(maxFrequency == 0 // a value of zero indicates, that the device supports any frequency // https://docs.unity3d.com/ScriptReference/Microphone.GetDeviceCaps.html ? DefaultSampleRateHz : maxFrequency); } }
private static bool CheckMicProfileIsDisconnected(MicProfile localMicProfile) { if (localMicProfile.IsInputFromConnectedClient) { if (!ServerSideConnectRequestManager.TryGetConnectedClientHandler(localMicProfile.ConnectedClientId, out ConnectedClientHandler connectedClientHandler)) { Debug.LogWarning($"Client for mic-input not connected: '{localMicProfile.ConnectedClientId}'."); return(true); } } else { List <string> devices = new List <string>(Microphone.devices); if (!devices.Contains(localMicProfile.Name)) { Debug.LogWarning($"Did not find mic '{localMicProfile.Name}'. Available mic devices: {devices.ToCsv()}"); return(true); } } return(false); }