Due date: Oct 20

We have provided starter code that is able to transmit and receive an acoustic tone:

Smartphone code to transmit and receive audio data [Android , iOS]

Key differences between Android and iOS starter code: The Android code updates the FFT in real-time (several times a second). The iOS code will only show the FFT once of the full recording. This will make the implementation of part 2 slightly different (described later in part 2).

Part 1: Contactless breathing monitor

In this assignment you will learn:

  1. How to compute breathing rate by emitting an inaudible acoustic tone from the smartphone, extracting the envelope of the signal, and performing an FFT.

Checkpoints and recommended steps:

  1. Place the smartphone less than 1m away from your chest. Transmit an 18kHz (inaudible) signal towards your chest and breathe in and out steadily (use a timer to roughly synchronize your breathing to a set frequency) for 1 minute. Plot the raw received signal in MATLAB

  2. Take an envelope of the signal and plot it. You should be able to observe steady motions associated with inhalation and exhalation

    1. hilbert(), envelope() can be used to take an envelope of the signal
  3. Take an FFT of the signal and plot it

    1. mag2db(abs(fft(envelope))) can be used to take an FFT. The output of this call will be the same as the number of samples in the envelope.

      The audio sampling rate is 48kHz, so if you recorded for 60 seconds the envelope and FFT output will be 48,000 * 60 = 2,880,000 samples long. The FFT shows the acoustic amplitude measured for different 2,880,000 frequency bins from 0 to 48kHz. Each bin shows the amplitude for 48,000 / 2,880,000 = 0.0167Hz.

    2. You need to create a frequency vector (x-axis), so that when you plot the FFT the x-axis is in Hz. Each of the example 2,880,000 FFT bins corresponds to a frequency range from 0 to 48 kHz. Construct your frequency vector like linspace(0,48e3,length(envelope))

    3. Ignore the DC component (1st bin) of the FFT when finding breathing rate

    4. Human breathing is 12 to 20 breaths per minute. What does that translate to in Hz? This will dictate the range of frequency bins where you can practically expect to see a breathing signal. Find the maximum bin within this range and check and record the amplitude.

  4. Repeat the above but for a control measurement where the smartphone is simply facing a wall. Verify what the signal looks like. This is important to ensure that what you measured in the previous step is indeed breathing and not an artifact. You should be able to see that the envelope is flat and the FFT amplitudes within the typical range of breathing frequencies is much lower.

Deliverables: Two screenshots similar to above showing the raw received signal, the envelope of the signal, and an FFT of the envelope with a peak corresponding to the breathing rate. Code for data processing.

Extending the system

  1. Extend this to view the phase changes of the signal and plot how it changes for breathing
  2. In a more cluttered environment or if the user is further away from the phone, it is more challenging to accurately capture the breathing signal using a tone. Instead, try using an inaudible chirp using the smartphone app. Then correlate and dechirp the signal and isolate the breathing movements.

Extra credit. Investigate using OFDM symbols (which are used in Wi-Fi), instead of a tone. Use this paper as a general guide: *Whole-Home Gesture Recognition Using Wireless Signals Best Paper, MobiCom, ‘13*

References for detecting heartbeats: AcousticCardiogram: Monitoring Heartbeats using Acoustic Signals on Smart Devices Using smart speakers to contactlessly monitor heart rhythms