**(not quite) All About The Bass -
pt.1**

September 2, 2018

Â

The low frequency partÂ of the sound spectrumÂ is full of opportunities and bum pains. It can convey very visceral energy. It causes psycho-acoustic masking effects - where one sound hides another, whichÂ can be either good orÂ bad. Different playback systems can be very different in how they handle bass, making it rather unstable and unpredictable. The list goes on.Â All of which makes it both important and tricky to deal with. The cherry on top is that most tools to analyse sound are completely rubbish with low frequency!

Â

A typical spectrum analyser, used to draw a graph of the sound spectrum, is based on a maths technique called the Fourier Transform. You may have heard of it as FFT,Â Â which is a commonly usedÂ efficient version. The Fast Fourier Transform. It takes a sound wave and finds the frequency components that make it up. So far so good. The problem is that it works in frequency bands. It makesÂ a finite number of bands across the audio spectrum - a kind of pixelating. TheseÂ sound pixels are evenly (linearly) spaced over the audio spectrum, but sound doesn't work that way! The spacing of the actual frequencies as you hear them musically,Â is logarithmicÂ not linear. In short,Â the lower down you go, the fewer pixels you get. For a typical plugin, the lowest frequencies are just one big approximate pixel with no actual detail at all! (Even if the tidy lookingÂ graph seems to tellÂ you otherwise).Â

Â

If you want to know for realÂ whats going on down there, there's a few possible approaches. One is to have utterly kick-ass monitoring and listen to it. That's several kinds of nice, but may not be practical. It also doesn't tell you how a different system is goingÂ to behave. Another (zero cost) option is to do the FFT thing with such a massive number of pixelsÂ that the bass still has good resolution. I'm quite a fan of zero cost, so here's the technical lowdown... The number of pixels you get (aka Bins in FFT speak) relates to the length of the sound you are analysing. A longer sample of sound results in more pixels. To getÂ theÂ resolution I wanted with sub-sonic energy, I needed around one hundred seconds of sound. That is, the FFT needs to average a full one hundred seconds to produce a single static, high-res graph. The limitation is implicit in the way sound and the FFT works. The real-time, jiggles-about-while-the-music-plays stylee just isn't an option if you want that bass microscope!

Â

So... Here's a bit of Python code that will take a stereo wav and draw a graph from zero to about 1.4KHz with super-duper detail. It's not a polished product, just bare bones clumsy so you'll need a little tech savvy to use it. Contact me (or your techy friend) if you needÂ a bit more of a clue!

UsingÂ it to analyseÂ some natural sounds painfully confirms a few fears for me. The sound of waves on the sea for example have low frequency components that go down and down and down.Â The slight roll off on the graph belowÂ 18Hz is probably from the simple recording equipment. It'll take crazy hardware if I want to accurately reproduce that! Up side, using it onÂ some sound I had intended to go on a movie shines a light on some sub sonic gremlins.Â Movie sound systems can be wired to produce tonnes of very low bass to rattle the chairs. It's pretty important to know if that low frequency energy is there or not, cos it may suddenly jump right out at you! A bit of steep high pass filtering - more on that in another post - and lots of embarrassment is saved...Â :)

Â

import numpy as np

import matplotlib.pyplot as plt

import soundfile as sf

rawdata, samplerate = sf.read('AStereoSoundFile.wav')

timestep = 1/samplerate

oneD = np.zeros(102400)

looplen = len(oneD)

for i in range(0, looplen):

Â Â oneD[i] = rawdata[i,0]

sp = np.fft.fft(oneD)

freq = np.fft.fftfreq(len(oneD), timestep)

freq2 = np.zeros(3200)

c = np.sqrt((sp.imag**2)+(sp.real**2))

fulllen = int(len(c))

ref = int(len(c)/32)

ref2 = (ref*32)-1

for i in range(ref, ref2):

Â Â c[i] = 0

ref = ref-1

d = np.zeros(3200)

for i in range(0, ref):

Â Â d[i] = c[i]

Â Â freq2[i] = freq[i]

plt.yscale('log')

plt.fill(freq2,d)

plt.show()

Â

The above code uses the Numpy and Soundfile python libraries, so you may have to get them too. Turn a blind eye to my coding inefficiencies, or tidy it yourself, if you're into that. PutÂ it in the same directory as the file you want to look at. The file must be longer than one hundredÂ seconds. Change line four so the file name is right. Run it and bob'sÂ your uncle :) Hopefully. Worked for me in Python 3 under Linux anyway!...

Â

Â

Waves on a beach. The plot showing plenty going on below 20Hz - and thats after the simple recording setup has lost a bit of it! You can see the sound 'pixels', but there's enough of them to give a meaningful picture.Â Â

Zoomed out - the Python code as it stands graphs up to around 1.4KHz. You can see the overall slope that's typical of a lot of natural sounds.Â

Â

Â

###### Featured Posts

###### Recent Posts

###### Archive

###### Search By Tags

I'm busy working on my blog posts. Watch this space!