This project contains a collection of MATLAB scripts for analyzing audio signals to assess road quality, detect vehicles, and classify vehicle types based on their sound profiles. It utilizes signal processing techniques to extract features from audio recordings and make estimations or classifications.
This project includes the following MATLAB scripts:
- Purpose: Estimates road quality (Smooth, Moderate, Rough) based on an input audio file (e.g., highway recordings).
- Method: It filters the audio signal to isolate low-frequency road noise, calculates RMS, peak values, and standard deviation of the filtered signal, and then classifies the road quality.
- Input: A
.wav
audio file (mono or stereo, will be converted to mono). Users need to specify the file name within the script. - Output: Console display of RMS value, peak value, standard deviation, estimated road quality, and a plot of the filtered audio signal.
- Purpose: Detects sound events in a
.wav
file and classifies them as 'Truck', 'Car', or 'Motorbike'. - Method: It processes the audio in frames, calculates spectral energy to detect events, and then uses the average dominant frequency within each event for classification.
- Input: User selects a
.wav
file via a file dialog. - Output: Console display of detected events, their timing, average dominant frequency, and classification. It also plots the audio waveform, smoothed spectral energy with event markers, and a summary of detected vehicle counts.
- Purpose: Detects and classifies vehicles (Bike, Car, Truck) from a given highway audio sample.
- Method: This script performs spectral analysis on audio frames, identifies vehicle presence based on energy thresholds, and classifies them using dominant frequency ranges.
- Input: A
.wav
audio file (e.g.,Highway sound sample 1.wav
). The file name needs to be set in the script. - Output:
- Console table listing detected vehicles with their detection times and types.
- A plot showing spectral energy over time with color-coded markers for different vehicle types.
- A plot of dominant frequency versus time, color-coded by vehicle type.
- A summary count of detected Cars, Bikes, and Trucks in the plot title.
- Purpose: Detects the presence of vehicles in an audio recording.
- Method: It calculates spectral energy per frame, smooths this energy, and applies a threshold to identify time segments where vehicles are likely present.
- Input: A
.wav
audio file (e.g.,Highway sound sample 1.wav
). The file name needs to be set in the script. - Output: A plot of spectral energy over time, showing the detection threshold and marking detected vehicle events. The total count of detected vehicles is displayed in the plot title.
- Ensure MATLAB is Installed: You need a working installation of MATLAB to run these scripts.
- Download the Scripts: Place all the
.m
files in the same directory on your computer. - Prepare Audio Files:
- The scripts are designed to work with
.wav
audio files. - For
road_quality_assessment.m
,vehicle_classification.m
, andvehicle_detection.m
, you will need to edit the script to specify the name of your input.wav
file (e.g., replace'Highway sound sample 1.wav'
with your actual file name). sound_event_vehicle_classification.m
will prompt you to select a.wav
file using a file dialog.
- The scripts are designed to work with
- Open MATLAB: Navigate to the directory where you saved the scripts.
- Run the Desired Script: Open the script you want to run (e.g.,
vehicle_detection.m
) in the MATLAB editor and click the "Run" button, or type the script's name in the MATLAB command window (e.g.,vehicle_detection
) and press Enter. - View Outputs:
- Check the MATLAB command window for any printed information (e.g., road quality reports, vehicle classifications).
- Plots generated by the scripts will appear in new figure windows.
Note: These scripts use standard MATLAB functions. No external toolboxes are explicitly required by the provided code, but ensure your MATLAB installation includes the Signal Processing Toolbox for full compatibility with functions like audioread
, designfilt
, filtfilt
, fft
, hamming
, movmean
, etc.
This project demonstrates the following capabilities using MATLAB for audio analysis:
- Road Quality Assessment: Estimates road surface conditions (smooth, moderate, rough) by analyzing low-frequency components of audio recordings.
- Vehicle Sound Detection: Identifies time segments in audio corresponding to vehicle presence using spectral energy analysis.
- Vehicle Classification: Categorizes detected vehicle sounds into types such as 'Car', 'Truck', and 'Motorbike'/'Bike' based on their dominant frequency characteristics.
- Sound Event Segmentation: Detects and isolates distinct sound events within an audio file based on energy thresholds.
- Signal Processing: Utilizes fundamental signal processing techniques including:
- Filtering (bandpass)
- Windowing (Hamming)
- Fast Fourier Transform (FFT) for spectral analysis
- RMS, peak, and standard deviation calculations
- Data Visualization: Generates plots for:
- Audio waveforms
- Filtered signals
- Spectral energy over time
- Detected event markers
- Dominant frequency distributions
Further enhancements and research directions for this project could include:
- Advanced Classification Models: Implement more sophisticated machine learning or deep learning models (e.g., SVMs, CNNs, RNNs) for improved vehicle and road quality classification accuracy and robustness.
- Expanded Vehicle Categories: Train models to distinguish between a wider variety of vehicle types or even specific models.
- Noise Robustness: Improve detection and classification accuracy in noisy environments or with varying microphone characteristics.
- Real-Time Processing: Adapt the scripts for real-time audio input and analysis.
- User Interface: Develop a graphical user interface (GUI) for easier interaction with the scripts and visualization of results.
- Acoustic Feature Enhancement: Explore a broader range of acoustic features (e.g., MFCCs, ZCR, spectral flux) for more detailed sound characterization.
- Sensor Fusion: Combine audio data with other sensor inputs (e.g., video, GPS) for a more comprehensive understanding of the environment.
- Environmental Sound Analysis: Extend the project to classify other environmental sounds beyond vehicles and road noise.