Code Monkey home page Code Monkey logo

rpianc's Introduction

RpiANC

Implementation of Active Noise Control Algorithms for Raspberry Pi.

This is the accompanying code to the publication 'Adaptive Active Noise Cancelling System for Headphones on Raspberry Pi Platform' that has been presented at the Signal Processing Workshop 2020 conference https://mrweek.org/spw/

Link to the article: https://ieeexplore.ieee.org/document/9259141

Used hardware

Assembled system

System schematic

Build and run commands

Example:

mkdir build && cd build
cmake ../ && make all

Main binary that does feedforward active noise control:

./ffANC

Simple tests that show how LMS and FxLMS attenuate simulated noise on matplotlib plots:

./lmstest
./fxlmstest

Build dependencies

Builds tested on Ubuntu 18.04 and Raspbian distributions:

Cmake >= 3.7
Alsa library, so packages like: libasound2, libasound2-dev.
Python2.7 libraries (matplotlibcpp dependency) so packages like: python-dev
OpenMP directives (propably supported by your compiler)

Repository and code structure

Cmake and make commands build a few binaries. The main one, is the ffANC binary that executes tha main function from the feedforward_anc.cpp file. Inside this file you can define or remove the DEPLOYED_ON_RPI macro to change devices used for capture and playback. Define CAP_MEASUREMENTS macro to capture sample values and save them to files.

The main function of the ffANC target executes a specified number of loop iterations. During each iteration 3 main operations: capture of new samples, sample processing and playback of the calculated samples, are executed concurrently, in a fork-join model. Firstly, each of the 3 operations is executed in a separate thread. Then, output samples from each operation are exchanged. Most recently calculated output samples are moved to the input array of the playback function and newly captured samples are moved to the input array of the signal processing function.

In constants.h file, you can find the names of devices used on Raspberry Pi and other constants used in signal processing.

All signal processing is in the header files under the Headers and the processing.cpp source file.

Scripts directory contains python and bash scripts that automate measurements, gathering data, deploying code etc.

Results

Comparison of attenuation of a noise signal of a constant frequency between the created ANC system and Sennheiser HR 4.50 BTNC headphones.

Attenuation comparison

Disclaimer: this implementation worked on a specific hardware setup and attenuated a specific (constant frequency) type of noise. It is not guaranteed that it will work out of the box on a different setup. I've published the code on github so that when someone else is going to try to implement something similar this codebase can be used as a starting point or an inspiration.

Useful links, articles, etc.

Included third-party libraries

This software uses matplotlibcpp - see matplotlibcpp-license.txt

rpianc's People

Contributors

psykulsk avatar penify-dev[bot] avatar

Watchers

Robert Bongart (MSc MSc MA) avatar

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.