Ejemplo n.º 1
0
    static void CompileThrottledSerializeTargetsOutboundData(CNetworkStream _cOutboundStream)
    {
        // Create packet stream
        CNetworkStream cSerializedDataStream = new CNetworkStream();

        foreach (KeyValuePair <byte, TSerializationMethods> tEntry in s_mThrottledSerializeTargets)
        {
            tEntry.Value.nSerializeMethod(cSerializedDataStream);

            if (cSerializedDataStream.BitSize > 0)
            {
                // Write the control identifier
                _cOutboundStream.Write(tEntry.Key);

                // Write the size of the data
                _cOutboundStream.WriteBits(cSerializedDataStream.BitSize, 10);

                // Write the data
                _cOutboundStream.Write(cSerializedDataStream);

                // Clear target stream
                cSerializedDataStream.Clear();
            }
        }
    }
Ejemplo n.º 2
0
    void EncodingUpdate()
    {
        if (Microphone.devices.Length != 0)
        {
            if (m_bRecording == false)
            {
                //if(Input.GetKeyDown(KeyCode.LeftAlt))
                {
                    m_acVoiceInput = Microphone.Start(Microphone.devices[0], true, m_kiRecordTime, 44000);

                    //start timer
                    m_fRecordingTimer = 0.0f;
                    m_bRecording      = true;
                }
            }
            else if (m_bRecording)
            {
                m_fRecordingTimer += Time.deltaTime;

                if (m_fRecordingTimer >= (float)m_kiRecordTime)
                {
                    Microphone.End(Microphone.devices[0]);

                    // Calculate sound size (To the nearest frame size)
                    int iAudioDataSize = m_acVoiceInput.samples * m_acVoiceInput.channels * sizeof(float);
                    iAudioDataSize -= iAudioDataSize % m_iFrameSize;

                    // Extract audio data through the bum
                    float[] fAudioData = new float[iAudioDataSize / sizeof(float)];
                    m_acVoiceInput.GetData(fAudioData, 0);

                    // Convert to short
                    short[] saAudioData = new short[fAudioData.Length];

                    for (int i = 0; i < fAudioData.Length; ++i)
                    {
                        saAudioData[i] = (short)(fAudioData[i] * 32767.0f);
                    }

                    AudioData voiceData = new AudioData();
                    voiceData.iAudioDataSize = iAudioDataSize;
                    voiceData.iFrequency     = m_acVoiceInput.frequency;
                    voiceData.saData         = saAudioData;

                    m_bEncoding = true;

                    m_EncodeThread = new Thread(new ParameterizedThreadStart(EncodeAudio));
                    m_EncodeThread.Start((object)voiceData);

                    m_bRecording = false;
                }
            }
        }

        if (!m_EncodeThread.IsAlive && m_bEncoding)
        {
            m_bEncoding = false;
            CNetwork.Connection.TransmitMicrophoneAudio(s_AudioPacket);

            s_AudioPacket.Clear();
        }
    }
Ejemplo n.º 3
0
 public static void Serialize(CNetworkStream _cStream)
 {
     // Write in internal stream
     _cStream.Write(s_cSerializeStream);
     s_cSerializeStream.Clear();
 }
Ejemplo n.º 4
0
 public static void SerializeOutbound(CNetworkStream _cStream)
 {
     _cStream.Write(s_cSerializeStream);
     s_cSerializeStream.Clear();
 }
Ejemplo n.º 5
0
    static void CompileThrottledSerializeTargetsOutboundData(CNetworkStream _cOutboundStream)
    {
        // Create packet stream
        CNetworkStream cSerializedDataStream = new CNetworkStream();

        foreach (KeyValuePair<byte, TSerializationMethods> tEntry in s_mThrottledSerializeTargets)
        {
            tEntry.Value.nSerializeMethod(cSerializedDataStream);

            if (cSerializedDataStream.BitSize > 0)
            {
                // Write the control identifier
                _cOutboundStream.Write(tEntry.Key);

                // Write the size of the data
                _cOutboundStream.WriteBits(cSerializedDataStream.BitSize, 10);

                // Write the data
                _cOutboundStream.Write(cSerializedDataStream);

                // Clear target stream
                cSerializedDataStream.Clear();
            }
        }
    }
Ejemplo n.º 6
0
 static public void SerializeSliderEvents(CNetworkStream _cStream)
 {
     _cStream.Write(s_SliderNotificationStream);
     s_SliderNotificationStream.Clear();
 }
Ejemplo n.º 7
0
 static public void SerializeElementEvents(CNetworkStream _cStream)
 {
     _cStream.Write(s_ElementNotificationStream);
     s_ElementNotificationStream.Clear();
 }