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 is a really good cross platform port for OpenTK.
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);
}
}
Edit: Based on Parrot
project in OpenTK samples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With