DSPRelated.com
Forums

Magnitudes drop when adding more

Started by overgaard January 29, 2006
Jon Harris wrote:
> "overgaard" <jorgen@antistaten.se> wrote in message > news:ONadnSU0c_eoIkLeRVn-sw@giganews.com... >>> "Rune Allnor" <allnor@tele.ntnu.no> wrote in message >>> news:1138567435.150149.246960@o13g2000cwo.googlegroups.com... >>> There's nothing mysterious about the wave (.wav) format, at least not >> with the >>> most common linear PCM version. It simply stores the digitized signal as >> a >>> series of (usually 16-bit) samples. Now if someone is doing additional >>> normalization or AGC on the signal, it could have a similar effect. But >> that is >>> totally separate from the wave format itself. >>> >>> The issue is most likely with your software that generates the tones. >> Perhaps >>> when you generate multiple tones, the software automatically scales all >> the >>> tones to avoid clipping? It is certainly true that you can't take a >> full-scale >>> sine wave and add another full-scale sine wave with a different frequency >>> without clipping the signal. I'm not sure what games Audacity plays when >> it >>> displays its spectrum. >>> >>> >> Hi Jon, >> >> Doh, you hit the nail mate! :) >> How stupid was I? Of course I can't add two >> or more sines att full-scale with different frequency without clipping. >> Looking at my source code I found that I scaled the mixed result in an >> averaging way. I mean 1+1+1 can't be 1. *LOL* >> >> My code looked something like this (just an example) >> >> for (int i = 0; i < length; i++) { >> samples[i] = 1.0 * sin(2 * M_PI * i * frequency / samplerate) + >> sin(2 * M_PI * i * frequency / samplerate) / 2 >> } >> >> I hade to devide by 2 for two sines and devide by 3 for three sines to >> avoid clipping (not go above 1.0). I guess this is what caused my dropped >> magnitudes. >> I was too hooked on it was something in the FFT I guess. :) >> Thanks for the help! >> Best regards // J&#4294967295;rgen > > Glad you figured it out. Sometimes the simplest things are the most overlooked. > If you want, you could remove the scaling based on number if frequencies and > instead do a arbitrary scaling by say 1/10. Then you could add up to 10 sine > waves without clipping and verify that the FFT magnitude doesn't change when > adding more frequencies. >
The WAV format has been updated to include floating point format, which would handle the scaling problems. You would have to check your specific tools to see if they handle this format correctly. Cheers, David