4

I would like to create a little application that plays back a music file (format doesn't really matter). The hard part is: at the same time I would like to display the current amplitude of the lower frequencies (bass), the middle frequencies and the high frequencies.

So I would need some kind of simple spectral analysis together with playback functionality. Is there a C# audio library that can do this without too much hassle?

The purpose of this project is to drive an RGB-LED lighting system I've recently installed in my room ;-)

Boris
  • 8,551
  • 25
  • 67
  • 120
  • 1
    http://stackoverflow.com/questions/4422983/best-open-source-project-for-audio-signal-processing –  Sep 27 '12 at 07:45

1 Answers1

10

NAudio : http://naudio.codeplex.com/ (Open source)

Bass and Bass.Net: http://www.un4seen.com/ (Free for non commercial)

Fmod Ex: http://www.fmod.org/index.html (Also free for non commercial use)

Doing what you need using Bass is very easy:

string filepath ="";
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, null);
int handle = Bass.BASS_StreamCreateFile(filepath, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT);
Bass.BASS_ChannelPlay(handle,false);

Then to get spectrum:

float[] buffer = new float[256];
Bass.BASS_ChannelGetData(handle, buffer, (int)BASSData.BASS_DATA_FFT256);

From there you can easily average bands for specific frequencies

mrvux
  • 8,523
  • 1
  • 27
  • 61