相关疑难解决方法(0)

将 Raspberry pi 上用 .NetCore C# 录制的音频保存到 Wav 文件

我发现很难找到一种方法将使用 OpenTk.NetStandard 捕获的音频存储到 NetCore C# 中正确的 .WAV 文件中。

我正在寻找一种在 Raspberry pi 上运行时有效的解决方案,因此 NAudio 或任何 Windows 特定方法都无法解决我的问题。

我发现了其他几个 SO 答案,它们展示了如何使用 opentk 捕获音频,但没有介绍如何将其存储在 wav 文件中。

这是代码的摘录,该代码应该从我从另一个问题中获取的麦克风中读取数据,我看到 AudioCapture 类是:

  const byte SampleToByte = 2;
  short[] _buffer = new short[512];
  int _sampling_rate = 16000;
  double _buffer_length_ms = 5000;
  var _recorders = AudioCapture.AvailableDevices;
  int buffer_length_samples = (int)((double)_buffer_length_ms  * _sampling_rate * 0.001 / BlittableValueType.StrideOf(_buffer));

  using (var audioCapture = new AudioCapture(_recorders.First(), _sampling_rate, ALFormat.Mono16, buffer_length_samples))
  {
      audioCapture.Start();
      int available_samples = audioCapture.AvailableSamples;        

      _buffer = new short[MathHelper.NextPowerOfTwo((int)(available_samples * SampleToByte / …
Run Code Online (Sandbox Code Playgroud)

opentk audio-capture .net-core

3
推荐指数
1
解决办法
2128
查看次数

标签 统计

.net-core ×1

audio-capture ×1

opentk ×1