Author |
Message |
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
TGV
Joined: Jul 03, 2009 Posts: 23 Location: Utrecht, The Netherlands
|
Posted: Fri Jul 10, 2009 12:14 am Post subject:
|
|
|
What do you mean by "averaging each harmonic individually"? An FFT gives the (complex) amplitude for single frequencies in a period of time. How do you average them? Across multiple time frames? |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Fri Jul 10, 2009 1:43 am Post subject:
|
|
|
Like this:
Code: | //
// vocal noise remover
fun void remove_noise () {
1024 => fft.size;
Windowing.hann(fft.size()) => fft.window;
complex s[fft.size()/2];
complex avg[fft.size()/2];
float alpha;
while (true) {
if (button_mute.state()) {
fft.upchuck();
fft.spectrum(s);
slider_alpha.value() => alpha;
for (int i; i<(fft.size()/2); i++) {
alpha * avg[i] + (1-alpha) * s[i] => avg[i];
}
ifft.transform(avg);
(fft.size()/2)::samp => now;
} else {
100::ms => now;
}
}
}
spork ~ remove_noise(); |
I have found that an alpha value of 0.5 works fairly well. Lower and you get more noise, higher and you get more artifacts. I'm told that this method is used in an audio file editing program, I forget which one. Try it, it works!
Les _________________ "Let's make noise for peace." - Kijjaz Last edited by Inventor on Fri Jul 10, 2009 5:21 am; edited 2 times in total |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Jul 10, 2009 5:00 am Post subject:
|
|
|
I don't get that code at all. Did you make sure to uncheck html?
I have serious doubts about that "for" loop, for a start....
What are you averaging? Averaging in time? In frequency? _________________ Kassen |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Fri Jul 10, 2009 5:25 am Post subject:
|
|
|
Kassen wrote: | I don't get that code at all. Did you make sure to uncheck html?
I have serious doubts about that "for" loop, for a start....
What are you averaging? Averaging in time? In frequency? |
Yes, I forgot to disable HTML - I fixed it. The less than sign in a for loop looks like HTML to the forum software, as I'm sure you've noticed. I am averaging in time. It's just a low-pass filter done with complex vector addition. You take a fraction of the running average, add in one minus that fraction of the new sample, and then add them and put them into the running average. This is done for each bin of the FFT. I seem to recall that you previously mentioned familiarity with this type of averaging, Kassen, you told me it's a low-pass filter before IIRC.
Les _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
TGV
Joined: Jul 03, 2009 Posts: 23 Location: Utrecht, The Netherlands
|
Posted: Fri Jul 10, 2009 6:54 am Post subject:
|
|
|
That's no low-pass filter, at least not a normal one (in the time domain). I think that if you feed it a pure sine wave of any frequency, it will come out identical (in the long run, not in the first iterations of the process, let's say the first second or so). This thing is a low-pass filter for changes in the amplitude of each frequency band.
Say you have a sine wave at 440Hz plus some noise, then the spectrum will show an almost constant amplitude at 440Hz but a varying one at all other frequencies (in particular the higher ones), e.g. 0.01, -0.004, 0.007, -0.009, etc. Then these values get low-pass filtered, so you end up with your original sine wave, but less noise.
Doesn't work for all signals, though. This thing needs several iterations of constant amplitudes to adapt, so if you feed it drums, it will take soften the attack.
If I understand it properly, that is |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Jul 11, 2009 5:19 am Post subject:
|
|
|
I think you are right, TGV, it's a bit like a filter on the analysis signal. We could even have higher order fiters on that, even highpass filters that would only let through the difference in signal, that might give some very unusual effects, I should experiment with it. _________________ Kassen |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24075 Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320
|
Posted: Sat Jul 11, 2009 5:31 am Post subject:
|
|
|
Les used this filter on his ChucK show yesterday, or at least that's what I understood. A recording of the show is to be found here, so you can listen to what it does (and for comparison, shows before that don't have the filter). _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
mosc
Site Admin
Joined: Jan 31, 2003 Posts: 18195 Location: Durham, NC
Audio files: 211
G2 patch files: 60
|
Posted: Sat Jul 11, 2009 8:39 am Post subject:
|
|
|
TGV wrote: | That's no low-pass filter, at least not a normal one (in the time domain). I think that if you feed it a pure sine wave of any frequency, it will come out identical (in the long run, not in the first iterations of the process, let's say the first second or so). This thing is a low-pass filter for changes in the amplitude of each frequency band. |
Yes, averaging a series of numbers is a low pass filter. I think that's what Inventor said. He didn't say this was a low pass in the time domain, he said it is an adaptive noise reducer, which it is. Quite a good idea, IMHO. _________________ --Howard
my music and other stuff |
|
Back to top
|
|
|
mosc
Site Admin
Joined: Jan 31, 2003 Posts: 18195 Location: Durham, NC
Audio files: 211
G2 patch files: 60
|
Posted: Sat Jul 11, 2009 9:03 am Post subject:
|
|
|
I listened to the noise reduced ChucK Show. Great show, Les. Anyway, the noise reducer really removes a lot of noise and the voices sound much better than on previous shows.
Still, there is some whine caused I think from some power main harmonics. Your adaptive filter won't get rid of those constant signals because they are seen as valid inputs signals.
You could get rid of the whine with a fixed equalizer, but an adaptive one would be more fun and useful. What happens if you differentiate the frequency domain coefficients as well? _________________ --Howard
my music and other stuff |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Sat Jul 11, 2009 12:07 pm Post subject:
|
|
|
What Howard says is even more true than might be apparent. That's because two weeks ago I switched microphones from the Emac's mic which is good for a computer mic to a homemade mic / guitar amp in a little black box, and boy is that mic noisy! All the noise was disguised somewhat last week by the hippy trippy vocoder, so last night's show was really the first clean-channel broadcast with the new mic and the noise reducer.
What I mean to say by this is that not only is the new setup quieter, it's also working with an even noisier input than we've had in the past. So yes to what Howard says, only even more so.
The whine is there at an averaging constant of 0.5, and gets noticeably louder at higher values. The mic is running off of a 9V battery, so I wonder if the whine is actually from the eMac's cooling fan which is near the mic physically, or if it is actually some kind of mathematical artifact. I just don't know really.
Truth be told, I invent or reinvent things like this all the time but I often lack the theoretical knowledge to fully understand how things work. I guess that's why I was speaking kind of analogously when I called it a low pass filter. To be precise it's a low pass filter applied in the frequency domain, which is a rather strange thing to do - but hey it works!
Anyway thanks for the comments all, I appreciate the observations. This kind of stuff is part of what makes my music hobby so much fun!
Cheers,
Les _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Sat Jul 11, 2009 4:54 pm Post subject:
|
|
|
I'm now thinking about the differentiation comments that Kassen and mosc made. If there is some whine that is constant, like power supply harmonics, then a differentiator should remove them because they are not changing in time. So it might be good to do both - first reduce the noise with averaging, then reduce the constant terms with some sort of differentiation. I wonder if simply subtracting the new samples would do this? _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
TGV
Joined: Jul 03, 2009 Posts: 23 Location: Utrecht, The Netherlands
|
Posted: Sun Jul 12, 2009 12:39 am Post subject:
|
|
|
You could use the same technique other noise cancellers use: finger printing. Take a piece of audio without meaningful signal, and subtract its spectrum from your recording. It's not quite as simple as I describe (you need the two signals to be in phase), but that will take care of some noise and the whine, hum, etc. Here is a description how CEDAR's (rather expensive) software does it: http://www.cedaraudio.com/intro/dehiss_intro.html |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Sun Jul 12, 2009 12:57 am Post subject:
|
|
|
Kewl, neat idea TGV. I may give that a try. Thanks for the suggestion.
Les _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
|
mosc
Site Admin
Joined: Jan 31, 2003 Posts: 18195 Location: Durham, NC
Audio files: 211
G2 patch files: 60
|
Posted: Mon Jul 13, 2009 9:28 pm Post subject:
|
|
|
Finger printing is a rather static technique. There is a training sequence of some sort, either silence or a know signal. As the channel changes you have to retrain. This technique is used in modems and other analog telecommunication circuits. Inventor's technique is. on the other hand, truly adaptive. _________________ --Howard
my music and other stuff |
|
Back to top
|
|
|
TGV
Joined: Jul 03, 2009 Posts: 23 Location: Utrecht, The Netherlands
|
Posted: Tue Jul 14, 2009 12:13 am Post subject:
|
|
|
Under normal circumstances, noise, whine, and hum are "static": it's the circuitry and microphones that generate it, and they don't change (at least not perceptibly). The adaptive technique has an advantage: you don't need a finger print, but it has problems with transients (feed it a snare or kick and you'll see) and it cannot take out whine and hum, since their harmonic amplitudes are almost constant over time. That's why I suggested it.
Anyway, there is no reason to use just one of them. You could use the finger-print technique on the end signal, and adaptive filtering on the mike, or something like that. |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Tue Jul 14, 2009 5:49 am Post subject:
|
|
|
mosc wrote: |
Still, there is some whine caused I think from some power main harmonics. Your adaptive filter won't get rid of those constant signals because they are seen as valid inputs signals.
You could get rid of the whine with a fixed equalizer, but an adaptive one would be more fun and useful. What happens if you differentiate the frequency domain coefficients as well? |
Call me lazy but in that case I'd first try sorting out the ground/mains situation before breaking out the DSP. Typically that takes less time and you save on headroom and sound quality. _________________ Kassen |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24075 Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320
|
Posted: Tue Jul 14, 2009 7:29 am Post subject:
|
|
|
In this case, as a listener, to me it seems that the airconditioner and a computer fan are the main sources of noise ... which would be something in favor of an adaptive technique. I must say that I dont quite understand what happens in the code, but it does filter noise and it doesn't give too many artifacts ... so not bad at all I'd say. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
|