3

我想让 kinect 只接收直接在它前面的用户的语音。我不希望检测到噪音或左右两侧说话的人。或者,如果用户移动到 kinect 的右侧或左侧。这可能吗?

var audioSource = this.Kinect.AudioSource;
audioSource.BeamAngleMode = BeamAngleMode.Adaptive;
var kinectStream = audioSource.Start();

我玩过 ManualBeamAngle,但不认为那是我想要的。

任何帮助,将不胜感激。cp

4

1 回答 1

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)为我们做这件事。希望这可以帮助!

于 2012-08-22T21:36:25.073 回答