public IList <AudioBeamFrame> AcquireLatestBeamFrames()
        {
            if (_pNative == RootSystem.IntPtr.Zero)
            {
                throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader");
            }

            var outCollectionSize = Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames_Length(_pNative);
            var outCollection     = new RootSystem.IntPtr[outCollectionSize];
            var managedCollection = new AudioBeamFrame[outCollectionSize];

            outCollectionSize =
                Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames(_pNative, outCollection, outCollectionSize);
            ExceptionHelper.CheckLastError();
            for (var i = 0; i < outCollectionSize; i++)
            {
                if (outCollection[i] == RootSystem.IntPtr.Zero)
                {
                    continue;
                }

                var obj = NativeObjectCache.CreateOrGetObject(outCollection[i],
                                                              n => new AudioBeamFrame(n));

                managedCollection[i] = obj;
            }

            return(managedCollection);
        }
Beispiel #2
0
        /*
         * TW: hacked this in here becuase there is currentl no way to release the resources from AcquireLatestBeamFrames
         * Also Kinect v2 on Windows only ever gives 1 frame. You don't really need the list from AcquireLatestBeamFrames. As I understand it.
         */

        public AudioBeamFrame AcquireLatestBeamFrame()
        {
            if (_pNative == RootSystem.IntPtr.Zero)
            {
                throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader");
            }

            int outCollectionSize = Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames_Length(_pNative);
            var outCollection     = new RootSystem.IntPtr[outCollectionSize];

            //var managedCollection = new Windows.Kinect.AudioBeamFrame[outCollectionSize];

            outCollectionSize = Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames(_pNative, outCollection, outCollectionSize);
            Helper.ExceptionHelper.CheckLastError();
            AudioBeamFrame obj = null;

            for (int i = 0; i < outCollectionSize; i++)
            {
                if (outCollection[i] == RootSystem.IntPtr.Zero)
                {
                    continue;
                }

                obj = Helper.NativeObjectCache.CreateOrGetObject <Windows.Kinect.AudioBeamFrame>(outCollection[i], n => new Windows.Kinect.AudioBeamFrame(n));

                //managedCollection[i] = obj;
            }
            return(obj);
        }
        // Token: 0x06002A7F RID: 10879 RVA: 0x000D7AF8 File Offset: 0x000D5EF8
        public IList <AudioBeamFrame> AcquireLatestBeamFrames()
        {
            if (this._pNative == IntPtr.Zero)
            {
                throw new ObjectDisposedException("AudioBeamFrameReader");
            }
            int num = AudioBeamFrameReader.Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames_Length(this._pNative);

            IntPtr[]         array  = new IntPtr[num];
            AudioBeamFrame[] array2 = new AudioBeamFrame[num];
            num = AudioBeamFrameReader.Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames(this._pNative, array, num);
            ExceptionHelper.CheckLastError();
            for (int i = 0; i < num; i++)
            {
                if (!(array[i] == IntPtr.Zero))
                {
                    AudioBeamFrame audioBeamFrame = NativeObjectCache.CreateOrGetObject <AudioBeamFrame>(array[i], (IntPtr n) => new AudioBeamFrame(n));
                    array2[i] = audioBeamFrame;
                }
            }
            return(array2);
        }
Beispiel #4
0
 // Token: 0x06002894 RID: 10388 RVA: 0x000D2074 File Offset: 0x000D0474
 private void Dispose(bool disposing)
 {
     if (this._pNative == IntPtr.Zero)
     {
         return;
     }
     if (this._subFrames != null)
     {
         foreach (AudioBeamSubFrame audioBeamSubFrame in this._subFrames)
         {
             audioBeamSubFrame.Dispose();
         }
         this._subFrames = null;
     }
     this.__EventCleanup();
     NativeObjectCache.RemoveObject <AudioBeamFrame>(this._pNative);
     AudioBeamFrame.Windows_Kinect_AudioBeamFrame_ReleaseObject(ref this._pNative);
     if (disposing)
     {
         AudioBeamFrame.Windows_Kinect_AudioBeamFrame_Dispose(this._pNative);
     }
     this._pNative = IntPtr.Zero;
 }
Beispiel #5
0
 // Token: 0x06002893 RID: 10387 RVA: 0x000D2058 File Offset: 0x000D0458
 internal AudioBeamFrame(IntPtr pNative)
 {
     this._pNative = pNative;
     AudioBeamFrame.Windows_Kinect_AudioBeamFrame_AddRefObject(ref this._pNative);
 }
Beispiel #6
0
    private void ProcessAudioFrame()
    {
        IList <AudioBeamFrame> frameList = audioReader.AcquireLatestBeamFrames();

        //AudioBeamFrameList frameList = (AudioBeamFrameList)reader.AcquireLatestBeamFrames();

        if (frameList != null)
        {
            if (frameList[0] != null)
            {
                if (frameList[0].SubFrames != null && frameList[0].SubFrames.Count > 0)
                {
                    // Only one audio beam is supported. Get the sub frame list for this beam
                    List <AudioBeamSubFrame> subFrameList = frameList[0].SubFrames.ToList();

                    // Loop over all sub frames, extract audio buffer and beam information
                    foreach (AudioBeamSubFrame subFrame in subFrameList)
                    {
                        // Check if beam angle and/or confidence have changed
                        bool updateBeam = false;

                        if (subFrame.BeamAngle != this.beamAngleRad)
                        {
                            this.beamAngleRad = subFrame.BeamAngle;
                            this.beamAngleDeg = this.beamAngleRad * 180.0f / Mathf.PI;
                            updateBeam        = true;

                            //Debug.Log("beam angle: " + beamAngleDegrees);
                        }

                        if (subFrame.BeamAngleConfidence != this.beamAngleConfidence)
                        {
                            this.beamAngleConfidence = subFrame.BeamAngleConfidence;
                            updateBeam = true;

                            //Debug.Log("beam angle confidence: " + beamAngleRadians);
                        }

                        if (updateBeam)
                        {
                            // Refresh display of audio beam
                            if (statusText)
                            {
                                statusText.text = string.Format("Audio beam angle: {0:F0} deg., Confidence: {1:F0}%", beamAngleDeg, beamAngleConfidence * 100f);
                            }
                        }
                    }
                }
//                else
//                {
//                    this.beamAngle = frameList[0].AudioBeam.BeamAngle;
//                    Debug.Log("No SubFrame: "+ frameList[0].AudioBeam.BeamAngle);
//                }
            }
//            else
//            {
//                Debug.Log("Empty Audio Frame: "+ audioSource.AudioBeams.Count());
//                if (audioSource.AudioBeams.Count() > 0)
//                    Debug.Log(audioSource.AudioBeams[0].BeamAngle);
//
//            }
        }
//        else
//        {
//            Debug.Log("Empty Audio Frame");
//        }

        // clean up
        for (int i = frameList.Count - 1; i >= 0; i--)
        {
            Windows.Kinect.AudioBeamFrame frame = frameList[i];

            if (frame != null)
            {
                frame.Dispose();
            }
        }

        //frameList.Clear();
    }