Ejemplo n.º 1
0
    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();
        }
    }
Ejemplo n.º 4
0
    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;
    }
Ejemplo n.º 5
0
    // 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.
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
    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);
    }
Ejemplo n.º 8
0
 void OnDestroy()
 {
     instance = null;
 }
Ejemplo n.º 9
0
 void OnDisable()
 {
     instance = null;
 }
Ejemplo n.º 10
0
    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;
    }
 void OnDestroy()
 {
     instance = null;
 }
 void OnDisable()
 {
     instance = null;
 }