Code Monkey home page Code Monkey logo

northcliff_spl_monitor's Introduction

Northcliff SPL Monitor

A Python Script that performs a basic sound pressure level monitor using the Pimoroni Enviro+

This script explores the potential of using the Pimoroni Enviro+ as a sound pressure level monitor. This project is still in the experimental phase. It should therefore not be used when accurate sound pressure level readings are required and should only be used as a base for future development.

Versions 1.0 and later use streaming to overcome the microphone's startup "plop" that was identified in the excellent review here

The microphone's startup "plop" can be seen here and it plays havoc with the sound readings if the microphone is started for each sampling. A DC offset remained after removing the startup "plop", seen here and removing that DC results in this.

Version 2.8 introduces improved A-Curve weighting. This requires the installation of some additional modules and an adjustment of the alsamixer microphone level to avoid clipping. These are highlighted in the Setup section.

Setup

sudo apt-get update

sudo apt-get upgrade

curl -sSL https://get.pimoroni.com/enviroplus | bash

sudo pip3 install matplotlib

sudo python -m pip uninstall sounddevice

sudo pip3 install sounddevice==0.3.15


For Versions 2.8 and later:

sudo apt-get install python3-scipy

sudo pip3 install git+https://github.com/endolith/waveform_analysis.git@master


For Versions 2.8 and later if wishing to use matplotlib for microphone debugging:

sudo apt-get install python3-gi-cairo


Follow instructions at: https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test including “Adding Volume Control”

Use the following instead of the documented text for ~/.asoundrc:

  1. #This section makes a reference to your I2S hardware, adjust the card name
  2. #to what is shown in arecord -l after card x: before the name in []
  3. #You may have to adjust channel count also but stick with default first
  4. pcm.dmic_hw {
  5. type hw
  6. card adau7002
  7. channels 2
  8. format S32_LE
  9. }
  10. #This is the software volume control, it links to the hardware above and after
  11. #saving the .asoundrc file you can type alsamixer, press F6 to select
  12. #your I2S mic then F4 to set the recording volume and arrow up and down
  13. #to adjust the volume
  14. #After adjusting the volume - go for 50 percent at first, you can do
  15. #something like
  16. #arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav
  17. pcm.dmic_sv {
  18. type softvol
  19. slave.pcm dmic_hw
  20. control {
  21. name "Master Capture Volume"
  22. card adau7002
  23. }
  24. min_dB -3.0
  25. max_dB 30.0
  26. }

For versions prior to Version 2.8:

Use alsamixer to set adau7002 capture level to 50


For Version 2.8 and later:

Use alsamixer to set adau7002 capture level to 10


Operation

For a numerical display of the current approximate overall sound level (Display 0):

Run python3 northcliff_spl_monitor.py or python3 northcliff_spl_monitor.py 0

or for a graphical display of current and past approximate overall sound levels (Display 1):

Run python3 northcliff_spl_monitor.py 1

or for a graphical display of current and past approximate sound levels by frequency band (Display 2):

Run python3 northcliff_spl_monitor.py 2

Version 2.1 adds the ability to cycle through the three displays by briefly touching the Enviro+'s light/proximity sensor

Version 2.2 adds a line in Display 1 that shows the maximum sound level that's been recorded since selecting that display, as well as the time and date when it was recorded. The maximum sound level is reset when selecting another display.

northcliff_spl_monitor's People

Contributors

roscoe81 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

northcliff_spl_monitor's Issues

CPU usage is excessive on a pi0

@roscoe81
Thanks for sharing this project. Wonderful initiative . I truly think sound is the sleeper sensor and is very useful especially when it comes to public safety applications.

Have you looked at optimizing the CPU usage . The script seems to be working and I see lively spikes in SPL when I clap or yell but I am seeing 80% CPU usage on my dinky little pi0 which has to do other tasks besides SPL measurment

I am using the latest 2.9 version. Was 2.1 version more gentle on the CPU usage. What if I am not interested in the frequency histogram, would that save a lot of CPU?

I think saving some recordings loud clips (when a dB level is exceeded) off for future analysis implemented as a circular buffer sounds very useful. Any thoughts on that ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.