Skip to content

BSc Thesis: Acoustic source localization embedded system to estimate direction of sound arrival using time difference between sound wave arrival to 4 microphones.

License

Notifications You must be signed in to change notification settings

JSerwatka/Acoustic-Source-Localization-System

Repository files navigation

Table of contents

Project

Project goals

This project implements an Acoustic source localization system using LabVIEW and sbRIO-9636 (Single-Board Controller from National Instruments).

The device is designed to show the direction of sound (Direction of Arrival (DoA)) in real-time, in the form of an angle deviation from the center of the device.

The whole system consists of three main components:

  • 4 microphones,
  • 4 microphone amplifiers,
  • sbRIO-9636.

The angle mentioned above is calculated based on the delay of the acoustic signals (TDoA) between successive pairs of microphones. Based on the data collected in this way, the position of the sound relative to the center of the device can be calculated.

An additional goal of this project is to use the cheapest possible components, but with a satisfactory accuracy of calculations in difficult acoustic conditions. The use of low-quality components creates additional complications but allows the system to be easily reproducible.

Software - simplified description

diagram Below is a simplified description of the successive steps the system uses to calculate the DoA:

  1. After amplifying the signal, it is sampled at the selected frequency (default - 50 kS/s).
  2. The signal is filtered with a high-pass filter with a cut-off frequency of 2.5 kHz.
  3. When the sound exceeds a certain threshold, a user-selected number of samples is collected (default - 9000).
  4. The collected audio signal is queued in the FIFO.
  5. A deterministic loop, working in the real-time part of the program, receives the data from the FIFO and passes it to the internal queue (RT FIFO).
  6. The data is received in a non-deterministic loop that analyzes the signal.
  7. Using Generalized Cross Correlation from Phase Transform Weights, TDoA is measured.
  8. Based on the data from the previous point, the angle of incidence of sound for each pair of microphones is calculated.
  9. The angles are analyzed to ensure that there is no measurement error.
  10. The final angle is computed.
  11. The angle data is sent to the user panel.
  12. The following data is displayed on the user panel:
    • the final angle of incidence of sound,
    • graph of the tested signal for one of the microphones,
    • TDoA graph for one of the pairs of microphones.

TDoA measurement method

The main task of the described system is to efficiently calculate the difference in time of arrival of sound between pairs of microphones. Many algorithms have been developed to solve this problem, among the most popular are Maximum Likelihood (ML), Multiple Signal Classification (MUSIC) and Generalized Cross-Correlation (GCC). The first two methods have a disadvantage which is crucial in the case of the system described in this work; to work properly, they require a large number of microphones and complex calculations. Both of these disadvantages are impossible to solve with a simple microphone array using a device that is not specialized for this task. For the above reasons, the GCC algorithm was chosen.

To explain Generalized Cross-Correlation (GCC), we must first create a mathematical model of the signals received by the microphones:

where s(t) is an audio signal, n1(t) and n2(t) are additional, random noises independent of the original signal, D represents a delay of the sound signal reaching the next microphones, and T represents the observation time of the signal.

The main method of computing TDoA is Cross-correlation (CC). The Cross-correlation function shall be applied to the two received signals. Thanks to this, we are able to obtain a graph of the similarity of two signals for different time shifts. Then we just need to find the value at which the function is at its maximum, and we get the sought-after amount of delay between the signals. The CC method is extremely simple, but at the same time very unreliable, especially with a low SNR value.

In order to increase the accuracy of the results, I use the appropriate filtering and weighting function to enhance the important signal parts and suppress unnecessary noise. This way, we obtain the Generalized Cross-Correlation, which can be represented by the following equation:

where psi is our weighting function, G - cross-correlation between received signals, and D - the value of the delay we are looking for.

The most frequently studied weighting functions are: Roth, Smoothed COherence Transform (SCOT), Phase_ _Transform (PHAT) and Eckart Filter. Many of these analyzes clearly show that the most effective method is GCC-PHAT. This approach is also most commonly used in similar projects. It is characterized by simplicity of calculations, with simultaneous high accuracy in TDoA estimation, which makes it extremely useful in sound localization systems operating in real time. PHAT can be represented by the following equation:

Flowchart of the TDoA estimation method, using generalized_cross-correlatio:

GCC

Implementation of GCC-PHAT in LabVIEW:

image

Angle calculation

Having TDoA allows you to calculate the angle of incidence of an acoustic wave on a pair of microphones. To achieve this, a simple trigonometric operation is used.

image

The figure shows a diagram of the microphone array, where L is the distance between the microphones, alpha, beta, and gamma are the angles at which acoustic waves hit the next pairs of microphones, and theta is the final angle with respect to the center of the array.

The alpha, beta and gamma angles are calculated using the equation below:

where c is the speed of sound, tau - the delay between the microphones, and the distance between them is represented by l.

After calculating the alpha, beta, and gamma angles, you can estimate the final theta angle. Below is a possible solution to this problem in four steps:

Bez tytułu

The use of three different values of a and b to calculate the angle is required to average the errors of each of the angles.

Error handling

Due to the poor quality of the components, angle error handling is required to protect a user from receiving false information about the direction of the sound source. In order not to lose data with each device error, two types of errors are being proposed:

  1. Single angle error - occurs when:
  2. Critical angles error - occurs when:

When a single angle error occurs, the result is displayed to the user, but also an error notification is sent, which is signaled by lighting the appropriate LED on the user panel. The critical angles error causes the calculated result to be ignored and a red LED on the user panel lights up.

GUI

The panel has been designed to be as intuitive as possible, but also to contain all the necessary information for the user of the application. For this reason, it has been divided into four segments, visually separated from each other:

image

  1. Settings - contains basic application settings that allow the user to choose between the precision and speed of the program. You can adjust:
    • SamplesToSend - allows you to control the number of samples that will be taken for analysis for each microphone (default - 9000). The greater the value of this control, the more accurate the result of the angle calculation, but slower performance.
    • AcqLoopFreq - allows you to select the signal sampling rate (default - 50kS/s). The greater the value of this control, the more precise representation of the input signal, but the shorter duration of the analyzed signal.
    • Threshold - allows you to set the application sensitivity, i.e. the minimum signal strength that will be accepted for analysis (default - 0.1). The lower value of the control allows you to observe low-intensity signals but increases the chance of errors and accidental analysis.
    • STOP - this control stops all VIs.
  2. Errors - contains error indicators:
    • Single angle error,
    • Critical angles error,
    • FIFO overflow error,
    • internal application errors.
  3. Angle indicator - this indicator shows where the sound is coming from and displays the calculated angle as a number.
  4. Signals - contains two graphs:
    • Signal - draws a graph of the amplitude of the input signal for the first microphone in successive units of time (time is presented as a number of samples).
    • TDOA - shows a graph of the correlation of signals from the first and second microphones analyzed with the GCC-PHAT algorithm and their shifts in relation to each other.

About

BSc Thesis: Acoustic source localization embedded system to estimate direction of sound arrival using time difference between sound wave arrival to 4 microphones.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published