Close
0%
0%

High Performance Audio ADC for Machine Learning

A system that can record high quality audio (24 bit, 48kHz 120db SNR) continuously and unattended outdoors.

Public Chat
Similar projects worth following
This project was inspired by the SAFE acoustics project (http://acoustics.safeproject.net), which does continuous nature recordings in the rainforest to monitor wildlife. I wanted to collect similar recordings in my local area, and analyze them for patterns with machine learning. So I want a system that can record unattended for long periods of time with high quality audio.
Requirements:
Record high quality audio - at least - 24bit 48kHz sample rate, 2 channel, 120dB SNR
Microphones - sensitive, flat response, low noise
Ability to record continuously for 1 year
Autonomous recording - fault-tolerant, minimal intervention, self-preserving
Highly configurable ADC - be able to set/adjust gain, etc while recording
Logging of other data - time, GPS location, temp, sunlight, gain settings
Ability to swap out storage while recording
Power sources - allow multiple sources, car battery, solar, mains, etc.
Weatherized - waterproof, -40 C to +40C
Software Controlled


Here is the basic hardware I have landed on:

Raspberry PI - Use a zero for low power consumption, assuming it can process the audio

Audio ADC - TI's tlv320adc6140 is used in the Amazon Echo and other continuous listening devices.  Its based on a I2S or DSP interface, which is compatible with the PI.  Specs are impressive and its highly configurable -specs.   Has lots of room to grow (4 channel, mixing, dsp, delay)  I've looked at others (PCM4222, PCM1808, SGTL5000, CS4272, AC108, DA7212), as well as USB dongles and higher-end stuff, but too expensive, too much power, too large.

I designed a board based on the evaluation board, that exposes the RPI connections and also has a nice screw terminal to connect the microphones.  Here is the board at OSH Park: ADC v1


Microphone - A stereo SASS microphone that uses - AOM-5024 electret capsules  High sensitivity, low noise, flat response, cheap.

Preamp - Not sure its needed, since the selected ADC has mic input, analog gain of 42dB and digital gain of 27dB.  Also would require an addl low noise power source. but here is my selections for adding a differential output preamp with dual opamps at 5v with low noise:

  • ISL28290 1nV/sqrt(Hz)
  • LMP7732 2.9nV/sqrt(Hz)
  • LME49721 4.0nV/sqrt(Hz)

Enclosure - Put the raspberry pi in the stereo microphone enclosure - see these outdoor stereo microphone designs:

Wind noise - This has to be handled in any design.  From what I have found it is crucial to reduce, probably biggest factor in a quality recording.  Here are some materials I have tested that pass sound suitably but block wind:

  • Landscape fabric
  • Nonwoven - Gardus Lintcatcher - a big bag with a drawstring - seems to repel water, but maybe needs treatment. Was $5 at the big box home improvement store.
  • Nonwoven - Swiffer dry sweeping cloths -  cover a microphone capsule with this.  Can use some aluminum window screen to make a framework to drape the this over.
  • Standard open cell foam - works too, but may absorb water

Other Materials - Here is some other stuff I've collected for their sound deadening properties:

  • Plumbers putty - heavy and does not resonate.  Also HVAC putty is same, but probably more weatherproof.
  • Heavy rubber - I found a step cover made of 1/4 inch heavy flexible black rubber at the big box home improvement store.  Could be cut up in a sheet.
  • Vinyl floor tiles
  • MLV - Mass loaded vinyl
  • Car sound deadening products?  - seems not as good - made for high temps.

Code

audio-recording-firmware-raspi-tlv320adc6140 - Raspberry Pi (device tree overlay, python firmware, python continuous recording)

nature-audio-ai - Jupyter Notebooks for classification and prediction, starting with bird calls.

Animal call web app - a python web application that allows users to find animal calls in the recordings.

Important features so far:

High quality audio

  • Using a custom build ADC board with advanced signal processing and low noise (-120db) 24 bit
  • More sensitive microphone capsules with 2 channel recording (stereo)
  • A boundary design (SASS copy) for the stereo array to ensure accurate natural sounding stereo imaging.
  •  Dual wind screens for wind noise and dampening for physical vibration
  • Addition of 2 more advanced compression formats - opus which provides better performance and flac which is lossless compression.

Low power usage (70mA at 12 volt during recording)

  • Raspberry pi zero W, which uses less current than other RPis.
  • ADC does not require a USB connection (uses I2S pins) which uses less power than a usb bus or usb device.
  • Bluetooth and HDMI interfaces shut down to save power.
  • WIFI shutdown when not needed to save power
  • A 5Ah 12v LiPo battery can power the system...
Read more »

ADC v1.0 opt BOM.txt

Bill of Materials for the ADC board

plain - 4.56 kB - 10/11/2021 at 00:22

Download

RPI-ADC Connections.jpg

List of connections for Raspberry Pi and ADC

JPEG Image - 90.36 kB - 10/11/2021 at 00:15

Preview

schematic.png

Schematic of the ADC board

Portable Network Graphics (PNG) - 40.52 kB - 10/11/2021 at 00:14

Preview

board design.png

Image of board design

Portable Network Graphics (PNG) - 18.27 kB - 10/11/2021 at 00:14

Preview

Microphone Connection.pdf

Schematic showing how to connect the microphone for a single input channel.

Adobe Portable Document Format - 127.61 kB - 10/11/2021 at 00:13

Preview

View all 7 files

  • Raspberry Pi Power system in separate project

    Filip Mulier12/17/2022 at 22:09 0 comments

    I documented the Raspberry Pi power system in a separate project because it is useful in its own right.  It provides push button startup, push button shutdown with essentially no battery current draw (1 microamp), ability to monitor voltage, current and power from the command line, and automatic shutdown when the battery voltage drops too low.  Here is the project: battery-power-system-for-raspberry-pi

    pi@pi3:~ $ battery
    battery voltage = 12.451 volts.  Run time = 0.3071861111111111 hours
    battery current = 332.275 mA.  Capacity used = 98.555 mAh
    CPU temp = 49.93 deg C.

  • SaSS Microphone Build Details

    Filip Mulier12/15/2022 at 11:45 0 comments

    I posted the build details for the SaSS style stereo microphone that is used with this project in a separate project. 'SaSS-Style Stereo Microphone for Nature Recording'  I'll be breaking down this high level project into multiples and posting details.  These can be used stand alone for other purposes.  This high level project will remain to capture the overall system.

  • Second System

    Filip Mulier03/03/2022 at 02:29 0 comments

    Version 2 system is complete. It includes battery voltage and current monitoring with automatic shutdown when battery is low. Also includes a real-time clock and proper pc boards for everything.

  • The last TLV320ADC6140 ADC available on Octopart :(

    Filip Mulier02/10/2022 at 03:03 0 comments

    I managed to order the very last TLV320ADC6140 ADC available on Octopart last August.  Mouser had the last one. This part is on back order til 2023. I’m gearing up to make another ADC board for a second recording system.


  • Handling Cold Temperatures

    Filip Mulier01/16/2022 at 14:49 0 comments

    We had a cold spell so I took the opportunity to add temp sensors to the microphone enclosure to measure how the inside temp varied.  The enclosure is foam insulation so I was curious as to how the 0.84W (12v x 0.070A) power usage of the system, which all turns into heat in the end, would keep the inside of the enclosure warm.  For Li-ion cells, the lowest temp is -20C (-4F).  I wanted to calculate the R-value of the enclosure, which is roughly related to the temp difference between the inside and the outside and takes into account the watts of energy introduced in the enclosure.

    Time Series of Temperatures (deg F) and R-value (USA units)

    The horizontal axis shows the day and time, with grid lines at 12 hour increments.  The details for the traces are:

    t_cpu - Temp as reported by the cpu die in deg F

    t_in - Temp inside the enclosure in deg F

    t_out - Temp outside the enclosure, but inside the wind screen deg F

    Temperature - Historical temp from a weather service deg F

    d3 - difference between t_in and Temperature deg F

    Wind Chill - feells like temp for human exposure deg F

    The system started at indoor temperatures and cooled off as the outdoor temperature also decreased.

    In perfectly controlled conditions for this type of test, d3 would remain constant.  But this test was done outside, so d3 is varying ,probably due to sunlight hitting the enclosure and also wind speed changes over the day.  The test was done on the north side of a building so direct sun was blocked, but the air may have heated from a nearby building.  Can see a daily bump around noon. Wind speeds varied from calm to peaks of 15 mph. Cloud cover varied from clear to overcast.

    d3 statistics- Difference between outdoor temperature and internal enclosure temp

    mean      14.649698
    std        1.821744
    min        9.625000
    25%       13.568750
    50%       14.787500
    75%       15.706250
    max       19.025000

    The R value (USA units) is calculated as:

    {𝑅=3.15459074295484(𝑇1+𝑇2)𝑤}

    So for fixed watts, its related to the temp difference d3 in the chart.

    R-value (USA units) Statistics

    mean      55.016429
    std        6.841497
    min       36.146352
    25%       50.956968
    50%       55.533941
    75%       58.984275
    max       71.447725

    Bottom line based on this experiment:

    For this enclosure design, a 'safe' outside temperature limit is about 10 deg F lower than the minimum internal enclosure temp desired.  Safe here is 3-sigma from the mean.  So a Li-ion battery with a -4F lower temp limit can be used at -14 deg F. 

    Unfortunately for my area the lower limit is around -20 deg F, so some sort of additional insulation, heating, or alternative battery is required for full unattended usage during winter. One option is to use battery power to heat the enclosure for the cold periods.  Since we seek  a 16 degree margin between inside and outside temp, a factor of 1.6, we need 1.6 factor in the watts of heat input to the enclosure, or 1.34 watts, instead of the 0.84 watts currently.  We could use a 'dumb' resistor, or we could use a CPU to do something better with the energy.

    (No Li-ion batteries were harmed in this experiment - it was done with mains power)

  • New Web App with Predictions

    Filip Mulier01/15/2022 at 17:49 0 comments

    In order to easily use some of the AI predictions on the recordings I put together a small web app that lets a user search for a particular animal and then hear the recorded sound detected by the AI algorithm.  It also shows the spectrogram of the sample, along with any other animal calls detected in the sound clip.  Samples come from 15 days of recordings made in 2021.

    Link: Animal sounds search engine

  • Example Recordings

    Filip Mulier10/10/2021 at 13:41 0 comments

    Here are two example recordings.  The first one is a complete recording done over 20 hours, with an audio file for each hour.  The files are recorded using the opus compression standard with a high quality setting.  The recording was done in April 2021 during the pandemic shutdown, 5 miles away from major highways in northern Wisconsin near a small field.  There are some human sounds, but the majority are natural.  The ADC gain is 50dB 30dB analog and 20dB digital.  At some point I want to calibrate the full audio path (mic - ADC Gain - sample value) to be able to provide the rough absolute sound pressure in the signal.

    Early Spring in a Small Field 2021-04-09

    The second recording was 14 hours recorded using flac (lossless) near a bog overnight in northern Wisconsin on June 13, 2021.  I made 2 files available because they are large (600MB per hour).  The ADC gain is 57db, 30dB analog and 27dB digital.  I ran these through my ML model and identified the timings of the detected bird calls with highest predicted probabilities in the recordings:

    File: Marsh 2021-06-13 4:04:55am central time

    Eastern Wood Pewee (t=1771.57)

    White-breasted Wood-Wren (t=1632.63)

    Veery (t=2182.36), and a Common Loon (t=276.05)

    I hear some bullfrogs too, but the AI model only handles birds.

    File: March 2021-06-13 5:04:55 AM central time

    Eastern Wood Pewee (t=306.57)

    Black Capped Chickadee (t=3407.63)

    Veery (t=964.47)

    Great Crested Flycatcher (t=575.00)

    Blue Jay (t=1389.47)

    Common Loon (t=3544.73)

    and possibly a Scarlet Tanager (t=419.21)

    I hear Trumpeter Swans too, but they are faint.

  • Recording Setup

    Filip Mulier10/09/2021 at 19:49 0 comments

    Recorder

    Here is a typical setup for recording.  The microphone housing with the ADC and raspberry Pi is on a tripod inside a non-woven bag to reduce wind noise.   I use my phone's hot spot to create a wireless network for the Raspberry Pi and my tablet.  I can then SSH into the Raspberry pi, edit the config script and launch the recording.  I then disconnect and shut down the hot spot.  I found that at high gain levels and during silent parts of the recordings I could hear a rumble or 'burp' sound every 5 seconds.  This turned out to be interference caused by the Raspberry Pi WIFI transmitter searching for a network.  I wrapped copper foil around the microphones and improved the microphone cable layout but it did not help. I also tried reducing the transmit power, but this does not seem to affect the actual power transmitted in the Raspberry pi.  So the current code has the option to automatically shut down the wifi 2 minutes after recording starts to avoid the issue.

    I got power usage down to about 60-70mA at 12 volts using a more efficient buck converter, so am able to easily run 48 hours on a 5000mAh 3 cell lithium ion battery.  When the PI is shut down, it uses 20mA at 12 volts.

    I've recorded about 30 days worth of recordings so far with this setup.  The most interesting are recordings from before sunset  to after sunrise for nature recordings.

  • Published code for Raspberry Pi

    Filip Mulier07/31/2021 at 13:19 0 comments

    I put the working Raspberry Pi code out on github.  It is capable of running on a Pi Zero W writing to either a USB stick or a large microsd (64GB) using about 240mA.  My power source is ~12v with a stepdown regulator.  This draws <100mA at 12 volts.

    Recording is controlled by editing a configuration script.  The script allows control over the recording format (ogg, flac, opus).  I recommend either opus for lossy compression (~100MB/hr) or flac (~600MB/hr) for lossless.  The script controls the file chunking, I have used 1 hr files.  So far I have run for multiple days, generating up to 120 files on an hourly basis.   Script also controls the gain settings of the ADC, currently analog and digital gain settings.  Metadata collection settings are also set here.

    Following metadata is stored in each audio file (most visible in Rythmbox or other music players)

    Date, Title, Artist, Album, Genre, Location, Comment (used for recording gain), tracknumber, tracktotal

    A couple odd issues:

    • I've needed to run arecord -L before my script, otherwise the ADC is not recognized by ALSA and the script fails.
    • There is an automatic shutdown flag in the config file.  When using this, I have noticed a bug where shutdown occurs prematurely at random.  If I do not have auto shutdown, recordings work the full length every time.  The code for shutdown seems straightforward, so not sure why this happens at random.

  • ADC board

    Filip Mulier05/08/2021 at 01:55 0 comments

    ADC board with 40 pin connector for raspberry pi


    Inside of the stereo microphone


    Front of microphone

View all 11 project logs

Enjoy this project?

Share

Discussions

Berry wrote 01/19/2024 at 20:34 point

Hello and congratulations on your project!
I was wondering if your project could use 4 microphones simultaneously? It seems a bit difficult to do so via I2S...

François

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates