Unity Kinect v2音频输入

编程入门 行业动态 更新时间:2024-10-27 19:30:34
本文介绍了Unity Kinect v2音频输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在努力让音频输入与团结一致。身体追踪工作正常。我按照音频基础教程进行了调整,并以类似于Body教程的方式对其进行了调整。

I am trying to get audio input to work for with unity. Body tracking works fine. I followed the audio basics tutorial and adapted it for unity in a similar way to the Body tutorial was done.

这是我当前代码的一小部分。即使_AudioReader.AcquireLatestBeamFrames();返回一个非空列表,它始终只有一个元素在列表中,为null。想法?

Here is a snippet of my current code. Even though _AudioReader.AcquireLatestBeamFrames (); returns a non null list, it always only has one element in the list, which is null. Ideas?

void Start () { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { _Reader = _Sensor.BodyFrameSource.OpenReader(); if (!_Sensor.IsOpen) { _Sensor.Open(); } //initialize audio reader var audioSource = _Sensor.AudioSource; this.audioBuffer = new byte[audioSource.SubFrameLengthInBytes]; _AudioReader = _Sensor.AudioSource.OpenReader (); } } void Update () { if (_Reader != null) { var frame = _Reader.AcquireLatestFrame (); if (frame != null) { if (_Data == null) { _Data = new Body[_Sensor.BodyFrameSource.BodyCount]; } frame.GetAndRefreshBodyData (_Data); frame.Dispose (); frame = null; } } if (_AudioReader != null) { var audioFrames = _AudioReader.AcquireLatestBeamFrames (); if (audioFrames != null) { // it gets here just fine if (audioFrames [0] != null) { // it never gives me any audio frames! var subFrameList = audioFrames [0].SubFrames; foreach (AudioBeamSubFrame subFrame in subFrameList) { // Check if beam angle and/or confidence have changed bool updateBeam = false; if (subFrame.BeamAngle != this.beamAngle) { this.beamAngle = subFrame.BeamAngle; updateBeam = true; } if (subFrame.BeamAngleConfidence != this.beamAngleConfidence) { this.beamAngleConfidence = subFrame.BeamAngleConfidence; updateBeam = true; } if (updateBeam) { // Refresh display of audio beam this.AudioBeamChanged (); } // Process audio buffer

推荐答案

它至少工作一次还是什么都没发生?你是如何处理audioFrames对象或subFrameList的?

Does it work at least once or nothing happens at all? How are you disposing the audioFrames object or subFrameList?

var audioFrames = _AudioReader.AcquireLatestBeamFrames ();

var subFrameList = audioFrames [ 0 ]。 子框架 ;

与所有框架对象一样,它们必须处理,这可能是这里的问题。 subFrameList应该是AudioBeamFrame类型,它有.Dispose(),以及audioFrames [ 0 ] 。从AcquireLatestBeamFrames返回的集合可能是问题,因为它没有Dispose,但您可以投射它(未测试)。我将调查这个并将其报告给团队。

As with all the frame objects they have to be disposed which might be the issue here. subFrameList should be of type AudioBeamFrame which has a .Dispose(), as well as, audioFrames [0]. The returned collection from AcquireLatestBeamFrames may be the issue since that does not have a Dispose, but you may be able to cast it(not tested). I will look into this and report it to the team.

更多推荐

Unity Kinect v2音频输入

本文发布于:2023-08-01 18:45:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1270754.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:音频输入   Unity   Kinect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!