|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
S-3D enthusiast
|
I made a noise canceller. It has two inputs and two outputs. The inputs are called called Primary and Reference. The out puts are called OutCorr and OutUncorr. Corr and Uncorr stands for correlated and uncorrelated.
This filter uses the LMS algorithm to adapt dynamically the FIR filter coefficients. The FIR filter has 44 taps. You input is noise and desired signal to Primary. You input noise only to Reference. It is best at removing periodic noise. It works best the if the noise in the primary and in the reference are recorded at the same time. It is especially true if the noise isn't much periodic. If the noise is highly periodic, it can be sent delayed to reference and of different amplitude and it will still be removed effectively. Example : You record someone talking beside an engine idling. It is the Primary. You record the engine idling. It is the reference. Both were recorded at different times but the noise will still be effectively removed because it is periodic. If you recorded someone speaking in the wind and the wind at different times, the wind would not be removed because it is random. There are two outputs. Correlated output is what you input to Primary minus the noise. Uncorrelated output is what was substracted from Primary. You can get it here : http://pages.globetrotter.net/samaus...ller44taps.zip Get it and experiment. I am waiting for your feedback. After this plugin, If I have time, I think I'll get to work on the bass booster here : http://www.hardwareheaven.com/effects-dsp/66173-headphone-bass-booster-idea.html It looks interesting. |
|
|
|
|
|
#2 |
|
DriverHeaven Lover
Join Date: Sep 2003
Location: Romania
Posts: 123
Rep Power: 0 ![]() |
great...i belive its the first noise-cancelation plugin available...i didnt test it already but the ideea is really great. cya
|
|
|
|
|
|
#3 |
|
DriverHeaven Junior Member
Join Date: Dec 2003
Location: Australia
Posts: 40
Rep Power: 0 ![]() |
Nice work. I will try it this week and let you know how it goes.
Any chance on working on something like this... http://www.hardwareheaven.com/effects-dsp/69525-dsp-challenge-feedback-killer.html :-) |
|
|
|
|
|
|
|
S-3D enthusiast
|
In fact, I started working on this plugin because of your post about making a feedback suppression DSP. I was looking for a way to automatically detect feedback and cancel it. I thought I could maybe use a system of noise cancellation. I finally succeeded in making a noise canceller but it cannot cancel feedback (as far as I know).
The filter coefficients are dynamically adapted to try to reduce the power of the OutCorr signal. The coefficients adjust themselves automatically. It takes many cycles for the coefficients to stabilize. Once it's done, the filtering is good. If the Reference signal change, the coefficients also change to readapt. I thought it might be possible to use the filter to cancel feedback. I tried to delay OutCorr and input that to Reference. That way, you would cancel the periodic part of the signal. It would not cancel much what changed in the signal (the music you play). It does not work, at least for now. I think feedback varies in amplitude and frequency. If it varied only in amplitude and slower, the noise canceller could cancel it. If you have any useful links to noise and feedback canceling theory, direct me to it. The plugin could maybe be improved further. Last edited by Tril; Mar 5, 2005 at 06:58 PM. |
|
|
|
|
|
#5 |
|
DriverHeaven Senior Member
Join Date: Mar 2004
Posts: 1,732
Rep Power: 0 ![]() |
The Bass booster plugin would be great and would be very useful for people with lower end computer speakers..the harmocin modelling using the missing fundememntal priciple is a pretty neat effect, and it is clearly audible..but there is no vibrations, so after ahwile you just want a sub...kinda teases you..lol..I wanted to do it but I am a little busy right now...there is a formula for the function floating around out there that produces the harmonics...good luck, I was talking with Tiger about producing the plugin, but he's busy to...I think it would be a great addition to KX...if done properly.
|
|
|
|
|
|
#6 |
|
DriverHeaven Addict
Join Date: Dec 2002
Posts: 259
Rep Power: 0 ![]() |
It works grate.
About feedback, I made feedback destroyer using a second order IIR notch filter. There are tons of papers in Internet about this topic, some of them very complicated. The idea is that IIR filters do its job better, but has problems of stability and convergence. So a lot of alternative (and more complicated) to LMS algorithms has appeared... Here you have a short paper that I used to make a feedback destroyer: http://www.aut.ac.nz/research_showca...s_iconip99.pdf |
|
|
|
|
|
|
|
S-3D enthusiast
|
I've updated the plugin. I've changed :
[color=yellow]static Mu[/color] to [color=yellow]control Mu[/color] Mu controls the convergence speed. If Mu is high, the plugin adapts faster if the noise source change but at the same time it can cause the adaptation to diverge. If it diverges, the noise will get louder in the filtered signal. You can often set Mu to 100% without problems but sometimes you'll have to set it lower. The plugin adapts continuously the coefficients to filter the noise. I would like to know at all times what is the shape of the impulse response of the adaptive filter. To know that, I would need the plugin to read the values of the coefficients stored in static variables and output those values. The oscilloscope plugin can make a graph of the signal inputed to it. That means that it is possible to output the value of a variable (the signal) grahically. I would like to output the 44 coefficients as numbers from -1 to 1. So I would convert the hexadecimal numbers to decimal before outputing graphically. I would also like to output those values from -2147483647 to 2147483647 (or -1 to 1, it's the same, it's only the axis values that would change) on a grahic. It would be a little like the oscilloscope plugin except that you would output 44 point on the graphic at every x sample number (or x time) and the curve would not move to the left because of time. I've never coded in C++ for kX so I would like some help to get me started on this. I'll look into the SDK to learn but I'll appreciate any help other forum members could give me. Tiger M would probably be able to help get me started and give me some advice on how to proceed since he made the oscilloscope. Once It's done, I would like to make an improved version of the noise canceller where the signal goes through to filters. The first one is the same as in the current and the other is a delay. With checkbox unchecked, the plugin would work the same as right now and the delay would be set to zero. With it checked, it would freeze the impulse and adapt the delay to minimize the noise. This new option could be used when you would like the plugin to filter periodic noise made for example by a fan bearings without filtering other noises around. You would input only the bearings noise to reference with the checkbox unchecked. The plugin would adapt to the noise and cancel it well. You would then check the checkbox and the impulse response (the values of the coefficients) would freeze and the automatic adaptation of the delay would then be activated to minimize the noise. In theory it should work. In practice, tests would be needed to know if it works well. Tril Last edited by Tril; Mar 7, 2005 at 02:48 AM. |
|
|
|
|
|
#8 |
|
HardwareHeaven Senior Member
Join Date: Jan 2004
Location: St. Cloud, MN
Posts: 492
Rep Power: 0 ![]() |
Good luck working on the bass booster plugin; if you need any help, i will do what I can to assist you. I noticed that I cannot run two noise canclers at once (if I wanted to cancel stereo noise) one "clicks off" and stops outputing (testable by hooking into the removed noise from both plugins, one removes noise, one wont.) I dont know if this is a bug or not. Good work so far!
__________________
COMP: Dual Intel PIII 733 Mhz; GeForce 4 Ti 4600; 1.128 Gb RAM; SB0350 (Audigy 2 ZS Platnium) STEREO(I UPGRADED):Crown Audio K1 and K2 amplifiers (4000 watts at .1% THD ), JL 13w7 Subwoofer (6.5 CF) (2) 18" PR's, Klipsch SB-1's, some cement blocks for speaker stands...
|
|
|
|
|
|
|
|
S-3D enthusiast
|
I don't know why it does not work with two at the same time for you. I just tested it and it worked with two at the same time. What plugins did you have loaded when you tried? Do you have other plugins loaded that use itram? When you code a plugin that uses itram you must not forget to use : itramsize xx. Where xx is the number of reserved itram for the plugin. Currently, the plugin uses 47 itram so with two plugins you need 94 itram.
My plugin uses 0 to 68 so I use : itramsize 68 You may be using a plugin where the writer forgot to set it correctly. It's probably unlikely but I've done it myself a few times. I'll try to improve the plugin and I'll play with it when I have time. I'd like to see if it's possible to quiet down my pc noise with a well placed speaker and a well placed mic. It won't probably work too well but I want to experiment. The chances are high that It would add even more noise instead of removing it but it would be nice if it worked. Last edited by Tril; Mar 8, 2005 at 04:12 AM. |
|
|
|
|
|
#10 |
|
HardwareHeaven Senior Member
Join Date: Jan 2004
Location: St. Cloud, MN
Posts: 492
Rep Power: 0 ![]() |
did you try conecting the uncorr output to speakers or headphones? on the first plugin loaded (for me) it does not have any output. I have an audigy 2 zs.
EDIT: I have plenty of Itram and other resources so I do not believe this is the issue.
__________________
COMP: Dual Intel PIII 733 Mhz; GeForce 4 Ti 4600; 1.128 Gb RAM; SB0350 (Audigy 2 ZS Platnium) STEREO(I UPGRADED):Crown Audio K1 and K2 amplifiers (4000 watts at .1% THD ), JL 13w7 Subwoofer (6.5 CF) (2) 18" PR's, Klipsch SB-1's, some cement blocks for speaker stands...
|
|
|
|
|
|
#11 |
|
kX user
Join Date: Apr 2004
Posts: 851
Rep Power: 0 ![]() |
This is strange...
It might be an issue with multiple use of an 'in' register. Tril, are you using an input reg more than once in the code?
__________________
Miss you, Steve... |
|
|
|
|
|
|
|
|
S-3D enthusiast
|
Quote:
I think I made a mistake in the code because I did not understand correctly when I wrote it. I used : macwn Error, PrimarydelayedRead, FilterOutput, 1; It should be : macsn Error, PrimarydelayedRead, FilterOutput, 1; When calculating the coefficients, the filter uses the sign of error to choose wich way to go to cancel the noise. As long as error did not overflow the mistake changed nothing. If it overflew, it caused the filter to try to adapt in the wrong direction. |
|
|
|
|
|
|
#13 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
Right. This is very interesting
![]() A year ago i installed a PC in my car to try to create an ANC system for a 4th year engineering project. I did a lot of work, but no actual cancellation in car Basically, to summarise my results; You need to use a FX-NLMS system you ideally want 512 filter taps. Can this many taps be implimented on the audigy ZS, when do we hit hardware limits? I have a electronic copy of my report that details some simluations, and reasoning behing FXLMS choice - if you are interested, I'd be delighted to email you my report, it should make relitively simple reading on this subject. The report is 3.5megs however. I managed to open the .da file with notepad, does a .da just import striaght into KX DSP (i cant test, as I am not on my car PC) - unfortunately I dont understand this machine code ![]() Please do get back to me on this, it sounds very interesting. Stu Last edited by stuthemong; Apr 19, 2005 at 12:48 AM. |
|
|
|
|
|
|
||
|
S-3D enthusiast
|
Quote:
I find that subject very interesting. Quote:
I wanted to test the filter I made with a larger number of coefficients so I decided to make a VST filter. It does not use the soundcard hardware but the computer processor and system memory. With a VST plugin I'm not limited in term of memory but I'm limited on CPU power. I haven't had a lot of time to put on that recently. My VST plugin does not work yet. It's a little more complicated than programming filters for kX. I programmed a ringbuffer (can also be called a circular buffer) in the VST plugin and it is possible that there is a pointer error somewhere. I'll have a signal processing class next semester. That will be interesting. Last edited by Tril; Apr 19, 2005 at 10:27 PM. Reason: removed my email address from message to keep spam scanners from finding it |
||
|
|
|
|
|
#15 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
Tril,
Awesome stuff. 200 odd taps should get to an interesting stage. Ill breifly outline some differences in noise cancellation algorithms from memory. LMS - the first, but very brittle, as you have found, the value of Mu is important NLMS - normalised LMS, this is very siilar, but automatically updates the Mu parameter, making it large when you are far from a close solution, and low when you are near it. This dynamically updates (it can go both ways if teh system changes), and means you can get fast tracking (high Mu), and high accuracy (low Mu) in the same alogirtm. A *great* improvement over simple LMS, and very simialr. FXNLMS (we always use NLMS, never LMS anymore really) is called Filtered normalised LMS. Effectively the filtered part relates to the fact that the model now contains an approximation of the physical system. In a ANC system you have to think about what is happening. The DSP does the maths, this is output via buffers to the analog output on S/C (with ASIO, this is a 2.3ms delay), the amplifier is instant, but speakers have a time delay between getting a signal, and outputting a note, a few ms, hten the sound has to travel to your detecting mircrophone. This delay casues havoc with the LMS system, they are not able to deal with delays. The FXLMS system inserts an estimate (which is found by a nice little side LMS optimisation, outlined in my report) between the output of the NLMS system, and the responding signal reaching the detector. This makes the system far more robust, and means that effective noise cancellation of harmonics is possilble. Ill send you my report when i get back tonight, it should make things a bit clearer. In my instance, in car, I can expect significant reductions - 10 Db of engine noise if i can get the system working. Id love to!!! Yours Stu |
|
|
|
|
|
|
||
|
S-3D enthusiast
|
The program as it is now won't work in your car. It uses
Error = PrimarydelayedRead - FilterOutput The error is internal. Basically you add the Primary signal and an inverted filtered Reference signal in the sound card. To get it to work in a noise cancellation system, you need to output the inversed Reference signal through speakers. You also need to get the error with an error microphone. I've done another plugin that does that but it's not posted. Quote:
Quote:
In a FIR filter such as here you need one memory space by coefficient. You also need one memory space for each past sample. You are now at 704/2 = 352 coefficients. But you need some more variables in the noise cancellation plugin and in others plugins used. By having only the noise cancellation loaded plus the minimal number of other plugins loaded I suppose you could reach close to 330 coefficients. That's a guess because I haven't tried and I don't know exactly how much memory is needed without testing. I have a soundblaster live! (emu10k1) so I have half that many ressources. The higher number of coefficients I tried was around 100. |
||
|
|
|
|
|
#17 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
tril,
understood, though I'm that together we can get something useful out, as you have done most the hard work ![]() The plan for a decent ANC system is to get some sort of harmonic that is correlated to the noise signal. E.g. in my car I can put a microphone in the engine bay, or even something like an acceleromiter, or even something that logs spark plug firings. I then put a seperate microphone by my ear in the car, and it is that signal that the ANC system forces to zero. This is the masterplan anyway ![]() http://people.pwf.cam.ac.uk/sbm24/activenoise.doc Is a link to my project, please let me know when you have d/led it, and ill remove it. The interesting parts are right at the end where i talk about the ANC. Stu |
|
|
|
|
|
|
|
|
S-3D enthusiast
|
Quote:
I won't be able to work on the plugin for the next two weeks. It's the last two weeks of the semester and I'm overloaded with work. I'll find some time to read your report and think about the system. Tril |
|
|
|
|
|
|
#19 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
its not a problem.
I have since read a sticky on DSP programming. My understanding is this .da file can be loaded into KX and that compiles to a .kx file via dane - is this correct? I must confess to feeling itchy - bin your work, lets work on this, FAR more fun ![]() I will have a look at your code, and ask questions on it - perhaps if you can help me understand the code, i can help write it - the only probelm i have is the audigy is in car - so i may well buy another for my home pc - can i just confirm one thing - does this workin 3587 (IIRC what i am running), or the newest beta version - waht differences are there that changes what you write in compiler?All the best, Stu I will leave the report up for a couple of weeks actually incase anyone else is interested |
|
|
|
|
|
|
|
S-3D enthusiast
|
da code works on all versions of kX driver. It's simply a .txt file renamed to .da.
Plugins using .kxl are .dll renamed to .kxl. They are made using C++. The advantage of C++ is that you can directly write to the memory of the sound card. You can also read. You can also add a better interface, combo boxes and checkmarks. It is useful to reduce your program code length. You can remove code that changes parameters by the user from the dane code and use c++ instead to change it thus using less instructions and less memory. The noise canceller filter was written in .da so it is compatible to all versions. You can use the dane editor or any text writer software like notepad to write .da plugins. Writing dane plugins is easy. The hardest part is finding the algorithm (or equations) you need. If you have any questions feel free to ask. |
|
|
|
|
|
#21 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
ok, so the .da should just load straight into KX with an input and output tab.
I have outlined the iterative forumula that needs to be run in my report, Its 3 or 4 lines - I wonder how we can manage the intermediate results in memory. This writing to RAM thing, how slow is it compared to the KX DSP? I imagine we are talking a lot more delay - do we know more about this? The less delay we have, the better ANC works by far Stu |
|
|
|
|
|
|
|
|
S-3D enthusiast
|
Quote:
xTram is system memory (RAM). It is also used to create delay lines. You can't use it as fast because of latency. I'd say you need around 25 samples between write and read to/from it. If we wanted to, we could use it in the filter to make the filter as big as possible. It's 64 on emu10k2. 64/2=32. We could add 32 coefficients to the filter if we use it. We would use it all on the past samples for the delay line. We would need to insert a sample in it at least 25 samples before using it. It is easily possible. There would be no delay because we introduce that data in advance in xTram. We could not use xTram for the coefficients because they need to change faster. GPRS is the normal memory. It's on the card so you can read and write multiples times to it in a cycle. |
|
|
|
|
|
|
#23 |
|
DriverHeaven Junior Member
Join Date: Feb 2004
Posts: 23
Rep Power: 0 ![]() |
Tril, all sounds very complex
![]() When you get a chance to look at the algorithm we can think about how best to do this. I dont think that we will run into huge problems so long as we have say 8 bits resolution. The other thing we can do is not update the filter every sample, but every 50th or so - maybe this way we can lower the overall DSP computing complexity, which may buy us time in buffers etc.. Stu |
|
|
|
|
|
|
|
S-3D enthusiast
|
I worked a bit more on this project of active noise cancellation. I gave up trying make a plugin for the emu10kx. There are not enough ressources. That's too bad. It would have been almost real time.
It needs code for two FIR filters and the adaptation. There are not enough GPRs and instruction to do that. The NLMS algorithm works better than the LMS algorithm but it needs to do divisions. If there were only one or two divisions, I could use an approximation of division but there is a need for hundreds of them. I made two VST filters for ASIO and I use KRISTAL to run them. The first filter does the same thing as the dane plugin I made before but with some more options. It works well. It takes a lot of processing power though. With a FilterLength of 400, I get about 90% CPU usage on my AMD Athlon Thunderbird clocked at 1207 MHz. It uses time domain convolution as the dane plugin. It would use less CPU if the convolution was do in the frequency domain using FFT but I can't use that. When using FFT, you do the convolution on a block of input. It gives you back the convoluted block of input. I need to do the convolution on one sample at a time so that the coefficients of the filter are adapted between each convolution. You can use that plugin with two microphones and headphones (or a peak plugin) to know how much the noise is reduced. This filter tells you what is the maximum amount of noise reduction that you will be able to achieve with the second filter in a real world situation. If you can get a good amount of reduction with this plugin you should not even try the second one. The plugin can also be used to find an estimation of the impulse response of the forward path, that is, how does the sound change between the output of the sound card and the input to the microphone. The coefficients can be saved. The second filter can load the coefficients made by the first plugin. You input what comes from a microphone close to a noise source in the left channel and what comes from the microphone in the listening position in the right channel. You adjust the settings of the filter and THEORICALLY you are supposed to notice a diminution in the ambiant noise. The second plugin takes less CPU than the first one even when using two FIR filter of length 400 because (I think) there is a calculations needed in the first plugin that is not needed in the second. In PRACTICE, I was only able to achieve an increase in ambiant noise. All I get is feedback from using the speakers and the microphones together. It is much harder to achieve something working correctly when you have to take into account the delay caused by using ASIO and the time the sound takes to move in the air. Even if it does not work, it is still an interesting subject. Better microphones might help. I'm currently using two different electret microphones connected on two different sound cards. One card is compatible with kX and the other one is not. I unmuted the volume of the mic on the incompatible card. I plugged a cable from the output of the non compatible card to the line in of the compatible cable and used Lemury's ADC plugin to get Mic and Line in at the same time. I should at least use two identical mics even if they are cheap. Since the plugins I made are not kX plugins but VST plugins I won't share them here. They also don't really work well (especially the second one) and take alot of CPU. It also does not appeal to musicians since they don't need it. I thought I would share my experience. I found coding VST plugins harder than kX plugins. Especially in the beginning. The emu10kx chips use instructions that saturate or wraparound on overflow. You need to take care of that yourself when coding VST plugins. I forgot at first and nothing worked. All that testing and programming of plugins would not have been possible without the kX drivers as I needed a custom DSP to route the mics directly to asio, etc. Thank you Eugene and all the others for the drivers. Well, that post was a bit long.
|
|
|
|
|
|
#25 | |
|
HardwareHeaven Junior Member
|
Re: I made a noise canceller filter (get it here)
Quote:
|
|
|
|
|
![]() |
| Thread Tools | |
|
|