Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-platform audio library for .NET [closed]

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.

like image 611
Drew DeVault Avatar asked Mar 30 '13 02:03

Drew DeVault


1 Answers

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();
        }
    }
}
like image 67
czesio Avatar answered Sep 25 '22 08:09

czesio