psykulsk / RpiANC

Active Noise Control on Raspberry Pi
MIT License
116 stars 20 forks source link

Confusion in setup #11

Open boneykuriakose opened 1 month ago

boneykuriakose commented 1 month ago

Hi @psykulsk ,

First of all sorry to disturb you with this project after these many years. I am working on a project to implement ANC in cars, so after a long research I came to the conclusion that FX-LMS is the most suited algorithm for it and after some browsing I came across your project which I was very interested.

My doubt is that, in the figure given in the read-me section we can see 2 microphone used - error & reference. But while going through the code I can only see one microphone used. And how should be the final setup be like? I am only building ffANC so file, is it enough for the expected working?

I also faced issue with xrun but I adjusted the value in constant.h file so that now the xrun issue arises only after 1 minute. I am running this code on RPi4 and the normal CPU usage observed is around 12-15%, but when it come to the xrun issue it peaks to around 55%. What might be the reason for this? Hope you will respond to this...

psykulsk commented 1 month ago

Hi!

First of all, thank you for your interest in this project!

In my setup there was a single mic with left and right channel. Reference mic was setup on one channel and error mic on the other ;)

Regarding xrun, it's hard to say. Are you running this with signal capturing enabled? As far as I remember all data is in that case is being bufferred in memory, so maybe it fills up after a minute and OS has to use swap and write some of it to disk, or something like that? Sorry, it's been a while, so I don't have a more specific advise for now.

Good luck!

boneykuriakose commented 1 month ago

Thanks for your valuable inputs @psykulsk

Can you please help me with the concept of offline secondary path estimation. How the executable file "secPath" is to be used to estimate the secondary path and how the data that is obtained from this is to be used to run "ffANC" executable and get a better output ?

boneykuriakose commented 1 month ago

Hi @psykulsk

I am not clear how the executable "secPath" works because it runs in an infinite loop which don't exit until we introduce an exit condition after a certain time. That gives us some filter coefficients. Is that coefficients to be used for the executable "ffANC" by modifying the filter coefficients in the constants.h file?

psykulsk commented 3 weeks ago

Hi, sorry for not getting back to you for a while. Generally, yes, the secPath executable purpose is to run "offline secondary path modelling" that should result in filter coefficients that should be then used in the constants.h (I don't think it runs in an infinite loop, there is a hardcoded number of loops).

But it's hard for me to after all this time to recommend this way of gettting the secondary filter coefficients. There are many ways in which it should be improved (example, do not stop after a hardcoded number of loops, but after finding some local minimum of the errorr signal).

Offline secondary path modelling has been described in publications like this one: https://dr.ntu.edu.sg/bitstream/10356/172219/2/Internoise_2023.pdf

or in: "Sen M Kuo and Dennis R Morgan. Active noise control: a tutorial review".

boneykuriakose commented 3 weeks ago

Hi, @psykulsk Thanks for your effort and valuable time.

I tried to recreate the setup which you did. I also did the secondary path modelling and updated the coefficients. I played a white noise from a speaker and started running the application but noise cancellation was not observed. There is actually no impact. Maybe it is minute? I am attaching the images of my setup below.

1000080045 1000080046

psykulsk commented 3 weeks ago

Nice! So my setup did attenuate noise, but it couldn't be white noise because with white noise the adaptive filter is not able to optimize its coefficients since the error signal is random and evenly distributed in some frequency band. What worked was attenuation of noise with specific frequencies. So you may also try out it out, for example some sine wave noise between 1-20 kHz. But don't expect incredible results. My setup did attenuate sine wave noise but it was not very stable and required significant time to adapt. I had a similar setup running on a digital signal processor and it worked way better. Good luck!

boneykuriakose commented 2 weeks ago

@psykulsk , I was not able to get a noticeably noise reduction from this setup and by using sine wave noises with specific frequencies. But there was a small reduction when I compare the audio dumps while ANC 'on' and 'off'. Which digital signal processor did you use? Thanks a lot for your work !

psykulsk commented 2 weeks ago

It was this one: https://www.hifiberry.com/shop/boards/dacplus-dsp/

I programmed it via Sigma Studio: https://www.analog.com/en/resources/evaluation-hardware-and-software/software/ss_sigst_02.html

Here are my project files from Sigma Studio in case they would be of any help to you: https://drive.google.com/drive/folders/1bxjX9sVlrDmr8BRJVZpXwxszgh_evvih?usp=sharing

But I don't have any more documentation of that setup any more ;/

boneykuriakose commented 2 weeks ago

Thank you for your valuable information.

boneykuriakose commented 5 days ago

Hi @psykulsk

So did you use this "HiFiBerry DAC+ DSP" as stand alone or used it via the Raspberry Pi. How was the input and output devices connected? Was it possible to configure both input and output using the I2S protocol? Can you briefly explain the steps?

psykulsk commented 4 days ago

Hey, I don't remember too many details about this, but in general yes, I believe I used i2s for both input and output. There were some errors in pin description in their datasheets, I remember starting a thread about this here: https://support.hifiberry.com/hc/en-us/community/posts/360003426118-DAC-DSP-board-DSP-analog-audio-output-I2S-input

boneykuriakose commented 4 days ago

Ok so you used the "HiFiBerry DAC+ DSP" only, without Raspberry Pi.