本文介绍了在 .NET Core 中录制音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所暗示的,我希望从 .NET Core 中的麦克风捕获音频.对我来说重要的是它是跨平台的.我已经在 Windows、Linux 和 OSX 上的 OpenCV 中进行了大量视频处理.音频对我来说是一块缺失的拼图.
As the title suggests, I'm looking to capture audio from a microphone in .NET Core. It's important for me that it's cross platform. I'm doing a lot of video processing in OpenCV on Windows, Linux and OSX already. Audio is a missing piece of the puzzle for me.
推荐答案
OpenTK.NETCore 是一个非常好的 OpenTK 跨平台端口.
OpenTK.NETCore is a really good cross platform port for OpenTK.
使用它的 AudioCapture
类,我已经能够在不同的操作系统平台上捕获麦克风数据.
Using it's AudioCapture
class I have been able to capture microphone data across different OS platforms.
using (var audioCapture = new AudioCapture(_recorders.First(), _sampling_rate, ALFormat.Mono16, buffer_length_samples))
{
audioCapture.Start();
int available_samples = audioCapture.AvailableSamples;
_buffer = _pool.Rent(MathHelper.NextPowerOfTwo((int)((available_samples * _sampleToByte / (double)BlittableValueType.StrideOf(_buffer)) + 0.5)));
if (available_samples > 0)
{
audioCapture.ReadSamples(_buffer, available_samples);
}
else
{
_pool.Return(_buffer);
}
}
基于 OpenTK 示例中的 Parrot
项目.
Based on Parrot
project in OpenTK samples.
这篇关于在 .NET Core 中录制音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!