Sound and Graphics


What a start to 2017. I’ve been extremely busy with work and it’s been exciting to work on innovative stuff. In the last couple of weeks I’ve been working extensively with DirectX (through SharpDX) and audio (through NAudio) and it’s the last one I want to discuss here.

Sound by NAudio is great

NAudio is fantastic. It’s easy to use, straightforward and just does what it’s supposed to. At work I’ve been able to rewrite our audio engine (based on DirectShow)  using Naudio and I’ve saved a lot of complexity and gained multiple features. Previously, every audio source had a separate output device. So there could easily be 5 streams to the default sound device, for example. In NAudio I simply used a MixingSampleProvider (discussed here and here by the author of NAudio himself) to mix all our audio sources. Then I’ve applied a simple compressor so now when outputting through WASAPI there are no volume differences.

Now, we output audio directly to BlackMagic DeckLink cards as well, so I’ve got some ‘middleware’ that handles all audio and sends it where it needs to go. An audio source just provides raw samples and the middleware takes care of resampling if necessary.

All this works very well, with very little code and low latency.

Graphics by SharpDX is great

SharpDX is also very good. It’s simply a wrapper for most DirectX calls but it does what it has to. There’s not much more to say about it 🙂

VLC through Meta.VLC

In our software we play videos as well. We were using a DirectShow based video player before which used to be a great way to play video but’s just a pain. You’re having to deal with filters, third party applications that add filters (ffdshow, LAV filters) and it’s all just a massive pain to set up. It takes a lot of code to get right, and even then you can usually only call ‘Run’ on a media control and it’ll start playing. You have no control whatsoever.

So, we switched to a VLC based player. Still third party sadly, but likely to remain active for the coming years. Everyone knows VLC – it supports all major media formats and supports streams. A good fit for our software. I’ve looked at multiple libraries to use, considered rolling our own libvlc bindings but then started using Vlc.DotNet. It can render to windows using handles but you can’t use VLC’s video and audio callbacks, which we needed.

So we found Meta.Vlc. It does support that kind of stuff the and the layer that Meta.Vlc provides is fairly thin, which we like. Figuring out how to get graphics rendering to line up with VLC was tougher than it first seemed to us, but we got it all fixed up now. Good stuff!


Learning something new everyday is extremely important and in the last couple of months I’ve learned a great deal about audio, video and everything in between.

Leave a comment

Your email address will not be published. Required fields are marked *