Ejemplo n.º 1
0
        unsafe private static void ProcessFrameOutput(AudioFrame frame)
        {
            using (AudioBuffer buffer = frame.LockBuffer(AudioBufferAccessMode.Write))
                using (IMemoryBufferReference reference = buffer.CreateReference())
                {
                    byte * dataInBytes;
                    uint   capacityInBytes;
                    float *dataInFloat;

                    // Get the buffer from the AudioFrame
                    ((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacityInBytes);

                    dataInFloat = (float *)dataInBytes;
                    float[] dataInFloats = new float[capacityInBytes / sizeof(float)];

                    for (int i = 0; i < capacityInBytes / sizeof(float); i++)
                    {
                        dataInFloats[i] = dataInFloat[i];
                    }



                    InputRecieved?.Invoke(null, dataInFloats);
                }
        }
Ejemplo n.º 2
0
    public void ProcessInput()
    {
        Assert.IsNotNull(InputField);
        Assert.IsFalse(string.IsNullOrEmpty(InputField.text));
        InputRecieved?.Invoke(this, InputField.text);

        InputField.text = string.Empty;
    }
Ejemplo n.º 3
0
        public void GetInput()
        {
            string inputString = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(inputString) == false)
            {
                InputRecieved?.Invoke(this, inputString);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handle frame of mic input
        /// </summary>
        /// <param name="frame"></param>
        private static unsafe void ProcessFrameOutput(AudioFrame frame)
        {
            float[] dataInFloats;
            using (AudioBuffer buffer = frame.LockBuffer(AudioBufferAccessMode.Write))
                using (IMemoryBufferReference reference = buffer.CreateReference())
                {
                    // Get the buffer from the AudioFrame
                    ((IMemoryBufferByteAccess)reference).GetBuffer(out byte *dataInBytes, out uint capacityInBytes);

                    float *dataInFloat = (float *)dataInBytes;
                    dataInFloats = new float[capacityInBytes / sizeof(float)];

                    for (int i = 0; i < capacityInBytes / sizeof(float); i++)
                    {
                        dataInFloats[i] = dataInFloat[i];
                    }
                }

            // Don't bother if muted
            if (LocalState.VoiceState.SelfMute || LocalState.VoiceState.ServerMute)
            {
                AudioInSpec1   = 0;
                AudioInSpec2   = 0;
                AudioInSpec3   = 0;
                AudioInSpec4   = 0;
                AudioInSpec5   = 0;
                AudioInSpec6   = 0;
                AudioInSpec7   = 0;
                AudioInSpec8   = 0;
                AudioInSpec9   = 0;
                AudioInAverage = 0;
            }
            else
            {
                // Determine FFT data
                List <float[]> amplitudeData = FFT.Processing.HelperMethods.ProcessFrameOutput(frame);
                List <float[]> channelData   = FFT.Processing.HelperMethods.GetFftData(FFT.Processing.HelperMethods.ConvertTo512(amplitudeData, ingraph), ingraph);

                float[] leftChannel = channelData[1];

                // Assign each FFT data out channel
                AudioInSpec1   = HelperMethods.Max(leftChannel, 0, 1);
                AudioInSpec2   = HelperMethods.Max(leftChannel, 2, 3);
                AudioInSpec3   = HelperMethods.Max(leftChannel, 3, 4);
                AudioInSpec4   = HelperMethods.Max(leftChannel, 4, 5);
                AudioInSpec5   = HelperMethods.Max(leftChannel, 5, 6);
                AudioInSpec6   = HelperMethods.Max(leftChannel, 7, 8);
                AudioInSpec7   = HelperMethods.Max(leftChannel, 9, 10);
                AudioInSpec8   = HelperMethods.Max(leftChannel, 10, 12);
                AudioInSpec9   = HelperMethods.Max(leftChannel, 14, 26);
                AudioInAverage = (AudioInSpec1 + AudioInSpec2 + AudioInSpec3 + AudioInSpec4 + AudioInSpec5 + AudioInSpec5 + AudioInSpec6 + AudioInSpec7 + AudioInSpec8 + AudioInSpec9) / 9;
            }

            InputRecieved?.Invoke(null, dataInFloats);
        }
Ejemplo n.º 5
0
 void Update()
 {
     if (Input.GetKey(KeyCode.Return))
     {
         string inputString = InputField.text;
         if (string.IsNullOrWhiteSpace(inputString) == false)
         {
             InputRecieved?.Invoke(this, inputString);
         }
         InputField.text = string.Empty;
     }
 }
        public void ProcessInput()
        {
            string inputString = Console.ReadLine();

            InputRecieved?.Invoke(this, inputString);
        }
 public void ProcessInput()
 {
     InputRecieved?.Invoke(this, InputField.text);
 }
Ejemplo n.º 8
0
 private void RaiseInputRecieved(InputEventArgs e)
 {
     InputRecieved?.Invoke(this, e);
 }