gpt4 book ai didi

c# - 使用NAudio从Kinect捕获音频

转载 作者:行者123 更新时间:2023-12-03 02:14:11 25 4
gpt4 key购买 nike

我编写了以下代码,该代码应该从Kinect捕获4声道音频。但是,当我尝试播放文件时,音频速度似乎会大大提高。关于为什么会发生这种情况的任何想法,或对此问题的可能解决方案?

public void Record4channels()
{
// recording length = 5 seconds
int recordingLength = (int)5 * 4 * 16000*2;
int count, totalCount = 0;

// sample rate: 16 KHz, bits/ sample : 16, Channel count : 4
var format = new NAudio.Wave.WaveFormat(16000, 16,4);

var audio = new byte[format.AverageBytesPerSecond];

using (var writer = new NAudio.Wave.WaveFileWriter("c:\\kinectAudio2.wav",format))
{

using (Stream audioStream = this.sensor.AudioSource.Start())
{
while ((count = audioStream.Read(audio, 0, audio.Length)) > 0 && totalCount < recordingLength)
{
writer.Write(audio, 0, count);
totalCount += count;
}
}
}
}

最佳答案

也许每个样本的位数是32,而不是16。

我已经在Linux中用freenect录制了音频。这是soxi的输出:

输入文件:“test.wav”
channel :4
采样率:16000
精度:32位
持续时间:00:00:03.68 = 58880个样本〜276个CDDA扇区
文件大小:942k
比特率:2.05M
样本编码:32位带符号整数PCM

关于c# - 使用NAudio从Kinect捕获音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21364625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com