Welcome! This is the place you want to be if you’re first getting started with the WPF Sound Visualization Library!
While it isn’t entirely necessary to know about digital signal processing, it will help in understanding what sort of data these controls required. One concept, in particular, that you’ll see recurring is that of acquiring FFT data. “FFT”
stands for “fast Fourier transform” and it is the way computers transform time-domain information into frequency domain information. Different sound/DSP libraries will present their FFT data in different ways, so understanding what that data actually
means will help you in getting it into the right form for this control library to use. I encourage you to
read more on fast Fourier transforms.
Step 1 – Choose Your Sound Library
The first thing you’ll want to understand is that the WPF Sound Visualization Library (WPFSVL) is meant to work with any source of sound stream data that you feed it. To accommodate this, the architecture may be little more complicated
than some more common Windows controls. Controls like the Album Art Display are very straight-forward and easy to drop in and use, but controls like the Spectrum Analyzer and Waveform Timeline require you to feed them some sort of sound player object. More
on that in a bit.
Before you begin with using these controls, you’ll be tasked with getting some sort of sound-processing code going. You could choose to write your own, but this is a pretty large task. I personally recommend you choose from one of the two big .NET
sound libraries out there. One option, and the one I personally use, is to use the
BASS sound library with the
BASS.NET wrapper to enable .NET support. Another popular option is to use the
NAudio sound library. I’ll be including some instructions on getting the controls going with both of these libraries. These are far from your only two options, however, so I encourage you to explore your options.
Step 2 – Understanding WPF SVL’s Architecture
Some WPFSVL control’s can just be dropped into your Window and used. Others will require you to register them with a sound player before you can have them start rendering fancy-looking sound data. The controls that require sound players will follow
a similar architecture. There’s two parts to this:
- Each control that requires a sound player will have an interface the sound player is required to implement. For the Spectrum Analyzer, this is
ISpectrumPlayer. For the Waveform Timeline, this is IWaveformPlayer.
- Once your sound player implements the necessary interfaces, you need to register them with the control. This is done by calling
<Control>.RegisterSoundPlayer() and passing it your sound player.
Beyond that, WPF SVL also requires that your sound player implement INotifyPropertyChanged so that it can get update notifications for the properties it needs.
Step 3 – Coding Your Sound Player
This is where things will get more specific to the sound engine you’re using. I’m providing two examples of sound players that are compatible with WPFSVL, one for each of the two major sound libraries.
Step 4 – Adding WPFSVL Controls and Providing Themes!
We’re almost there! All you really have to do now is add the controls to your Window and register your sound players with each of the controls as mentioned in Step 2. The last thing you’ll want to do, even though it isn’t absolutely required,
is customize the look of your controls a bit. Colors and functionality can be set via some of the Control’s dependency properties. More complex layout changes can be made by creating a custom
ControlTemplate for the Controls. All of the controls support this. Check out the Sample Applications for some examples of this in the context of different themes!