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 ;-)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With