Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6670329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:15:19+00:00 2026-05-26T03:15:19+00:00

I have an audio player using NAudio and I would like to display a

  • 0

I have an audio player using NAudio and I would like to display a real time intensity for each frequency band.

I have an event triggered for each block of 1024 samples:

public void Update(Complex[] fftResults)
{
   // ??
}

What i would like to have is an array of numbers indicating the intensity of each frequency band. Lets say I would like to divide the window into 16 bands.

For example when there are more bass frequencies it could look like this:

░░░░░░░░░░░░░░░░
▓▓▓░░░░░░░░░░░░░
▓▓▓░░░░░░░░░░░░░
▓▓▓▓░░░░░░░░░░░░
▓▓▓▓▓░░░░░░░░░░░
▓▓▓▓▓▓▓▓░░░▓░░▓░

What should I put into that event handler if this is possible with that data?

Data coming (Complex[]) has already been transformed with the FFT.
It is a stereo stream.

First try:

double[] bandIntensity = new double[16] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

public void Update(Complex[] fftResults)
{
    // using half fftResults because the others are just mirrored
    int band = 0;
    for (int n = 0; n < fftResults.Length/2; n++)
    {
        band = (int)(.5 * n / fftResults.Length * bandIntensity.Length);
        bandIntensity[band] += Math.Sqrt(fftResults[n].X * fftResults[n].X + fftResults[n].Y * fftResults[n].Y);
        bandIntensity[band] /= 2;
    }
}

The above is doing something but I think too much goes into the first two bands, and I’m playing shakira which does not have that much bass.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:15:20+00:00Added an answer on May 26, 2026 at 3:15 am

    There are two separate issues that you probably want to address here:

    (1) Window Function

    You need to apply a window function to your data prior to the FFT, otherwise you will get spectral leakage which will results in a very smeared spectrum. One unpleasant side effect of spectral leakage is that if you have any kind of significant DC (0 Hz) component then this will result in the kind of 1/f shape that you are seeing on your bar graph.

    (2) Log amplitude/frequency axes

    Human hearing is essentially logarithmic in both the intensity and frequency axes. Not only that, but speech and music tend to have more energy in the lower frequency part of the spectrum. To get a more pleasing and meaningful display of intensity versus frequency we usually make both the magnitude and frequency axes logarithmic. In the case of the magnitude axis this is normally taken care of by plotting dB re full scale, i.e.

    magnitude_dB = 10 * log10(magnitude);
    

    In the case of the frequency axis you will probably want to group your bins into bands, which might each be an octave (2:1 frequency range), or more commonly for higher resolution, third octave. So if you just want 10 “bars” then you might use the following octave bands:

       25 -    50 Hz
       50 -   100 Hz
      100 -   200 Hz
      200 -   400 Hz
      400 -   800 Hz
      800 -  1600 Hz
     1600 -  3200 Hz
     3200 -  6400 Hz
     6400 - 12800 Hz
    12800 - 20000 Hz
    

    (assuming you have a 44.1 kHz sample rate and an upper limit on your audio input hardware of 20 kHz).

    Note that while having a magnitude (dB) intensity scale is pretty much mandatory for this kind of application, the log frequency axis is less critical, so you could try with your existing linear binning for now, and just see what effect you get from applying a window function in the time domain (assuming you don’t already have one) and converting the magnitude scale to dB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create an audio player using UITableView. Every song needs to
I have an audio file. I want to segment into 10 seconds each using
I have an audio player and I want to show the current time of
I'm using the jQuery audio player 'jPlayer', I have a loop which creates a
I have an audio player that I'm building using AVPlayer. Currently, I keep the
I am using AVAudioplayer to play some audio files. I have some controls like
I am making an app in which I have to open default audio player.
I have an mp3 player that sends MCI commands to play pause/ff/rw/stop the audio
I have an audio project I'm working on using BASS from Un4seen. This library
I have an Audio app using AVAudioPlayer on iOS. Whenever music is playing my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.