Forums > MaxMSP

FFT help…..

December 22, 2006 | 4:25 am

So….I’m sort of a newbie…I’ve done several of the tutorials, built some instruments, and have a general understanding of the flow in Max and MSP.

Basically, I want to take two audio sources (initially can be buffers, but would be more practical to eventually use two audio inputs), and compare the frequency spectrums. For all frequencies that are common, I’d like to be able to decrease the amplitude for these frequencies in one file… the idea being that a realtime frequency "hole" could be carved in the secondary file to minimize frequency masking of the primary file. I’d like to be able to set a threshold and ratio for the compression of the secondary file so the effect can be subtle to extreme.

Since I’m trying to learn the program, I’m not looking for specific code, rather some advice in the right direction as to what objects I might need to use and/or study. I’m assuming I’ll be using the fft objects and I’ve read the tutorials on that subject, which gave me a little direction, but not enough. What object(s) can I use to compare each bin and manipulate the amplitude info within these bins? Sorry if this would be explained by some other tutorials, but since this is a school project, I don’t have time to go through ALL the tutorials before it’s due. Any help would be appreciated. thanks!


December 22, 2006 | 3:42 pm

no responses? Does this mean that what I want to do is impossible???


December 22, 2006 | 4:58 pm

This sounds to me, if I understand what you’re after, essentially
like convolution, but instead of adding the two spectra you want to
subtract one from the other. Since convolution multiplies the two
spectra within the fft, it makes sense to me that dividing one from
the other would give you the result you are looking for. You’d need
to designate one as the ‘audio’ signal and the other as the ‘filter’
signal. In order to vary the amount of subtraction you could scale
the filter signal before dividing it from the audio signal.

I’m sure someone who’s actually done this will have better
suggestions…

On Dec 21, 2006, at 9:25 PM, scott wrote:

>
> Basically, I want to take two audio sources (initially can be
> buffers, but would be more practical to eventually use two audio
> inputs), and compare the frequency spectrums. For all frequencies
> that are common, I’d like to be able to decrease the amplitude for
> these frequencies in one file… the idea being that a realtime
> frequency "hole" could be carved in the secondary file to minimize
> frequency masking of the primary file. I’d like to be able to set
> a threshold and ratio for the compression of the secondary file so
> the effect can be subtle to extreme.
>

—-
Steven M. Miller

Associate Professor of Contemporary Music
College of Santa Fe
Contemporary Music Program
1600 St. Michaels Drive
Santa Fe NM 87505
http://pubweb.csf.edu/~smill
(505) 473-6197

~~~~~~~~~~~~~~~~~~~~~
SFIFEM
Atrium Sound Space
OVOS
*opportunities for composers & sound artists*


December 22, 2006 | 6:44 pm

Thanks for the suggestions. After reading the FFT tutorials I had similar thoughts. A few questions though…and I apologize if they are obvious…

How do I designate one to be a filter? Also, by scaling the filter signal, are you just talking about a simple *~ object to scale the amplitude??

I know this project is a bit beyond my current skill level, but I’ve had the idea for a while and since I’m learning max I wanted to give it a shot.


December 22, 2006 | 7:32 pm

By ‘designate’ I simply meant to be clear about which one is being
subtracted from which (or in the fft division, which is the numerator
and which is the denominator). In subtraction, the audio signal would
have the filter subtracted from it, so in the division case, the
audio signal would be the numerator (the one being divided) and the
filter would be the denominator (the one doing the dividing, so to
speak), I believe.

For scaling the amplitude, yes, the simple *~ would work fine, unless
you wanted something a bit more fancy.

On Dec 22, 2006, at 11:44 AM, scott wrote:

>
> Thanks for the suggestions. After reading the FFT tutorials I had
> similar thoughts. A few questions though…and I apologize if they
> are obvious…
>
> How do I designate one to be a filter? Also, by scaling the filter
> signal, are you just talking about a simple *~ object to scale the
> amplitude??
>
> I know this project is a bit beyond my current skill level, but
> I’ve had the idea for a while and since I’m learning max I wanted
> to give it a shot.

—-
Steven M. Miller

Associate Professor of Contemporary Music
College of Santa Fe
Contemporary Music Program
1600 St. Michaels Drive
Santa Fe NM 87505
http://pubweb.csf.edu/~smill
(505) 473-6197

~~~~~~~~~~~~~~~~~~~~~
SFIFEM
Atrium Sound Space
OVOS
*opportunities for composers & sound artists*


December 22, 2006 | 7:59 pm

On Dec 22, 2006, at 10:42 AM, scott wrote:
> no responses? Does this mean that what I want to do is impossible???

I think the lack of response was more due to your disregard for time
spent with the tutorials.
They are hands down the best in the biz. You should also look in the
examples folder.

—–
Nathan Wolek
nw@nathanwolek.com

http://www.nathanwolek.com


December 22, 2006 | 9:14 pm


December 22, 2006 | 9:50 pm

I have absolutely no disregard for the tutorials at all, and I plan on doing every single one of them thoroughly. As I mentioned in my original post, this is a school project with a timeline, so I was simply looking for some advice in the right direction…i.e., which objects to study and/or which tutorials to focus on in my short amount of time…and if my idea is even feasible. My teacher encouraged me to work on it since we only cover Max/MSP for half the term and won’t be getting into FFT objects. I think the tutorials are great, just don’t have enough time for this particular project. Thanks Steven for your input. I think I have enough of an idea to give it a shot.


December 22, 2006 | 10:24 pm

Another thought is to do the convolution normally (multiplying the
spectra) but with the ‘filter’ signal phase reversed (multiplied by
-1) first before doing the fft. This may also have the desired
effect…not sure.

On Dec 22, 2006, at 2:50 PM, scott wrote:

>
> I have absolutely no disregard for the tutorials at all, and I plan
> on doing every single one of them thoroughly. As I mentioned in my
> original post, this is a school project with a timeline, so I was
> simply looking for some advice in the right direction…i.e., which
> objects to study and/or which tutorials to focus on in my short
> amount of time…and if my idea is even feasible. My teacher
> encouraged me to work on it since we only cover Max/MSP for half
> the term and won’t be getting into FFT objects. I think the
> tutorials are great, just don’t have enough time for this
> particular project. Thanks Steven for your input. I think I have
> enough of an idea to give it a shot.

—-
Steven M. Miller

Associate Professor of Contemporary Music
College of Santa Fe
Contemporary Music Program
1600 St. Michaels Drive
Santa Fe NM 87505
http://pubweb.csf.edu/~smill
(505) 473-6197

~~~~~~~~~~~~~~~~~~~~~
SFIFEM
Atrium Sound Space
OVOS
*opportunities for composers & sound artists*


December 22, 2006 | 11:58 pm

Quote: Temporalist wrote on Thu, 21 December 2006 21:25
—————————————————-

> Basically, I want to take two audio sources (initially can be buffers, but would be more practical to eventually use two audio inputs), and compare the frequency spectrums.

If you want to use to audio inputs then set the patch up in that way, and drive the inputs with sfplay~ or something simple, as there shouldn’t be any need to use buffers for this task unless you find it simpler that way.

> I’m assuming I’ll be using the fft objects and I’ve read the tutorials on that subject, which gave me a little direction, but not enough. What object(s) can I use to compare each bin and manipulate the amplitude info within these bins?

I would advise against the use of fft~ and ifft~, as the pfft~ method (using a patcher containing fftin~ and fftout~ objects) is MUCH easier for audio processing applications. There should be a tutorial on it, so look at that.

At this stage you’ll probably be best off using cartopol~ to turn the complex numbers generated by the fft objects into amplitude and phase data. You’ll only need to alter and look at the amplitude data for what you want, and should retain the phase data from the signal which is BEING filtered, not the signal being used as a filter.

For comparison you’ll probably want >~ or < ~ or any of the related comparison signal objects. *~ or /~ will be fine for modifying the data, possibly with other +~ or -~ objects depending on the exact maths you want to do. I'd try to work out the maths that you want to do on the amplitude data before trying to implement it.

And the suggestion of trying convolution with a phase-reversed signal unfortunately will not work, as all you would be doing is inverting the signal (or shifting the phase of one input by 180 degrees / pi if you prefer radians), which will not change the result audibly.

Regards

Alex


December 23, 2006 | 3:17 pm


December 23, 2006 | 4:12 pm

Quote: nathan wolek wrote on Sat, 23 December 2006 08:17
—————————————————-
> c) Most of the encountered values will be between 0. and 1.

Within a pfft~ or after an fft~ object the amplitudes after the fft are scaled by an amount proportional to the fft size (the exact value depends on the window type used and is hard to determine exactly). This is due to the fft routines used within these objects and is usually not an issue, as when doing resynthesis they are scaled back in the inverse fft. In fact pfft I think does half the scaling at either end which is quite inconvienient and also I believe undocumented. This is all a bit technical, but there is a point to it – in practical terms many amplitudes after the fft will be in a range larger than 0 to 1 due to this scaling, unlike with a normal audio signal, where 1 is considered to be clipping, and signals are normally kept within this range. So – the upshot is that:

1 – you should not assume the range of an input to be within 0 and 1 in terms of amplitude

2 – you should be aware that changing the fft size will change the range of amplitudes you are expecting – this may or may not be an issue in any particular case.

Regards

Alex


December 23, 2006 | 5:15 pm

On Dec 23, 2006, at 11:12 AM, Alex Harker wrote:
> 1 – you should not assume the range of an input to be within 0 and
> 1 in terms of amplitude

True, but I did say "most". The idea was to use these quieter bins
to achieve scott’s filtering objective.

—–
Nathan Wolek
nw@nathanwolek.com

http://www.nathanwolek.com


December 23, 2006 | 10:23 pm

Thanks for all the suggestions. Nathan, I’m sorry if I gave you the wrong impression. My "no responses" post was only because I saw there were like 40 views so I was concerned my idea may not be possible…it was not meant to be a "why won’t anyone help me out?" statement. I do appreciate frustration with those not willing to put in the simple work to learn the basics.


Viewing 14 posts - 1 through 14 (of 14 total)