{"id":15172869,"url":"https://github.com/psykulsk/rpianc","last_synced_at":"2025-09-23T15:56:54.171Z","repository":{"id":38799484,"uuid":"136456178","full_name":"psykulsk/RpiANC","owner":"psykulsk","description":"Active Noise Control on Raspberry Pi","archived":false,"fork":false,"pushed_at":"2023-08-15T19:35:25.000Z","size":561,"stargazers_count":123,"open_issues_count":0,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-31T14:22:10.640Z","etag":null,"topics":["activenoisecancellation","cpp","digital-signal-processing","dsp","noise-cancellation","noise-reduction","raspberry","raspberry-pi","raspberry-pi-3","signal-processing"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psykulsk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-07T09:44:49.000Z","updated_at":"2025-01-21T17:19:00.000Z","dependencies_parsed_at":"2022-07-13T05:50:45.629Z","dependency_job_id":null,"html_url":"https://github.com/psykulsk/RpiANC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2FRpiANC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2FRpiANC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2FRpiANC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psykulsk%2FRpiANC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psykulsk","download_url":"https://codeload.github.com/psykulsk/RpiANC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238258977,"owners_count":19442509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activenoisecancellation","cpp","digital-signal-processing","dsp","noise-cancellation","noise-reduction","raspberry","raspberry-pi","raspberry-pi-3","signal-processing"],"created_at":"2024-09-27T10:21:49.016Z","updated_at":"2025-09-23T15:56:49.114Z","avatar_url":"https://github.com/psykulsk.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RpiANC\n\nImplementation of Active Noise Control Algorithms for Raspberry Pi.\n\nThis is the accompanying code to the publication 'Adaptive Active Noise Cancelling System for Headphones on Raspberry Pi Platform'\nthat has been presented at the Signal Processing Workshop 2020 conference https://mrweek.org/spw/\n\n\nLink to the article: https://ieeexplore.ieee.org/document/9259141\n\n\n## Used hardware\n* Raspberry Pi 3 Model A+\n\n* Two Tiny MEMS Microphones - https://www.adafruit.com/product/3421\n\n* On-ear headphones connected via 3.5mm jack\n\n\n![Assembled system](docs/rpi_anc_system.png)\n\n![System schematic](docs/anc-system-schematic.png)\n\n\n## Build and run commands\n\nExample:\n```\nmkdir build \u0026\u0026 cd build\ncmake ../ \u0026\u0026 make all\n```\n\nMain binary that does feedforward active noise control:\n```\n./ffANC\n```\n\nSimple tests that show how LMS and FxLMS attenuate simulated noise on matplotlib plots:\n```\n./lmstest\n./fxlmstest\n```\n\n## Build dependencies \n\nBuilds tested on Ubuntu 18.04 and Raspbian distributions:\n```\nCmake \u003e= 3.7\nAlsa library, so packages like: libasound2, libasound2-dev.\nPython2.7 libraries (matplotlibcpp dependency) so packages like: python-dev\nOpenMP directives (propably supported by your compiler)\n```\n\n\n## Repository and code structure\n\nCmake and make commands build a few binaries. The main one, is the `ffANC` binary that executes tha main function from\nthe [feedforward_anc.cpp](Mains/feedforward_anc.cpp) file. Inside this file you can define  or remove the DEPLOYED_ON_RPI\nmacro to change devices used for capture and playback. Define CAP_MEASUREMENTS macro to capture sample values and save\nthem to files.\n\nThe main function of the `ffANC` target executes a specified number of loop iterations. During each iteration 3 main\noperations: capture of new samples, sample processing and playback of the calculated samples, are executed concurrently,\nin a fork-join model. Firstly, each of the 3 operations is executed in a separate thread. Then, output samples from each\noperation are exchanged. Most recently calculated output samples are moved to the input array of the playback function\nand newly captured samples are moved to the input array of the signal processing function.\n\n\nIn [constants.h](Headers/constants.h) file, you can find the names of devices used on Raspberry Pi and other constants used in signal processing.\n\nAll signal processing is in the header files under the [Headers](Headers)\nand the [processing.cpp](Sources/processing.cpp) source file.\n\n[Scripts](Scripts) directory contains python and bash scripts that automate measurements, gathering data, deploying code etc.\n\n## Results\n\nComparison of attenuation of a noise signal of a constant frequency between the created ANC system and Sennheiser HR 4.50 BTNC headphones.\n\n![Attenuation comparison](docs/attenuation_comp.png)\n\n\nDisclaimer: 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\non 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.\n\n\n## Useful links, articles, etc.\n\n* [Microphone wiring and connection guide](https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test#wiring-for-stereo-mic-3061608-5)\n* [Introduction to Sound Programming with ALSA](https://www.linuxjournal.com/article/6735)\n* [A Tutorial on Using the ALSA Audio API](http://equalarea.com/paul/alsa-audio.html)\n* [Rpi I2S thread](https://www.raspberrypi.org/forums/viewtopic.php?t=91237)\n* [Implementation of FIR Filtering in C](https://sestevenson.wordpress.com/implementation-of-fir-filtering-in-c-part-1/)\n\n\n## Included third-party libraries\n\nThis software uses matplotlibcpp - see matplotlibcpp-license.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsykulsk%2Frpianc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsykulsk%2Frpianc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsykulsk%2Frpianc/lists"}