This project is a cross-platform .NET Core/Standard 3D audio engine based on OpenAL.
- Based on the OpenAL 1.1 specification
- Multiple output and sound capture devices
- Full 3D sound support with different distance models, pitch shifting and other stuff
- Bundled with PCM WAV, OGG and MP3 importers (thanks to NLayer and NVorbis)
For runnable examples check out the Samples directory.
var outputDevice = new OutputDevice();
...
var buffer = Wav.Load("never_gonna_give_you_up.wav");
...
var source = new SoundSource();
source.Enqueue(buffer);
source.Play();
var inputDevice = new CaptureDevice();
...
inputDevice.StartCapture();
...
var samples = new byte[0];
// If you're running it in a game loop, you don't need a while loop here
// Just allocate a big enough buffer and reuse it
while (something)
{
inputDevice.ProcessSamples((data, bytesRead) =>
{
var oldSize = samples.Length;
Array.Resize(ref samples, oldSize + bytesRead);
Array.Copy(data, 0, samples, oldSize, bytesRead);
});
Thread.Sleep(100);
}
...
inputDevice.StopCapture();
...
// Do something with the samples array
// Put the data from it in a SoundBuffer, for example
Check out the SoundSource and Listener API documentation to take a look at what you can do.
See the OpenAL.NETCore project.