Ejemplo n.º 1
0
        public float[] Processing1(float[] audioSource, ref int vad)
        {
            if (!_isInit)
            {
                return(o_source160);
            }
            if (_delayFreamSize <= 0)
            {
                AudioDefine.To16Array(o_source, audioSource);
                AudioProcessingDll.WebRtc_BufferFarend(o_source);

                IntPtr ptr = IntPtr.Zero;
                vad = AudioProcessingDll.Process(g_source, ref ptr, AudioDefine.MS_IN_SEND_CARDBUF);
                for (int i = 0; i < g_source.Length; i++)
                {
                    g_source [i] = o_source [i];
                }
                Marshal.Copy(ptr, o_source, 0, AudioDefine.G_FRAME_SIZE);
                AudioDefine.ToFArray(o_source160, o_source);
            }
            else
            {
                _delayFreamSize--;
                AudioDefine.To16Array(g_source, audioSource);
            }

            return(o_source160);
        }
Ejemplo n.º 2
0
 public void InitAmr()
 {
     if (_amrIsInit)
     {
         return;
     }
     AudioProcessingDll.amr_init(0);
     _amrIsInit = true;
 }
Ejemplo n.º 3
0
        public static byte[] EnFrame(float[] ibuf)
        {
            AudioDefine.To16Array(outShort, ibuf);
            AudioProcessingDll.amr_enc(outShort, ibuf.Length);
            IntPtr ptr = IntPtr.Zero;
            int    len = AudioProcessingDll.next_enc(ref ptr);

            Marshal.Copy(ptr, outByte, 0, len);
            return(outByte);
        }
Ejemplo n.º 4
0
 public void StartRecord(int recordId)
 {
     _currentRecord = _recodMap[recordId];
     TryGetMicrophonePermission();
     _currentRecord.StartRecord();
     _maxlen = AudioDefine.FREQUENCY * AudioDefine.MIC_BUFF_LEN;
     _processing.Init();
     Microphone.End(null);
     _mclip = Microphone.Start(null, true, AudioDefine.MIC_BUFF_LEN, AudioDefine.FREQUENCY);
     AudioProcessingDll.ForceToSpeaker();
 }
Ejemplo n.º 5
0
 public void Clean()
 {
     if (_isInit)
     {
         AudioProcessingDll.WebRtcFree();
         _isInit = false;
     }
     if (_amrIsInit)
     {
         AudioProcessingDll.amr_exit();
         _amrIsInit = false;
     }
 }
Ejemplo n.º 6
0
        public void Init()
        {
            if (_isInit)
            {
                return;
            }
            o_source160 = new float[AudioDefine.G_FRAME_SIZE];
            g_source    = new short[AudioDefine.G_FRAME_SIZE];
            o_source    = new short[AudioDefine.G_FRAME_SIZE];
            AudioProcessingDll.WebRtcInit(AudioDefine.NS_POLICY, AudioDefine.ECHO_MODE);

            _isInit = true;
        }
Ejemplo n.º 7
0
        public static short[] DeFramesOutShot(byte[] ibuf)
        {
            IntPtr ptr = IntPtr.Zero;
            int    pos = 0;

            AudioProcessingDll.amr_dec(ibuf, ibuf.Length);
            int len = AudioProcessingDll.next_dec(ref ptr);

            while (len != -1)
            {
                Marshal.Copy(ptr, outShort, pos, len);
                pos += len;
                len  = AudioProcessingDll.next_dec(ref ptr);
            }
            return(outShort);
        }
Ejemplo n.º 8
0
        public float[] Processing4(float[] audioSource, ref int vad)
        {
            if (!_isInit || i_data == null)
            {
                return(audioSource);
            }
            AudioDefine.To16Array(g_source, audioSource);
            IntPtr ptr = IntPtr.Zero;

            AudioProcessingDll.WebRtc_BufferFarend(GetListerBuff());
            vad = AudioProcessingDll.Process(g_source, ref ptr, AudioDefine.MS_IN_SEND_CARDBUF);
            Marshal.Copy(ptr, o_source, 0, AudioDefine.G_FRAME_SIZE);
            AudioDefine.ToFArray(o_source160, o_source);

            return(o_source160);
        }
Ejemplo n.º 9
0
        public static short[] GetListerBuff()
        {
            IntPtr ptr = IntPtr.Zero;

            AudioListener.GetOutputData(f_listenerBuff, 0);
            int index = 0;

            for (int i = 0; i < s960_listenerBuff.Length; i++)
            {
                s960_listenerBuff [i] = (short)(f_listenerBuff [i] * AudioDefine.RESCALE_FACTOR);
            }

            AudioProcessingDll.WebRtc_Resample48khzTo8khz(s960_listenerBuff, ref ptr);
            Marshal.Copy(ptr, o_source, 0, AudioDefine.G_FRAME_SIZE);

            return(o_source);
        }
Ejemplo n.º 10
0
 public float[] Processing(float[] audioSource, ref int vad)
 {
     if (!_isInit)
     {
         return(o_source160);
     }
     AudioDefine.To16Array(g_source, audioSource);
     if (_delayFreamSize <= 0)
     {
         IntPtr ptr = IntPtr.Zero;
         vad = AudioProcessingDll.Process(g_source, ref ptr, AudioDefine.MS_IN_SEND_CARDBUF);
         Marshal.Copy(ptr, o_source, 0, AudioDefine.G_FRAME_SIZE);
         AudioDefine.ToFArray(o_source160, o_source);
     }
     else
     {
         _delayFreamSize--;
     }
     AudioProcessingDll.WebRtc_BufferFarend(g_source);
     return(o_source160);
 }