Example #1
0
        private void initialAudioProccessing(byte[] bytes)
        {
            float[] floats = Converters.bytes2floats(bytes);

            for (int i = 0; i < floats.Length; i += inputChannels)
            {
                // WE ARE NOW ONLY PROCESSING THE FIRST CHANNEL IN THE INPUT
                if (inputFormat.Channels == 1)
                {
                    ProcessFloatSample(floats[i]);
                }
                else
                {
                    switch (inputMode)
                    {
                    case 0:                             // LR
                        ProcessFloatSample(floats[i], floats[i + 1]);
                        break;

                    case 1:                             // LL
                        ProcessFloatSample(floats[i], floats[i]);
                        break;

                    case 2:                             // RR
                        ProcessFloatSample(floats[i + 1], floats[i + 1]);
                        break;

                    case 3:                             // RL
                        ProcessFloatSample(floats[i + 1], floats[i]);
                        break;
                    }
                }
            }
        }
Example #2
0
        /**
         * FORMAT 2
         * G722 16kHz mono
         **/
        private byte[] EncodeFormat2(float[] data)
        {
            byte[]  rs = codecDownSampler.inputResample(Converters.floats2bytes(data), data.Length);
            float[] f  = Converters.bytes2floats(rs);

            float[] mono = Converters.stereo2mono(f);

            short[] shorts = Converters.floats2shorts(mono, true);

            int bytes = (int)(shorts.Length / 2);

            byte[] output = new byte[bytes];

            encode2.Encode(encode2State, output, shorts, shorts.Length);
            return(output);
        }
Example #3
0
 private void BufferSound(byte[] bytes, BufferedWaveProvider buffer, bool mono2stereo, bool outputGain)
 {
     BufferSound(Converters.bytes2floats(bytes), buffer, mono2stereo, outputGain);
 }