Could the SpectrumAnalyzer be compatible with the default audio device output?

Jun 14, 2012 at 5:09 PM

Implementing a volume slider in WPF and thought it would be a "nice to have" to show a real-time spectrum analyzer ( just one bar, with peak falloffs).  I saw that you have to register the control with something that implements the interface ISpectrumPlayer. More or less it just needs FFT data to read.  I am having trouble finding an answer to my question elsewhere on the interwebs so I thought I'd drop by and ask and also congratulate you on a very nice library.


Jun 14, 2012 at 5:39 PM

I think you're asking a few things here, so correct me if I'm wrong.

First, you're wondering if you could somehow intercept the default output audio on your PC and display an "active" volume level - similar to what is shown in the system volume panel. Is that correct? That answer varies slightly based on whether you're using Vista or above (where you are dealing with audio endpoints), or Windows XP. Either way, you can find info here:

Secondly, you're asking about how you might display that data. If you're talking a single bar, then you don't need FFT data or a spectrum analyzer. I think what you're thinking of would be more considered a "VU Meter". And, instead of doing all sorts of extra work to break it down into Frequency Bands with FFT, you just need to store the maximum level. This is generally the absolute value of any sample in your stream (absolute value because of negative and positive sound pressure). If you're dealing with floating point data, this would be somewhere between 0.0 and 1.0

Hope some of this helps!

Jun 14, 2012 at 8:32 PM

Thanks for the super-fast response.  And you're right, I was about to over-engineer the hell out of this.  I'm already using some interop to enforce the master volume scalar and these peak values are actually build in the MMdevice.  I've just exposed it and attached a dispatcher timer to refresh it at my desired interval and it seems to be working great. I'm only slightly disappointed in the performance of the ProgressBar and it's ability to render on fluidly at 33ms update intervals.

Jun 28, 2012 at 3:15 PM

I am facing a problem similar to GEN3RIC's.As my current project I am building an Applet for the Logitech G19 with C# and WPF and until now everything works. I am able to read Winamp's currently playing song, tags, etc. For getting the visualization to display I fortunately found your great control, but I'm somehow not able to get it to work as I want. When adding the control to my main window and call the audioengine.OpenFile(pathfromfile) and then Play() everything works as expected: the visualization does its job. Fine!

But now I want to visualize the currently playing track (ex. playing in Winamp), but I'am not able to get the data needed. I tried different approaches, like get the current audio via waveIndevice (working with NAudio) , writing it into a temporary memorystream and so on, but all attemps failed.

What am I doing wrong, or is it even impossible to do this with NAudio/your control?


Would be very glab about any advice/hint/code snippet to get this problem solved!

Thanks in advance and greeting from Germany!


Jun 28, 2012 at 3:24 PM


For that scenario, you should be using the WinAmp APIs to feed you sound data! They may even do the FFT calculation for you. Don't try to get the data from the global audio space, but directly from Winamp. I wrote a plugin very similar to what you're trying to do for the Logitech G15 and keyboard and Foobar 2000 like six years ago:

Jun 28, 2012 at 4:47 PM

That means it will work with winamp only, but not with WMP or other players and it needs an additional winamp-plugin, right?! Too bad, but maybe it's the only way to get some visualization on  the display.


Jun 28, 2012 at 5:00 PM

Yeah, it's unfortunate, but doing what you want to do is not a trivial problem to solve. There are commercial products out there that focus on doing essentially what you're trying to do (GoldWave is one of them). I'd love to see a nice writeup on how to capture all the audio going out to the default endpoint, and I think it is something Microsoft should support a little better, but I don't currently know of a simple way. Let me know if you find something!