Using Exhaust Sound Recordings to Calculate Engine RPM

Japan Blog
Analytics Vidhya
Published in
5 min readFeb 15, 2021

Some time ago I wrote a MATLAB script that processes vehicle’s exhaust sound recordings, analyzes its frequency spectrum and calculates the engine speed in RPMs. Today I will be using 3 example sound recordings to show you how this is done.

Data Collection

The 3 sound files are, first of all, a homemade sound recording of my own car’s exhaust, and 2 sound recordings that I have downloaded from YouTube onboard videos:

  • Mazda MX-5 (NC) 2.0i 158 bhp: My car.
  • Ferrari 150º Italia (Formula 1): Onboard lap around the Suzuka circuit in 2011, by Fernando Alonso.
  • Porsche 911 GT3 991.2: A 0–300 km/h acceleration.

Spectral Analysis

The frequency domain of each signal will be calculated in MATLAB and studied using its spectrogram. A spectrogram is a data processing technique with which the amplitude distribution of the signal’s frequency domain is mapped against time. A digital spectrogram is created by discretising the originally longer signal in chunks of shorter lengths (window) and calculating the fast Fourier transform (FFT) of each one individually. The window and the overlap of these discretised data chunks need to be tuned beforehand.

Mazda MX-5 (NC) 2.0i 158 bhp

Ferrari 150º Italia (Formula 1)

Porsche 911 GT3 991.2

The 3 spectrograms above tell us a lot about what is going on in each case. Excluding the first signal, which I recorded by revving my car in standstill, you can already glimpse the shape of a typical engine speed graph as the driver travels through the different gears, accelerations and brakes. The next challenge will be to find and isolate the fundamental frequency from the rest of the irrelevant frequency content.

Finding the Fundamental Frequency

Except for artificially generated sinusoidal waves, all sounds in nature are complex tones — that is to say, they consist of a combination of multiple sine waves. The fundamental frequency, or first harmonic, is the frequency wave that is perceived as the loudest. The rest will be harmonics and partials of the fundamental. Additionally in this example, part of the spectral content will come from the noise produced by other sources (wind, vibrations, electric noise, etc). There are different algorithms that enable us to find the fundamental frequency from a spectrum and pull it as a time domain based signal — I will be using the Welch’s power spectral density estimate.

Using the Mazda MX-5 signal as an example, the next figure shows the following 4 steps:

  • Sound Recording: Raw data of the recorded sound.
  • Spectrogram: Frequency spectrum of the sound recording.
  • Spectrogram & Fundamental Frequency: Spectrogram with the fundamental frequency found applying Welch’s method.
  • Fundamental Frequency: Isolated fundamental frequency.

Looking at the figure above, we can see how Welch’s method to finding the fundamental frequency is generally accurate but with some exceptions — see for instance the 7 sec., 8 sec. or 14.75 sec. points in time. The intensity of the second harmonic prevails over the fundamental, interfering with the prediction and misleading the result. This can be improved by fine-tuning the window and overlap parameters, but this would be at the expense of data resolution. So, one could decide to come up with an algorithm that constrains the frequency range within which Welch’s method is applied. For the time being however, I will simply replaces the wrong data points with “NaN”. The following graphs show the resulting fundamental frequency for each one of the 3 sound signals proposed.

Mazda MX-5 (NC) 2.0i 158 bhp

Ferrari 150º Italia (Formula 1)

Porsche 911 GT3 991.2

The Internal Combustion Engine

Let’s convert the fundamental frequency signals to engine rotational speed signals by knowing some basic information about each engine. We will use the number of cylinders and the number of strokes (4-stroke or 2-stroke). With this in mind, we can calculate the number of engine detonations occurring every second, as follows:

The multiplier parameter k should be 1 by default, but may be different in some cases due to a variety of exceptional reasons:

  • Big-bang firing order (multiple cylinders detonating simultaneously).
  • 2-stroke engines with missing detonations at low engine speeds.
  • Manifold or muffler designs that cancel the fundamental frequency.

Mazda MX-5 (NC) 2.0i 158 bhp

Ferrari 150º Italia (Formula 1)

Porsche 911 GT3 991.2

Conclusions

Spectral analysis techniques are very powerful tools and can be used to calculate, among other vehicle metrics, the internal combustion engine speed from a simple audio recording of the exhaust sound. The main challenge lays in the fact that the fundamental frequency is not always straight forward to isolate from harmonics and other sources of noise. While this can be resolved in a variety of ways, automating it and making it robust under a wide range of vehicles and engine types may still prove difficult. However, with the engine speed signal calculated, this can be used to reverse engineer other vehicle parameters such as, for instance, vehicle speed or engine torque and power curves.

--

--