void Start() { recorder = GetComponent <VoiceChatRecorder> (); int size = VoiceChatSettings.Instance.Frequency * voiceMaxLen; source = GetComponent <AudioSource> (); source.loop = false; source.clip = AudioClip.Create("VoiceChat", size, 1, VoiceChatSettings.Instance.Frequency, false); audioVolume = source.volume; source.playOnAwake = true; data = new float[size]; cacheData = new byte[size]; SendData = new byte[10]; // 37500 = 150 * 16000 * 10 / 640 int allsize = compressLen * size / VoiceChatSettings.Instance.SampleSize; tempSendAllData = new byte[allsize]; if (VoiceChatSettings.Instance.LocalDebug) { if (VoiceChatRecorder.Instance) { VoiceChatRecorder.Instance.NewSample += OnNewSample; } } }
void OnEnable() { if (instance != null && instance != this) { MonoBehaviour.Destroy(this); Debug.LogError("Only one instance of VoiceChatRecorder can exist"); return; } Application.RequestUserAuthorization(UserAuthorization.Microphone); instance = this; }
public override void OnInspectorGUI() { VoiceChatRecorder recorder = target as VoiceChatRecorder; if (Application.isPlaying && Network.isClient) { EditorGUILayout.LabelField("Available Devices", EditorStyles.boldLabel); foreach (string device in recorder.AvailableDevices) { EditorGUILayout.LabelField(device); } EditorGUILayout.LabelField("Selected Device", EditorStyles.boldLabel); int index = Mathf.Clamp(Array.IndexOf(recorder.AvailableDevices, recorder.Device), 0, Int32.MaxValue) + 1; string[] devices = new string[1] { "Default" }.Concat(recorder.AvailableDevices).ToArray(); index = EditorGUILayout.Popup(index, devices); if (index != 0) { recorder.Device = devices[index]; } else { recorder.Device = null; } if (recorder.IsRecording) { if (GUILayout.Button("Stop Recording")) { recorder.StopRecording(); } } else { if (GUILayout.Button("Start Recording")) { recorder.StartRecording(); } } } else { DrawDefaultInspector(); } }
void OnEnable() { if (instance != null && instance != this) { MonoBehaviour.Destroy(this); Debug.LogError("Only one instance of VoiceChatRecorder can exist"); return; } if (GameManager.Inst.ServerConfig != "Assembly" && GameManager.Inst.ServerConfig != "MDONS") { Application.RequestUserAuthorization(UserAuthorization.Microphone); } instance = this; }
// Use this for initialization void Start() { // Get Components for Pointers recorder = GetComponent<VoiceChatRecorder> (); // Presumes that the first device availiable is the best recorder.Device = recorder.AvailableDevices [0]; //TODO: Get NetworkId from DarkRift before recording recorder.StartRecording(); //TODO: LIST // 1. Set VoiceChatRecorder.Instance.NetworkId to a unique number on each client // 2. Subscribe to the VoiceChatRecorder.Instance.NewSample event // 3. When the NewSample events get triggered, send the VoiceChatPacket data to all other clients. // 4. On the client read the data back, and make sure you have one instance of the Network/Resources/VoiceChat_Player prefab, grab the VoiceChatPlayer script and call OnNewSample(packet) on it. }
private IEnumerator InitMicrophone() { yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); print("Microphones " + Microphone.devices.Length); if (Microphone.devices.Length > 0) { VoiceChatRecorder v = VoiceChatRecorder.Instance; v.enabled = true; v.NetworkId = PhotonNetwork.player.ID; v.Device = v.AvailableDevices[0]; v.StartRecording(); v.NewSample -= VoiceChat; v.NewSample += VoiceChat; } yield return(null); }
private IEnumerator InitMicrophone() { if (_Loader.dm && !Application.HasUserAuthorization(UserAuthorization.Microphone)) { ShowWindowNoBack(_Game.MenuWindow); } yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); Debug.LogWarning("Microphones " + Microphone.devices.Length); if (Microphone.devices.Length > 0) { VoiceChatRecorder v = VoiceChatRecorder.Instance; v.enabled = true; v.NetworkId = PhotonNetwork.player.ID; v.Device = v.AvailableDevices[0]; v.StartRecording(); v.NewSample -= VoiceChat; v.NewSample += VoiceChat; } yield return(null); }
void OnDestroy() { instance = null; }
void OnDisable() { instance = null; }