0

I made a spectrum analyzer, but I'm struggling to find a range where I can cover the most instruments, but also still make the bars visible.

I tried the range 20Hz - 800 Hz but seems like some songs I miss out on instruments. So, I tried to 20Hz - 2000 Hz.

I can see that drum and bass are in the lower region (20-200), I see that the piano is in the 400-700 range.

These are the ranges I show. The actual range I can show is up to 1/2 of the sample rate. (Most likely 24000 Hz)

Thus, the question arises "What frequency range fits the most songs in? Looking at Pop, Rock, House, Rap, etc."

Edit: I want to gain knowledge with a spectrum analyzer for my next project which is an Arduino with LEDs that change color based on the frequency of the music.

The current setup is done by Javascript and AnalyserNode which uses FFT algorithm to convert signals into dB values.

As for limit of the analyzer. It should make catch the most common frequencies.

12
  • 2
    You need to do a lot more research, as there is a vast difference between different instruments' frequeny ranges. Also bear in mind all instruments produce harmonics which makes their range incredibly different from what it nominally appears to be.
    – Tim
    Jul 8, 2020 at 18:47
  • It would help to answer the question if you could tell in more detail what do you want to achieve. What is the purpose or application of your spectrum analysis? Jul 8, 2020 at 21:15
  • also - can you add some detail about the problem of 'making the bars visible'? maybe that can be solved in a number of ways. Jul 8, 2020 at 22:13
  • The problem is that you have to distinguish the frequency range of the instruments themselves from the frequency range of the equipment they are amplified/recorded/played-back through. I think there are too many variables to give a direct answer unless you specify your precise setup. Jul 8, 2020 at 23:10
  • 1
    @Helper If you divided the frequency range into 16384 steps, presumably you could then combine some of those 'bins' into ranges of your own choice...? Jul 9, 2020 at 9:25

5 Answers 5

3

A piano can go all the way from A0 at 27.5Hz, up to C8 at 4186Hz (source). If you wanted to capture harmonics in the notes, that would imply you'd need to handle higher frequencies than that.

2
  • Useful source I didn't know piano could go up to 4186 Hz. Any chance you also have a usefull source for this for other instruments?
    – Helper
    Jul 9, 2020 at 8:48
  • @Helper Try orchestralibrary.com/reftables/rang.html but you will then have to look them up on the other site to find the frequencies.
    – Simon B
    Jul 9, 2020 at 12:56
7

Full audible spectrum is 20Hz - 20kHz.

Having said that, if you don't want to or can't stretch to 20kHz, the lowest I would recommend going is to 8kHz.

I think the main question here is: what is the purpose of the analyzer?

Also, depending on the application, consider asking in Signal Processing; you could probably get better answers there.

Hope this helps!

1
  • Thanks for your suggestion. I shall take a look there. The purpose is to learn how spectrum analyzers work. How frequencies work in music and what they show. The ultimate purpose is to create a lamp that changes LEDs based on the frequency of the music.
    – Helper
    Jul 9, 2020 at 8:33
3

The highest note on a piano is C8 and that's approximately 4186 Hz. So, it is really hard to understand what you are using as a criterion for the limits of your spectrum analyzer.

There are instruments that go higher than that. Regardless of this, you need to be able to sample higher than the harmonics that would normally get excited in real life or you will cause aliasing and generate false note detection within your instrument range.

You have not provided nearly enough info to determine what a good range is but if your limits will be used to set a max sampling frequency then I'd set that to something like 5*Max_Instrument_Note_Frequency. Why? Because it is very common for the first few harmonics of the fundamental to be present and detectable in a sound sample, either captured by a microphone or from a properly sampled wave file (or other format). These harmonics are what create the unique tone of the instrument and are also dependent on the attack. You might think that if all you want is the fundamental then you don't need to sample the harmonics. The problem with that is that those frequencies are in the wave form and if you don't sample finely enough to get them they will be aliased into frequency bins in your analyzer. This will then potentially be seen by you or some A.I. as a false fundamental and picked up. Taking the highest note of a piano as the max (not necessarily a good choice) you should be sampling at least 20,000 Hz. Room acoustics measurements sample a few times this, > 40kHz. There could be high frequency sound present in the room that we cannot hear but would be picked up by a sensitive broad band microphone.

In addition to the points mentioned above the fact is, asking what a normal range for pop tunes is extremely subjective. Some pop singers can hit notes in the 1000s Hz range. The question is really too broad as worded.

1
  • I edited the start post with some info. It is always getting sampled at 1/2 of the sample rate. So if the sample rate is 48K Hz then the song is sampled at 24 K Hz. I edited in the post that the ranges I describe are what I show.
    – Helper
    Jul 9, 2020 at 8:42
3

When composing and engineering modern music, the full spectrum of audible frequencies may be taken into consideration. If you start at where the frequencies start to be heard as continuous tones and not drum beats (around 60Hz I think EDIT: remembering that wrong, around 20hz...), you can have instruments and sounds that cover the range all the way up to the threshold of hearing (around 15kHz). Some audio engineers may separate the mix into different bands, having a low end bass, mid ranges and high "twinkle" sections. Mid range would be instruments like keys and guitars. Mid-high range could be things like voice, Harmonica, Accordion, and the high range instruments like whistles, Piccolo, cymbals and Tambourine.

If you are analyzing music you will probably want the full audible frequency spectrum, as even guitar heavy arrangements can have frequencies represented in the high range due to amp distortion and effects.

6
  • 2
    Surely frequencies start to be heard as continuous tones way lower than 60 Hz? The Low B string on a 5 or 6 string bass is about 31Hz, for example. Jul 8, 2020 at 19:12
  • 1
    Recordings are not produced at 44.1kHz for nothing..
    – Tom
    Jul 8, 2020 at 19:13
  • You want the full range with an upper limit set to over 5 times the highest note you expect. To avoid aliasing.
    – user50691
    Jul 8, 2020 at 20:38
  • 1
    @topo yeah, that didn't sound right to me, but memory is a funny thing. I figured someone would correct me and I could edit... Looking it up, most people hear a tone around 20 hz, and some as low as 12... Jul 9, 2020 at 4:33
  • I was thinking of making buckets and show each bucket. A bucket might be low end bass, mid ranges, etc. As you said. But do you have any chart or information where I could find the range of instruments?
    – Helper
    Jul 9, 2020 at 8:46
1
  1. For the purpose of music visualization you need logarithmic frequency range, as we hear the pitch as logarithm of the frequency. In other words you need narrow bands at low frequencies and wide at the high ones.

  2. Full hearing range is 20Hz–20kHz, but you will rarely find a note with a fundamental frequency over several kHz. High frequencies however contain overtones of the notes, so they are more responsible for the sound, rather than note content. Percussive sounds have broad frequency range and often dominate at the high frequencies.

  3. For the purpose of visualization, especially if you have limited number of channels (LEDs) you may choose some arbitrary frequency divisions, as you suggest "buckets". You may want to search internet for "music frequency chart" or similar, showing in which regions various instruments reside. Some guideline:

    • below 40 Hz: sub-bass
    • 40–80 Hz: bass
    • 80–200–400–800 Hz: low-middle-center mids. This is probably the most active region, this is where most melody notes (both vocal and instrumental) will fit, as well most of the harmonic/rhythmic instruments. You may want to divide this into several bands
    • 800–4000 Hz: highest melody notes, overtones, percussive notes
    • above 4000 Hz: overtones and percussive notes
  4. The sound power spectrum typically decays towards high frequencies, but on the other hand, if you make the bands wider at higher frequencies, they will pickup more power as well. Depending on how exactly you will do it you may need to adjust gain of each band so that you don't have "dead" regions in your visualizer. I believe there are math formulae for that, but I can't recall it at the moment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.