Cross-platform audio library for .NET [closed]
Asked Answered
K

2

13

Requirements:

  • Get raw input from a microphone in real time
  • Play that raw input back in real time

I can't seem to find much from Googling about it. Has anyone used something like that?

I'm using C#, and it needs to work on Windows, Linux, and Mac, the latter two with Mono.

I might be willing to use p/invoke, but I'm not especially familiar with native code and it would be tough. If someone can suggest a native library, I'll give it a shot.

Kopaz answered 30/3, 2013 at 2:12 Comment(3)
I bet this post will be closed soon, as some guys at stackoverflow are biased to think these kind of post is useless, and they always close these, but I think it is important. I will give an upvote.Microcline
C# SDL might work as SDL is portable across mac windows and linux. Not sure if the C# wrapper works with mono. cs-sdl.sourceforge.netParquet
I'm not seeing mic support in there. Thanks, though.Kopaz
A
6

ManagedBass is new .NET Cross-Platform wrapper for un4seen Bass library with MIT license. It's not only wrapper - it has also objective API. Take a look at this blog post.

Here's example of playing file using wrapper API:

using ManagedBass;

class Program
{
    static void Main()
    {
        Bass.Init(); // Initialize with default options.

        int handle = Bass.CreateStream("YOUR_FILE.mp3");

        Bass.ChannelPlay(handle); // Begin Playback.

        Console.ReadKey(); // Wait till user presses a Key.

        Bass.ChannelStop(handle); // Stop Playback.

        Bass.ChannelFree(handle); // Free the Stream.

        Bass.Free(); // Free the device.
    }
}

Here's the same using objective API:

using ManagedBass;

class Program
{
    static void Main()
    {
        using (var Player = new MediaPlayer()) // Create a Player.
        {
            Player.Load("YOUR_FILE.mp3"); // Load a file.

            Player.Start(); // Begin Playback.

            Console.ReadKey();
        }
    }
}
Arondell answered 14/5, 2016 at 20:58 Comment(2)
I added example code for each APIArondell
Unfortunately, the blog post is dead. I suggest Bass.Net, as there is barely any documentation on ManagedBass and I was not able to get it to run, due to unclear dependecies.Lignocellulose
H
2

BASS.NET is supposed to be cross-platform with mono, and you can do what you're asking using it, as in this SO answer: https://mcmap.net/q/908303/-reading-the-system-audio-output-stream

http://bass.radio42.com/

Hyla answered 30/3, 2013 at 2:38 Comment(1)
That's a very restrictive license. I'll keep this one in mind, but I'd prefer an alternative.Kopaz

© 2022 - 2024 — McMap. All rights reserved.