This is a signal analysis of a recording took in a Nissan Rogue 2011 while the car was running at 65 mph and it had one of the back windows Open The sound was annoying and most likely saturated the iPhone 6+’s microphone goo.gl/XFSKc2

The Singal Analysis follows. It goes with the Linkedin Article @ the following link: https://www.linkedin.com/pulse/when-car-turns-resonance-chamber-signal-analysis-case-jose-i-rey/

library(tuneR)
library(ggplot2)
library(signal)
## 
## Attaching package: 'signal'
## The following objects are masked from 'package:stats':
## 
##     filter, poly
library(scales)

# load the wave file I recorded using my iPhone 6+' microphone
resonantWave <-readWave("Rougue 2011 at 65mph.wav", from = 2, to = 12, units = "seconds")

# FFT Transformation, and cleaning of signal
# method mostly from http://samcarcagno.altervista.org/blog/basic-sound-processing-r/
samples <- resonantWave@left
sample_rate <- resonantWave@samp.rate
n <- length(samples)

# Perform FFT to obtain frequency components
magWave <- fft(samples)

# The result is a signal, followed by a mirrored repeat

# Dspose of the redundant data
nUniquePts <- ceiling((n+1)/2)
magWave <- magWave[1:nUniquePts]

magWave <- abs(magWave)  # Obtain frequency magnitudes
magWave <- magWave/n  # Scale by the number of points
magWave <- magWave^2 # Square to obtain the power

# If the FFT is of even length:
if (n %% 2 > 0){ 
  magWave[2:length(magWave)] <- magWave[2:length(magWave)]*2
} else {
  magWave[2:(length(magWave)-1)] <- magWave[2:(length(magWave)-1)]*2
}


freqArray <- (0:(nUniquePts-1)) * (sample_rate / n) # Generate axis of frequencies in kHz

magWave_db <- 10*log10(magWave) # Convert power to decibels


magWave_df <- data.frame(freq=freqArray, db=magWave_db) # create data frame
magWave_df2 <- magWave_df # resample to plot
magWave_df2$db <- sgolayfilt(magWave_df$db, p=15, n=17)

# Another way to produce a Power Spectra using 
#spec(resonantWave, log="x", dB="max0", dBref= 1*10e-6, plot=TRUE, ylab="Power in dB")

Now Plot the Power Spectrum Note the Blue Dashed Lines correspond to the observed and calculated Peaks

# Plot frequency components using ggplot
g <- ggplot(magWave_df2, aes(x=freq, y=db), log10="x") +
  geom_line() +
  scale_y_continuous(breaks = seq(-60, 80, by = 10), name="Power(dB)") +
  scale_x_log10(breaks=c(1, 5, 16, 33,50,100, 500,1000, 5000 ,10000, 20000), name="Frequency (Hz)") +
  theme(axis.text.x=element_text(angle=90,hjust=1)) +
  geom_vline(xintercept = c(16,33,106), color="blue", linetype="dashed")
g
## Warning: Transformation introduced infinite values in continuous x-axis