I am looking to develop an app in C# WinRt, but was wondering what libraries are available for playback and for complicated manipulation. I am looking for a free library that allows for an extensive list of audio formats to be played (for example mp3, wma, wav, ogg, etc.) and also to be analyzed. Thats pretty much the basic functionality I would need. But if I could get picky, a library that can convert audio files between the formats would be handy. Doing a google search I came across the Naudio library, but it was not so greatly compatible with WinRt.Thanks for any tips or advice on this.
The current alpha build of NAudio 1.7 (available via NuGet) does contain a Windows RT assembly and the source code includes a simple demo of playback and recording as a Windows Store app. Since it uses Media Foundation, you'll be able to play most of the file types you suggested (although ogg won't be supported out of the box), and you can construct your audio pipeline to access the audio as floating point samples for analysis.
Things that aren't currently supported are using the Media Foundation encoders to encode, and the various reader/writer classes need to be re-written to use the WinRT asynchronous streams and File I/O APIs instead of the regular .NET ones. Hopefully these features will be added to the library soon.
Related
I am trying to merge an audio stream and a video stream into a single file, on the Uno Platform, particularly for WebAssembly.
I already know that the normal, desktop-only way is by calling ffmpeg, and I also found a C# only way for UWP here.
However, the code used Windows.Media.Editing which is not implemented in Uno.
I know there is a ffmpeg library port for WASM here, but I don't know how to call it from my Uno web application.
So are there any ways to merge an audio stream and a video stream to a single file, on the Uno platform for WASM?
Unfortunately, this API is not yet implemented in Uno Platform, so in this case you need to write platform-specific implementation.
If you have a JavaScript library available, which can provide the functionality you need, you can still call it from the C# code. There is a three-part tutorial in the Uno Platform docs on implementing C# - JS interop, so that may be helpful to get started.
Alternatively, in case you find an alternative implementation in C# on NuGet, you can install it for the supported platforms and use it in your code as well. To write platform-specific code, you can use #if conditionals like #if __WASM__ etc. - for full information see this documentation page.
Where I can found something suitable (library) for .NET 4.0 (C#) capable for following features:
+ Reading mp3/wav samples with direct access to samplebuffer of loaded samples? (for example I want to load mp3 sample and programatically add reverb, chorus, and more custom effects implemented by me)
+ Playing directly audio buffers (arrays of floats)
+ Saving audio buffers to disk as mp3 or wav
Some time ago i found ASIO for .NET and this only works with .NET 3.5, is there something for .NET 4.0? Thank's a lot for your help.
ASIO for .NET won't help you in the cracking of mp3 or wav files. The most modern API in Windows for doing this is Microsoft Media Foundation. These are all COM APIs though, so you're either going to be doing (perhaps painful) COM interop from .NET or (easier) writing a C++/CLI wrapper. If you go the C++/CLI wrapper, you will need to be aware of performance issues (especially with how critical latency is to audio programming).
I'm skeptical that you will get the audio latency you need when programming in .NET. A good audio driver (like ASIO) will get you down to <3ms of latency. So if you are targetting "live audio", you will need to be generating audio buffers quicker than that (unless you are fine with longer latencies). To put it this way, the "time intervals" that the Windows APIs deal with are in 100 nanosecond intervals :).
You likely don't want to have to crack the files yourself. It becomes tedious as it's not only just mp3 and wav. You also have to be aware of how the wav is formatted as well (to account for different bit rates, number of channels, etc.). Using Media Foundation, it will automatically load the write decoder for you, you just give it the file path. Check out this tutorial that shows opening an existing WAV file and writing a new WAV file. I just recently went down this path for a drum sequencer I'm creating, and it's not very painful at all (if you're familiar with COM programming).
The central component in MF that makes this possible is the MFSourceReader.
If you're wanting to play the audio after you modify it, you can look at the sample "RenderExclusiveEventDriven" in the Windows SDK (under "audio" I believe). That's what I did for the drum sequencer as well. Latency won't be an issue and you're just dealing with byte arrays, so manipulating the raw data becomes very easy. Though at this point, you can probably stick with the ASIO .NET route and just use that to play the raw data you get from MFSourceReader.
I don't think there are .NET wrappers around Media Foundation yet (though if somebody has done that work already, feel free to post here as it would be awesome to know).
I have a C# application and I would like to be able to read in a WMV file and then write out a WMV file with reduced resolution/quality.
Are there any built-in libraries for C# that can do this? Do I need the Windows Media Format SDK?
Does anyone have experience with this?
Can I use something like FFmpeg for this?
You will have to decode and re-encode ( = transcode) the file to do this. By doing so you will inherently reduce quality since you are working off an already compressed base.
One way to do it if you need a high degree of control is is with a DirectShow wrapper for C#, i.e. DirectShow.NET. then you just need to define a simple transcoding graph.
Actually the simplest way to do this is with Expression Encoder (the successor to Windows Media Encoder) which has a simple managed API and should do the job with much less effort than integrating DirectShow.
There's a summary article here. A simple transcoding job looks like this (sample from article, only presets changed):
MediaItem src = new MediaItem
(#"C:\WMdownloads\AdrenalineRush.wmv");
Job job = new Job();
job.MediaItems.Add(src);
job.ApplyPreset(Presets.VC1WindowsMobile);
job.OutputDirectory = #"C:\EncodedFiles";
job.Encode();
I don't think there are any classes in the .Net Framework which deal with transcoding WMV files.
But you can install the Windows Media 9 Encoder SDK and create appropriate objects in C# to do the conversion. See CodeProject.com - Convert MP3, MPEG, AVI to Windows Media Formats for a starting point. Even though that link starts with non-WMV files, the Windows Media Encoder doesn't restrict the input file format (at least when I've used the VBScript encoding batch file).
N.B If you use the WM9Encoder on Vista or Win7, you may need the hotfix - see TechNet - issues in using Windows Media Encoder 9 Series on Windows 7
Is there something like libmms, librtsp or xine-lib for C#?
I have been using the BASS library successfully for these types of streams.
It should be able to do it with the WMA plugin.
It's written in C/C++ , but there is a .NET wrapper available.
It also supports mp3 and ogg/aac (with plugins)
You may also try to host the Media Player, if the target is Windows Forms/WPF.
I'm looking at options for adding streaming video to a social web site written in ASP.NET/C#. I have a great deal of experience with Flash too, so I'm comfortable using FLV players, but I'd definitely go Silverlight if the right library is available.
The library would need to be able to encode user uploaded video in a web format.
I imagine playback will be Flash or Silverlight based.
It would need to create thumbnails of the video.
It would need to have server software for streaming the video or have some 3rd party way of doing so.
I don't mind paying a licensing fee for the software, so it does not have to be open source or free.
The license must allow use on a commercial web site.
The closest thing I have found is MediaSoft's offering. But I never heard of this company before starting my search and don't know anyone using their software. They seem to be using FFMPEG to perform encoding, which I heard can spawn legal issues for commercial web sites. Though I'm not very familiar with the licensing of FFMPEG myself so please correct me if I heard wrong.
Has anyone used MediaSoft? Any other video libraries that you have used that worked well? Did you just end up writing your own video encoding and serving library?
Not sure about Silverlight, but Flash will render both h.264 and FLV videos. FFMPEG can convert into both via liblame for FLV and x264 for h.264. It can also generate thumbnails.
It and the corresponding modules are licensed under the LGPL/GPL which means you can use FFMPEG to generate videos/thumbnails without restriction as long as you have the rights to the original movies that you're transcoding. The GPL/LGPL license restrictions only apply to the FFMPEG code/binaries which won't matter until you decide to distribute those binaries to other people.
In addition to the above answer, you can look at red5 as a streaming solution
http://osflash.org/red5