Monday, May 27, 2013

AVR Atmega audio input RMA using EMA (Exponential Moving Average)

audiogetema is a simple library you can use to interface with a ac audio input.
It reads data from an ADC pin and returns the RMS value of the input using an exponential moving average filter.
Exponential moving average (EMA) is a type of infinite impulse response filter that applies weighting factors which decrease exponentially. The weighting for each older datum point decreases exponentially, never reaching zero.


Here the mean part of RMS, is calculated during the sample grabbing, using an ema filter.
Using this method we can implement a attack and and decay smooth filter - that is an EMA filter.
The filter idea comes from Audio VU Meter by Anatoly Kuzmenko.
The smooth parameter can be modified.

As audiogetavarage library here is also implemented a dynamic bias.

Setup parameters are stored in file audioget.h

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

2 comments:

  1. Hello,

    What are the expected values on the output ?

    ReplyDelete
    Replies
    1. Hello, the sample main.c file output RAW values, raw RMS values, and SPL (dB) values.

      Delete