Normalise amplitude to a range for FFT analysis
Hey, wonder if someone could help me tweak a patch to have a reliable way to calibrate FFT amplitude values.
What I'm doing is listening via adc~ and then performing a realtime FFT analysis on the incoming signal. The FFT results are then transmitted over serial to drive motors on an arduino setup. The arduino code assumes it will receive FFT bin amplitude data in the range 0-1 and then maps this to the min-max range for the motors. The reads over adc~ can be quite quiet (compared to a signal synthesised within max) so I tried normalising the signal to a factor of 2 and then clipping the result to get a boosted signal that stays within the desired amplitude range. But, I think I must have misunderstood the function of the clip object, because I sometimes get FFT amplitude reads over 1. Because these are then outside the max range for the motors, the motor doesn't fire at amplitude reads over 1. The ardiuno code is doing a few other things, so I'd prefer not to rewrite that end of the code and find a solution at the max end.
What I'd ideally like to achieve is a way to calibrate the volume of the adc~ signal so that regardless of the input volume I can ensure that the loudest sounds are close to but never exceeding an amplitude of 1 on the FFT analysis.
max patch attached
Best
Jess
Didn't know about the [normalize~] object, but it looks like it's just a [*~] object.
Anyway, what do you want to [clip~]? If you want the values given by the fft to be clipped, then you must put your [clip~] object in your [pfft~].
Better yet, [clip~] right before you give the values to your Arduino.
Note that the maximum values you get as energy in each fft bin are not limited to 1. Check out MSP Analysis Tutorial 4 (pfft~) for more insight. Most of the bin values will turn out to be in a low range [0-1] but some of them can be quite high (actual theoretical value depends on the windowing, actual value will depend on your input signal, of course).
Thanks so much, Yes you are right, the pfft results could be more or less anything ;)
Yes normalise works quite well for boosting quiet signals.
I will try clipping just before / after the fft analysis to see if that makes the difference.
thanks
Jess