Coder Social home page Coder Social logo

Comments (5)

czesiu avatar czesiu commented on May 18, 2024 7

I did own research and I found following libraries/solutions:

  • BASS.NET - .NET wrapper (P/Invoke) for multiplatform un4seen BASS audio library
  • ManagedBass - also wrapper for BASS audio library, but with non restrictive license as BASS.NET. Additionally all P/Invoke part is in PCL library.
  • OpenAL and OpenTK - OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications. OpenTK is a C# wrapper for OpenAL and OpenGL.
  • Gstreamer# - I found this probably on stack overflow. Looks outdated. Looks like P/Invoke bindings to gstreamer library. Banshee is a open source application which uses gstreamer under the hood.
  • Vorbis# - OggVorbis decoder written purely in C#. Not an audio library, but can be used with System.Media.SoundPlayer to play ogg files.
  • PortAudioSharp - .NET bindings (P/Invoke) for the cross-platform low-latency audio library PortAudio.
  • irrKlang - high level 2D and 3D cross platform (Windows, Mac OS X, Linux) sound engine and audio library.

Here's stack overflow question with some of this libraries mentioned: http://stackoverflow.com/questions/35896/how-can-i-play-compressed-sound-files-in-c-sharp-in-a-portable-way

I tested only BASS.NET and ManagedBass and they are working with .NET Core on Mono.

Most of these C# libraries are only P/Invoke bindings to some multiplatform C library. I like ManagedBass because it has PCL library which is .NET Core compatible (DNX and DNX Core environments). BASS.NET (and probably other mentioned libraries) have only full .NET version, so I can run it only with #if DNX451 switches and only in Mono runtime. With PCL ManagedBass I have code without #if DNX451 switches which compiles properly for DNX and DNX Core version.

But there is one issue in DNX Core, from which reason I can run ManagedBass only on Mono. This issue is related with name of P/Invoked library. Binding in PCL library looks like that:
[DllImport("bass", EntryPoint = "BASS_Start")]
public static extern bool Start();
and because this is a PCL, then name of library in a code must be same for all platforms. But library name in various platforms is different, e.g. "libbass.so" in Linux and "bass.dll" in Windows.
Mono has automatic library mapping mechanism described here (there is also manual mechanism described here).
Is there similar mechanism in DNX Core runtime or do you have plans for adding it?

from core.

AlexChesser avatar AlexChesser commented on May 18, 2024

Hey @czesiu it's an interesting question and I have to admit that I don't know the answer, but I did a bit of hunting to find out, and I suspect that answer is "no for now, probably in future". Though I'd also suspect that even the "no" might be supported by a third party somewhere.

If you look at the stack overflow answers for "how do I play sound with C#" you see people talking about the System.Media namespace:

and if you go into the dotnet API reference you see that system.media isn't there yet:

If you search the dotnet forums for Audio - you get a couple leads in terms of third party products that might be worth looking at in more detail: https://github.com/reignstudios/ReignSDK

And you can also look towards UNITY (perhaps)

If I start to dig around a bit more, things start to get hazier. Sorry I can't be more help. It's an interesting question.

from core.

mellinoe avatar mellinoe commented on May 18, 2024

Right now, there's no "high-level" API for audio playback. If you are adventurous, you can try things like OpenTK, which expose lower-level OpenAL functionality. This will be much more difficult than something ready-to-go like System.Media.SoundPlayer, but will be cross-platform and much more flexible.

Disclaimer: I've never tried to use the OpenAL functionality of OpenTK on .NET Core. I've only used the graphics portions of the library.

from core.

czesiu avatar czesiu commented on May 18, 2024

Do you have plans for adding DllMap (automatic or/and manual) mechanism in CoreCLR?

from core.

n9 avatar n9 commented on May 18, 2024

@czesiu Maybe ask in a new issue.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.