我想让kinect只接听直接位于其前面的用户的语音。 我不希望检测到噪音或人们在右边或左边说话。 或者,如果用户移动到kinect的右侧或左侧。 这可能吗?
var audioSource = this.Kinect.AudioSource;
audioSource.BeamAngleMode = BeamAngleMode.Adaptive;
var kinectStream = audioSource.Start();
我玩过ManualBeamAngle,但不认为这就是我想要的。
任何帮助将不胜感激。 CP
答案 0 :(得分:3)
你可以使用Source角度找到它,它们在中间时都是0。请参阅Audio Basics - WPF,并将代码更改为:
double sourceAngle;
...
private void AudioSourceBeamChanged(object sender, BeamAngleChangedEventArgs e)
{
beamRotation.Angle = -e.Angle;
sourceAngle = e.Angle;
beamAngleText.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.BeamAngle, e.Angle.ToString("0", CultureInfo.CurrentCulture));
}
private void AudioSourceBeamChanged(object sender, BeamAngleChangedEventArgs e)
{
beamRotation.Angle = -e.Angle;
beamAngleText.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.BeamAngle, e.Angle.ToString("0", CultureInfo.CurrentCulture));
}
private void AudioReadingThread()
{
// Bottom portion of computed energy signal that will be discarded as noise.
// Only portion of signal above noise floor will be displayed.
const double EnergyNoiseFloor = 0.2;
while (this.reading)
{
while (sourceAngle == 0) //this is the important part
{
int readCount = audioStream.Read(audioBuffer, 0, audioBuffer.Length);
// Calculate energy corresponding to captured audio in the dispatcher
// (UI Thread) context, so that rendering code doesn't need to
// perform additional synchronization.
Dispatcher.BeginInvoke(
new Action(
() =>
{
for (int i = 0; i < readCount; i += 2)
{
// compute the sum of squares of audio samples that will get accumulated
// into a single energy value.
short audioSample = BitConverter.ToInt16(audioBuffer, i);
this.accumulatedSquareSum += audioSample * audioSample;
++this.accumulatedSampleCount;
if (this.accumulatedSampleCount < SamplesPerColumn)
{
continue;
}
// Each energy value will represent the logarithm of the mean of the
// sum of squares of a group of audio samples.
double meanSquare = this.accumulatedSquareSum / SamplesPerColumn;
double amplitude = Math.Log(meanSquare) / Math.Log(int.MaxValue);
// Renormalize signal above noise floor to [0,1] range.
this.energy[this.energyIndex] = Math.Max(0, amplitude - EnergyNoiseFloor) / (1 - EnergyNoiseFloor);
this.energyIndex = (this.energyIndex + 1) % this.energy.Length;
this.accumulatedSquareSum = 0;
this.accumulatedSampleCount = 0;
++this.newEnergyAvailable;
}
}));
}
}
sourceAngle == 0)
行为我们做了这件事。希望这有帮助!