Analyse Frequency Changes and Increase Sampling Rate

Dear all,

This is my first time being here. I am doing a project related to sound and movement. Basically, the sound source is constantly moving back and forth. By theory, this would changes the frequency and I would like to observe these changes.

I have tried to record and analyze using frequency analysis, by selecting different part of the recording (when sound source is stationary, moves away and moves closer) and plot spectrum. However, I am not sure thats the best way to analyze.

Is there anyway that could help me analyze the frequency changes more accurately?

Is there a way to increase sample rate? I am using a microphone that comes with my HTC headphone, and i am recording 5kHz sound. Recording settings are 32-bit mono and 44100Hz


Doppler-effect can be visible in Audacity’s spectrogram view if you increase the resolution, (aka “window size”), from the default setting, see … Doppler Effect for High School Physics - #3 by Trebor

However the object will have to be moving at a speed which is around 1/20th the speed of sound, (~15m/s), to be measurable. The Doppler-effect at say walking-speed, (~1.5m/s), will probably be too small to measure.

Is there a way to increase sample rate?

Go to Edit → Preferences → Quality.

44.1kHz or 48kHz is fine for a 5kHz signal (or anything you can hear).

Also, your driver can fake you out and up-sample to a higher sample rate than your hardware can handle. It’s not unusual for the hardware to be “locked” at 44.1 or 48kHz, but it’s hard to know what the true sample rate is. It’s sort of like printing a high-resolution image on a low-resolution printer… The printer won’t refuse to print… The Windows and the driver will happily and quietly down-sample the resolution to something the printer can handle.

Certainly, your analog to digital converter isn’t 32-bits either. Audacity works internally at 32-bit floating-point and there are good reasons for that, but you are not recording 32-bits of resolution. And, when you are recording with a microphone, the acoustic background noise means you are usually getting less than 16-bits of true resolution anyway.

Assuming you are using one mono microphone, you are recording mono.

Thank you for the replies

So for the window size, the higher i go, the more accurate it will be?
I have tried changing from smallest to largest and they seem to give me different frequency peaks, even though I am selecting the same sound sample. The sound level (dB) seems to change too. Can you please explain to me why? I am not too familiar with digital recording. thanks.

Hi DVDdoug,
Thanks for you clear explanation on sample rate.

There are several things that I don’t understand. Wouldn’t recording at bits of resolution other than 32 affect the result? And why acoustic background noise would reduce the ‘true’ resolutions to less than 16? Would it further affect my result?

I am sorry that I am asking many questions, it’s just I am curious and like to know how things work :bulb: Thanks

with a sample rate of 44100Hz IMO the optimum window size is 2048 or 4096. Higher settings take a longer time for the computer to render, with little gain for the extra work.

As the sound-emitting object moves different distances from the microphone, the sound level, loudness, must change according to the inverse square law … Inverse Square Law for Sound .

In Audacity you can use a tool called hyperexpand to make all the track equally loud to compensate for your sound-emitting object being at different distances from the microphone during the recording.

There are several things that I don’t understand. Wouldn’t recording at bits of resolution other than 32 affect the result?

What I was trying to say is, you’re NOT truly recording at 32-bits because your soundcard doesn’t have a 32-bit analog-to-digital converter. That’s not a big issue

And why acoustic background noise would reduce the ‘true’ resolutions to less than 16? Would it further affect my result?

It might not affect your result at all… For what you’re doing, you shouldn’t need high resolution.

But… noise reduces precision/resolution/accuracy. You can have a high-quality24-bit professional audio interface but unless you are in a soundproof studio, you are not getting even 16-bits of useful information…

Imagine you are trying to measure the depth of a swimming pool with an accuracy of 1/16th of an inch (about 1.5 mm if you live in a more advanced country. :slight_smile: ) It’s very hard to get that much accuracy/resolution because of the water movement (noise in your measurement). If someone is splashing around in the water that’s even more “noise” in your measurement.

Back to digital audio… With no signal and only acoustic noise will cause some of the “bottom” bits (the less significant bits to the right) to jump around randomly. When you add the signal and read (sample) the signal, those noisy jumping-around bits are meaningless. Going from 16 to 24 bits just gives you more useless noisy bits below the noise floor.

Hi, what i meant was when i change the window size, the dB seems to change too (dB goes down when window size goes up) even though I am analyzing the same sample. Is it because of the way they measure digital loudness? I remember it’s 20log(current bit/largest possible bit size) or something similar.

The reason for this is that the graph is scaled such that a sine wave (pure tone) in any one frequency band will register as the same amplitude. Specifically, a sine wave with an amplitude of 0 dB will register as 0 dB on the graph.

In real-life audio, there are hardly ever pure sine tones, but rather a swirling mix of countless frequencies. Thus for real-world audio we expect to see “complex bands of frequencies” rather than individual frequencies, so the wider the frequency band, the more frequencies it will catch. The larger the window size, the more frequency bands and the narrower those bands are, so the less frequencies they catch, hence the lower amplitude.

Let’s start over.
Firstly, what kind of sound source do you use?
It should ideally be a constant sine wave.
The frequency spectrogram wouldn’t be my first choice.
It doesn’t allow tracking of a single frequency as accurate as it could be.
Side remark: the frequency spectrum is a compilation of different bandpass filters, increasing the resolution can change the magnitude if the frequency doesn’t fall exactly on one bin (=band).
It is therefore good to resample the track at a sampling rate that corresponds to the window size and the test tone, e.g. test tone = 5000 Hz->sample rate 40960 gives peaks nicely centered on the bins.

However, we need a nicer approach.

  1. the window should be a sliding one (instant frequency for each sample)
  2. proper interpolation (you can emulate it with using the mouse cursor on peaks in the spectrogram)
  3. meaningful output as e.g. labels at velocity changes.
  4. Different algorithms possible for the FM demodulation.

We can write a Nyquist script if you want.


For Larger window size > narrower bands > each band has smaller frequency-catching range > frequency plot is more accurate?
My sample is only about 5 seconds long each. So computation time is not an issue.

There was another problem when I try to analyze the sample. What I did was:

  1. Recorded TWO identical ambient sound samples.
  2. Plotted frequency analysis at window size: 65536 for BOTH
  3. Exported the graph data to Excel
  4. I tried to compare both graphs, their dB levels are very different. In fact, average differences are about 10dB for the ENTIRE frequency range, and can go up to 50dB
    Have attached PNG file. I took db level of one sample and subtract it from another sample. Only dB level of same frequency are paired for subtraction.

I know this is not supposed to happen, but what am I doing wrong? is window size 65536 too big for my recording?

Or is my microphone faulty? I was in a fairly quiet closed room, no outside noise, no air-cond, nobody was in the room.


That’s to be expected if the recorded samples were fairly short.

Slightly simplifying things (ignoring window type and overlap), lets imagine comparing two recordings, each is 5 seconds of white noise, and the sample rate is 44100 Hz.
If your sample rate is 44100 Hz, then 65536 samples is just under 1.5 seconds.
If you analyse 5 seconds of audio - that gives you 3 full windows. Plot spectrum will take an average of the measurements from each window.

Consider if we compare the results from just the first 65536 samples of each recording.
White noise, by definition, has an average amplitude that is equal in all frequency bands across the audio spectrum. Note that this speaks of an “average” level. During one window period the levels for each frequency band is likely to vary wildly from other bands. We would therefore expect to see random values in each frequency bin.

Now if we consider comparing 3 windows from each recording. After averaging 3 bins we would still expect random values, but random values within a smaller range. The more windows that we average, the narrower the range of random variation. By the time we gave averaged 500 windows or more from each recording, we would expect, for true white noise, all frequency bins to be within about 1 dB of each other. Of course, as is the nature of random things, there is a chance that one or more readings may be wildly different (someone wins the lottery).

So if you analyse, say 15 minutes of audio, then you would expect much less variation, but as Plot Spectrum measures a maximum of 10 million samples, you would need to take multiple measurements and average them yourself.

A couple of suggestions:

First, you can use a bandpass filter centered around the frequency of your test tone to eliminate much of the noise. As other have suggested the magnitude of the frequency shift you will get moving the object by hand is quite small. Also use the compressor to with a very high ratio (or the previously mentioned hyperexpand) to get your test recording to a constant level.

The other suggestion is that if you generate a track with a pure tone matching your test frequency and play with your test track you will hear the “beat” between them. By counting the beats you can get a very accurate measure of the source frequency.