noise cancellation

jamin's icon

im fairly new to max/msp and im undertaking a noise canceling project, i need to cancel the incoming signal with an inverted phase version of the original. issues arose with the latency of passing one of the split signals into the pfft~ object. im not sure how do deal with this latency such that it maximizes the cancellation process back in the main patcher.some sort of feedback from the main patcher to the pfft patcher needs to be to be carried out. any thoughts?

Leafcutter John's icon

you can invert a signal simply by multiplying it by -1. I'm not sure what you are doing in fft. but maybe this is helpful?

jamin's icon

i think the inversion of the signal needs to carried out within the frequency domain, i want to cancel only selected frequencies from within the signal. so im thinking of shifting the phase of individual selected bins from a cartpol object. im just a bit lost as to how to select and phase shift certain bins. any ideas?

pvillez@gmail.com's icon

Hi Ben,

Unless the extracted noise is sample by sample identical to the origiinal
signal, just inverting won;t do much.

As far as the latency goes you can compensate by having a delayed copy of
the untreated and then adding afterwards.

best, P

On 03/01/2008, Leafcutter John wrote:
>
>
> you can invert a signal simply by multiplying it by -1. I'm not sure what
> you are doing in fft. but maybe this is helpful?
> --
> http://www.leafcutterjohn.com
>
> "The Forest And The Sea"
> Out on Staubgold Records
> Staubgold 68 CD/LP
>

notyouraveragejoe's icon

One good way to cancel noise is in the frequency domain.
In your Pfft, use a
gates so that you only frequency bins that are above a certain amplitude.
What this does is cut out all quiet sounds, allowing only louder desired
sounds.
As my example (hopefully) shows. Haven't actually tested this, so sorry if
it doesn't work.
This is a good method as it can be rather effective at removing noise
without affecting the desired signal. Avoid setting the noise level to too
high a number as you will be cutting out parts of your desired signal and
will create audible artifacts.

Max Patch
Copy patch and select New From Clipboard in Max.

On 03/01/2008, ben Gilman wrote:
>
>
> im fairly new to max/msp and im undertaking a noise canceling project, i
> need to cancel the incoming signal with an inverted phase version of the
> original. issues arose with the latency of passing one of the split signals
> into the pfft~ object. im not sure how do deal with this latency such that
> it maximizes the cancellation process back in the main patcher.some sort
> of feedback from the main patcher to the pfft patcher needs to be to be
> carried out. any thoughts?
>

Gary Lee Nelson's icon

I suppose this is related. I have some digital hardware synths coming into
MSP via an 828 and a mixer. I am getting a lot of machine noise in the
audio. When I unplug the power transformer from my MacBook it reduces and
removing the second monitor reduces it further. Any suggestions.

Cheers
Gary Lee Nelson
Oberlin College
www.timara.oberlin.edu/GaryLeeNelson

notyouraveragejoe's icon

If it's from a transformer, then there's a strong chance it's 50Hz, so
filtering about that range might in theory reduce it

On 04/01/2008, Gary Lee Nelson wrote:
>
> I suppose this is related. I have some digital hardware synths coming
> into MSP via an 828 and a mixer. I am getting a lot of machine noise in the
> audio. When I unplug the power transformer from my MacBook it reduces and
> removing the second monitor reduces it further. Any suggestions.
>
> Cheers
> Gary Lee Nelson
> Oberlin College
> www.timara.oberlin.edu/GaryLeeNelson
>
>
>

Gary Lee Nelson's icon

50Hz (60Hz in USA) is hum. My noise is broader band and somehow related to
computer signals (see below). I have all of my audio devices connected to
one power point and all the computer stuff to another. What else?

On 1/4/08 9:51 AM, "Joe Bicker" wrote:

> If it's from a transformer, then there's a strong chance it's 50Hz, so
> filtering about that range might in theory reduce it
>
> On 04/01/2008, Gary Lee Nelson wrote:
>> I suppose this is related. I have some digital hardware synths coming into
>> MSP via an 828 and a mixer. I am getting a lot of machine noise in the
>> audio. When I unplug the power transformer from my MacBook it reduces and
>> removing the second monitor reduces it further. Any suggestions.
>>
>> Cheers
>> Gary Lee Nelson
>> Oberlin College
>> www.timara.oberlin.edu/GaryLeeNelson
>>
>>
>>
>
>
>

Cheers
Gary Lee Nelson
Oberlin College
www.timara.oberlin.edu/GaryLeeNelson

Stefan Tiedje's icon

ben Gilman schrieb:
> i think the inversion of the signal needs to carried out within the
> frequency domain, i want to cancel only selected frequencies from
> within the signal. so im thinking of shifting the phase of individual
> selected bins from a cartpol object. im just a bit lost as to how to
> select and phase shift certain bins. any ideas?

Maybe a multiplication with zero? seems easier...

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

Steven Miller's icon

Are the mixer-to-interface (828) connections balanced? If not, that
might help. If they are, you might need to lift the ground on one end
- either send or receive end, but not both - (disconnect the ground
connection inside the cable/plug) of each of the balanced cables. Are
the audio and/or computing devices plugged in to a power conditioner/
transformer? (Furman, for example, sells a whole line of them). Noise
in audio systems is often a real pain to sort out.

On Jan 4, 2008, at 8:57 AM, Gary Lee Nelson wrote:

> 50Hz (60Hz in USA) is hum. My noise is broader band and somehow
> related to computer signals (see below). I have all of my audio
> devices connected to one power point and all the computer stuff to
> another. What else?

----
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home
SFIFEM
Atrium Sound Space
OVOS
CMP

Owen Green's icon

If it's an analogue connection from mixer to 828, are you using balanced
cables? It could be a cable microphony problem ...

--
Owen

Gary Lee Nelson wrote:
> 50Hz (60Hz in USA) is hum. My noise is broader band and somehow related to
> computer signals (see below). I have all of my audio devices connected to
> one power point and all the computer stuff to another. What else?

jamin's icon

Quote: Stefan Tiedje wrote on Fri, 04 January 2008 15:59
----------------------------------------------------
> ben Gilman schrieb:
> > i think the inversion of the signal needs to carried out within the
> > frequency domain, i want to cancel only selected frequencies from
> > within the signal. so im thinking of shifting the phase of individual
> > selected bins from a cartpol object. im just a bit lost as to how to
> > select and phase shift certain bins. any ideas?
>
> Maybe a multiplication with zero? seems easier...
>
> Stefan
>
> --
> Stefan Tiedje------------x-------
> --_____-----------|--------------
> --(_|_ ----|-----|-----()-------
> -- _|_)----|-----()--------------
> ----------()--------www.ccmix.com
>
>
----------------------------------------------------

im basically trying to construct a noise canceling simulation. i want control over the frequencies that are cancelled within the residual signal. i started out by splitting an input signal and sending both signal through an pfft. one of the signals was inverted and the amplitudes of the bins were passed into a buffer. here multi-sliders were used as control over which amplitude bins were zeroed. the signal was then passed out the buffer and back to the main patcher along with the unchanged signal. back in main patcher the two signals were added together and output. this worked very well but then i came to the realization that this is no real representation. both the split signals were undergoing the same delay as they were both being passed into the pfft. at present im trying to make it function without passing the unchanged signal into the pfft. this would obviously mean there would be some latency when the two signals are added together back in the main patcher. because im passing periodic signals into the system i thought i could shift the phase of the signal passed into the pfft to allow for the latency. but it seems that a shift in phase in the pfft will only have the affects of canceling certain frequencies within the residual signal. almost like there is different latencies on different bins. the patcher below shows the affects.

main patcher -

Max Patch
Copy patch and select New From Clipboard in Max.

pfft - patcher (save as freq1)

Max Patch
Copy patch and select New From Clipboard in Max.

shifting the phase in the pfft subpatcher shows the amplitude of different frequencies in the main going both up and down. im not sure what to do i need control over the latency somehow.

pvillez@gmail.com's icon

You say noise. Do you mean noise as hum or wide band noise, like hiss or
tranny thermal noise?. Monitor as in screen or speakers?

CRT's where notorious for interference ( as a guitarist it was a real nag!
single coils.) Which synths are plugged in? Maybe we can narrow it down a
bit further and nail it.

On 04/01/2008, Joe Bicker wrote:
>
> If it's from a transformer, then there's a strong chance it's 50Hz, so
> filtering about that range might in theory reduce it
>
> On 04/01/2008, Gary Lee Nelson wrote:
>
> > I suppose this is related. I have some digital hardware synths coming
> > into MSP via an 828 and a mixer. I am getting a lot of machine noise in the
> > audio. When I unplug the power transformer from my MacBook it reduces and
> > removing the second monitor reduces it further. Any suggestions.
> >
> > Cheers
> > Gary Lee Nelson
> > Oberlin College
> > www.timara.oberlin.edu/GaryLeeNelson
> >
> >
> >
>
>
>

Gary Lee Nelson's icon
Steven Miller's icon

Can't you simply calculate the latency of the fft'd signal, and delay
the direct signal to match before adding them together? It seems like
it should work.

On Jan 4, 2008, at 5:56 PM, ben Gilman wrote:

>
> im basically trying to construct a noise canceling simulation. i
> want control over the frequencies that are cancelled within the
> residual signal. i started out by splitting an input signal and
> sending both signal through an pfft. one of the signals was
> inverted and the amplitudes of the bins were passed into a buffer.
> here multi-sliders were used as control over which amplitude bins
> were zeroed. the signal was then passed out the buffer and back to
> the main patcher along with the unchanged signal. back in main
> patcher the two signals were added together and output. this worked
> very well but then i came to the realization that this is no real
> representation. both the split signals were undergoing the same
> delay as they were both being passed into the pfft. at present im
> trying to make it function without passing the unchanged signal
> into the pfft. this would obviously mean there would be some
> latency when the two signals are added together back in the main
> patcher. because im!
>
> passing periodic signals into the system i thought i could shift
> the phase of the signal passed into the pfft to allow for the
> latency. but it seems that a shift in phase in the pfft will only
> have the affects of canceling certain frequencies within the
> residual signal. almost like there is different latencies on
> different bins. the patcher below shows the affects.
>
>

----
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home
SFIFEM
Atrium Sound Space
OVOS
CMP

jamin's icon

yes that would work but it needs to be applied to real world sounds, eventually the input to the system will be a microphone and the system will be functioning on periodic sounds within a real world environment. essentially what your suggesting is very similar to what i did originally, apart from i added a delay by passing the direct signal through pfft to incur the delay.

jamin's icon

Quote: smill wrote on Fri, 04 January 2008 19:04
----------------------------------------------------
> Can't you simply calculate the latency of the fft'd signal, and delay
> the direct signal to match before adding them together? It seems like
> it should work.
>
> On Jan 4, 2008, at 5:56 PM, ben Gilman wrote:
>
> >
> > im basically trying to construct a noise canceling simulation. i
> > want control over the frequencies that are cancelled within the
> > residual signal. i started out by splitting an input signal and
> > sending both signal through an pfft. one of the signals was
> > inverted and the amplitudes of the bins were passed into a buffer.
> > here multi-sliders were used as control over which amplitude bins
> > were zeroed. the signal was then passed out the buffer and back to
> > the main patcher along with the unchanged signal. back in main
> > patcher the two signals were added together and output. this worked
> > very well but then i came to the realization that this is no real
> > representation. both the split signals were undergoing the same
> > delay as they were both being passed into the pfft. at present im
> > trying to make it function without passing the unchanged signal
> > into the pfft. this would obviously mean there would be some
> > latency when the two signals are added together back in the main
> > patcher. because im!
> >
> > passing periodic signals into the system i thought i could shift
> > the phase of the signal passed into the pfft to allow for the
> > latency. but it seems that a shift in phase in the pfft will only
> > have the affects of canceling certain frequencies within the
> > residual signal. almost like there is different latencies on
> > different bins. the patcher below shows the affects.
> >
> >
>
> ----
> Steven M. Miller
> Professor, Contemporary Music Program
> College of Santa Fe
>
> Home
> SFIFEM
> Atrium Sound Space
> OVOS
> CMP
>
>
>
----------------------------------------------------

i've just tried what you suggested and it still has the same affect. not sure what is going on or what can be done to resolve it. has no one else experienced this problem.

Stefan Tiedje's icon

ben Gilman schrieb:
> the patcher below shows the affects.

This will never work, if you add a constant to the phase information of
a bin, it will just change the frequency of that bin if you
resynthesize. Still the easiest way to get rid of a bin is to set it to
zero, thats what all denoiser plugs do.
The methods the noisecanceling headphones are using isn't a fft method
and only works for very low noise, its just inverting a (filtered) signal...

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

Peter Reid's icon

[not too off topic I don't think]

I am interested in the kind of noise cancellation used in telephony to avoid echoes. (Skype/mobile handsets etc)

Does anyone give any insight into this technique? Does it have a name, is it described in any book? Has anyone worked on a max msp implementation?

thanks in advance,
Peter

keith@beamfoundation.'s icon

What you are looking for is called Acoustic Echo Cancellation and is a closely guarded dark art practiced by DSP companies and makers of conference phones.

Performance is highly dependent on room reflections, distortion in both speaker and microphone and varying line delay times. It also needs to be adaptive as people - objects - conditions change and move about the room.

This is not for the faint of heart. We spent 18 months developing a usable algorithm that ultimately ran on a SHARC. Many company sell code for this which can be modified. I have never seen a complete Max/MSP implementation, altho I started using MSP for basic experiments before we moved to Matlab and Simulink.

This is why most internet phone systems work best with a headset - to keep the incoming audio from getting to the outgoing audio.

KMc

Peter Reid wrote:
[not too off topic I don't think]

I am interested in the kind of noise cancellation used in telephony to avoid echoes. (Skype/mobile handsets etc)

Does anyone give any insight into this technique? Does it have a name, is it described in any book? Has anyone worked on a max msp implementation?

thanks in advance,
Peter
--
http://www.peterreid.org/code/

Keith McMillen
BEAM Foundation
http://www.beamfoundation.org/
510.502.5310

quoob's icon

Can I reopen this topic even after so many years???
So KMc, here...

What you are looking for is called Acoustic Echo Cancellation and is a closely guarded dark art practiced by DSP companies and makers of conference phones....This is not for the faint of heart. We spent 18 months developing a usable algorithm that ultimately ran on a SHARC. Many company sell code for this which can be modified. I have never seen a complete Max/MSP implementation, altho I started using MSP for basic experiments before we moved to Matlab and Simulink.

...you are saying that there is no way to reproduce something like it in Max? Not even a basic version of it?

In my project I am also attempting to subtract the music signal from a mp3 player (for example) "minus" the sound signal picked up by a mic in the room, which will be made of music reproduced by the speakers and ambient/crowd noise. Exactly what an Automatic Gain & Equalization Control does on modern headsets...

So what I want to achieve is a realistic estimation of the ambient/crowd noise loudness.
Is this anyway possible in Max?

Any ideas and help anyone?

Thanks