Topic: Audio Summing Algorithm (Read 1770 times)
0 Members and 1 Guest are viewing this topic.

## Re: Audio Summing Algorithm

##### Reply #25 – 2018-04-23 18:41:52
If I get up the energy to play with this stuff, I can probably put together a rough 'FFT' based summer (that is, not an FFT, but power based) to see what forcing the phases to match would sound like.  I suspect the results would at least be grainy sounding (like some of the ABBA recordings due to the abuse of the quadrature/destroying the analytical nature of the signal), but more than likely renders the sound unintelligible.

Actually, I have done something similar before -- by zeroing the phase of a given FFT (magnitudes the same, phase is zeroed -- all the same), and the result was pretty much unintelligble-- it was possible to detect some of the material, but didn't seem to be useful.
Can you send us some samples, please? And why does it happen?
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #26 – 2018-04-23 18:48:25
The comment about a true FFT being a linear transform is true -- add an FFT (each) of two signals and the result will be the same as an FFT of the sum of the actual time domain originals.

WHAAAAAT?
Let's assume we have a signal and an inverse of it. If we FFT both, we get same freqs and amps, but another phases (which doesn't matter while listening). However if we sum anticorrelated signals, we get NOTHING. LITERALLY NOTHING. FFT OF NOTHING IS NOTHING.
How can be average of FFTs of something be equal to FFT of nothing?
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #27 – 2018-04-23 18:56:09
The comment about a true FFT being a linear transform is true -- add an FFT (each) of two signals and the result will be the same as an FFT of the sum of the actual time domain originals.

WHAAAAAT?
Let's assume we have a signal and an inverse of it. If we FFT both, we get same freqs and amps, but another phases (which doesn't matter while listening). However if we sum anticorrelated signals, we get NOTHING. LITERALLY NOTHING. FFT OF NOTHING IS NOTHING.
How can be average of FFTs of something be equal to FFT of nothing?
Very easy. If you do it by the definition, that is, not ignoring phase information.
Similar to how an average of 2 numbers may be zero.
Keep calm and opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #28 – 2018-04-23 19:02:02
The comment about a true FFT being a linear transform is true -- add an FFT (each) of two signals and the result will be the same as an FFT of the sum of the actual time domain originals.

WHAAAAAT?

https://en.wikipedia.org/wiki/Fourier_transform#Basic_properties

How can be average of FFTs of something be equal to FFT of nothing?

The sum of the FFTs of two waveforms that sum to zero also sums to zero.  That is what linearity means.

## Re: Audio Summing Algorithm

##### Reply #29 – 2018-04-23 19:06:21
OK... but how does it happen?
FFT of zero: FREQ 0, AMPL 0, PHASE 0.
Average of FFTs: FREQ freq, AMPL ampl, PHASE (phase1 + phase2) / 2
...is that right?
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #30 – 2018-04-23 19:17:13
OK... but how does it happen?

If two signals are 180 degrees out of  phase, then each element is the negative of the other.  If you sum (X + -X) you get zero.

FFT of zero: FREQ 0, AMPL 0, PHASE 0.

The FFT only returns 1 complex number per input representing the amplitude and phase.

Average of FFTs: FREQ freq, AMPL ampl, PHASE (phase1 + phase2) / 2

Addition and subtraction of complex values works differently than you are assuming:

## Re: Audio Summing Algorithm

##### Reply #31 – 2018-04-23 19:32:56
So if I FFT'd both channels of the signal, averaged coefficients and IFFT'd them, would it do the same as simply averaging both signals?
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #32 – 2018-04-23 19:40:55
If you do it correctly and if we ignore loss of precision (fixed size floating point is still fixed size floating point), then yes, it would do the same.
Keep calm and opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #33 – 2018-04-23 19:48:25
So if I FFT'd both channels of the signal, averaged coefficients and IFFT'd them, would it do the same as simply averaging both signals?

Yes, that is exactly what I was saying above.

## Re: Audio Summing Algorithm

##### Reply #34 – 2018-04-23 21:01:22
If I get up the energy to play with this stuff, I can probably put together a rough 'FFT' based summer (that is, not an FFT, but power based) to see what forcing the phases to match would sound like.  I suspect the results would at least be grainy sounding (like some of the ABBA recordings due to the abuse of the quadrature/destroying the analytical nature of the signal), but more than likely renders the sound unintelligible.

Actually, I have done something similar before -- by zeroing the phase of a given FFT (magnitudes the same, phase is zeroed -- all the same), and the result was pretty much unintelligble-- it was possible to detect some of the material, but didn't seem to be useful.
Can you send us some samples, please? And why does it happen?
I have massive archives from when I played with that stuff (about 2013 or so), and will look for something to demo to you.   Like I wrote earlier, there was little benefit even with the compressor/expander thing to work in the Fourier domain (more trouble than it was worth, even though I wanted to work in multiple bands -- seems like the transform would give you lots of bands and seems like that would be good -- but it wasn't all that helpful.)  I could definitely compress the hell out of the signal, but I didn't like the sound of a 512 band compressor. :-).   It seems like 6-8bands is into the diminishing returns, and it seems helpful to try to keep the 500-2500Hz range in one band by itself -- various reasons for that.

John

## Re: Audio Summing Algorithm

##### Reply #35 – 2018-04-24 00:59:32
I believe @ziemek.z misunderstanding of FFT (i.e. the fact that FFT returns a complex function from a real variable) comes from how audio editors often display FFTs. Many - including Audacity - display it as a sequence of buckets, where frequencies of each bucket are painted in a voiceprint. The tools often quitely ignore the Imaginary part of the resulting function, and simply paint the magnitude of the complex value, and ignore the argument, which in that case is phase.

## Re: Audio Summing Algorithm

##### Reply #36 – 2018-04-24 01:18:20
I believe @ziemek.z misunderstanding of FFT (i.e. the fact that FFT returns a complex function from a real variable) comes from how audio editors often display FFTs. Many - including Audacity - display it as a sequence of buckets, where frequencies of each bucket are painted in a voiceprint. The tools often quitely ignore the Imaginary part of the resulting function, and simply paint the magnitude of the complex value, and ignore the argument, which in that case is phase.
Okay -- that makes sense.  From what I know (and from my previous practical experience), the phase is all important.  When I wrote my prototype compressor/expander, the math operations were done on complex numbers.  Using magnitudes only was just a waste of time and just produced garbage.

In my recent work on compressors, expanders, Aphex Exciter removers, DolbyA decoders, etc -- when trying to clean up the sound of some old recordings -- I found that they were sometimes screwing with the phase in bad ways and summing/subtracting phase shifted versions of the signal to/from itself -- the results might have given an effect of making middle freqs more intense (in the case of the parameters used in certain devices), but with the super high quality equipment of today -- the ugliness becomes more apparent.  At least, they weren't zeroing the phase, but even playing with the quadrature (the stuff 90deg out of phase) should not be done lightly.   Even though I didn't like the results -- they weren't going to crazy with the phase -- it is just that phase can mess things up simiilarly to messed up freq response.  Doing some phase things (fancy for the time that 4ch matrix was common) is part of how matrix quad could work reasonably well.   IMO, f possible, unless done absolutely carefully -- not a good idea to play with the phase of any aspect of the signal.  There are right ways/good reasons for doing it -- but if questions need to be asked on forums like this, then it is a good idea to avoid doing it for now :-).

John

## Re: Audio Summing Algorithm

##### Reply #37 – 2018-04-24 06:06:21
I believe @ziemek.z misunderstanding of FFT (i.e. the fact that FFT returns a complex function from a real variable) comes from how audio editors often display FFTs. Many - including Audacity - display it as a sequence of buckets, where frequencies of each bucket are painted in a voiceprint. The tools often quitely ignore the Imaginary part of the resulting function, and simply paint the magnitude of the complex value, and ignore the argument, which in that case is phase.
Okay -- that makes sense.  From what I know (and from my previous practical experience), the phase is all important.  When I wrote my prototype compressor/expander, the math operations were done on complex numbers.  Using magnitudes only was just a waste of time and just produced garbage.
Depends. If you have a signal that is even (symmetric at center) in your bucket, the Imaginary part of your FFT of that signal is zero. The magnitude is then only the Real part.
In cases where a voiceprint is displayed (I'm not sure "voiceprint" is the correct term, I've seen it a bunch of times, though), it seems it's /just/ being used for display purposes, mixing anything even when using that display option, doesn't mean the actual FFT of that signal is used, and it seems indeed it almost never (in my experience) is.

If your sample bucket is small enough such that it is manageable, you can move all samples beyond the center, map them into the negative part by duplicating them symmetrically, and then run the FFT on that. The Imaginary part of the signal in that bucket will be zero (or equal to the zero function rather). Using this for anything but display purposes isn't really sensical, though.

## Re: Audio Summing Algorithm

##### Reply #38 – 2018-04-24 06:19:14
Thank you for clarifying done very important things before I even started. You saved me from doing useless stuff and completely wasting my time! I think I should learn more about FFT and DSP in general...
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

## Re: Audio Summing Algorithm

##### Reply #39 – 2018-04-24 06:23:58
I believe @ziemek.z misunderstanding of FFT (i.e. the fact that FFT returns a complex function from a real variable) comes from how audio editors often display FFTs. Many - including Audacity - display it as a sequence of buckets, where frequencies of each bucket are painted in a voiceprint. The tools often quitely ignore the Imaginary part of the resulting function, and simply paint the magnitude of the complex value, and ignore the argument, which in that case is phase.
Okay -- that makes sense.  From what I know (and from my previous practical experience), the phase is all important.  When I wrote my prototype compressor/expander, the math operations were done on complex numbers.  Using magnitudes only was just a waste of time and just produced garbage.
Depends. If you have a signal that is even (symmetric at center) in your bucket, the Imaginary part of your FFT of that signal is zero. The magnitude is then only the Real part.
In cases where a voiceprint is displayed (I'm not sure "voiceprint" is the correct term, I've seen it a bunch of times, though), it seems it's /just/ being used for display purposes, mixing anything even when using that display option, doesn't mean the actual FFT of that signal is used, and it seems indeed it almost never (in my experience) is.

If your sample bucket is small enough such that it is manageable, you can move all samples beyond the center, map them into the negative part by duplicating them symmetrically, and then run the FFT on that. The Imaginary part of the signal in that bucket will be zero (or equal to the zero function rather). Using this for anything but display purposes isn't really sensical, though.
Okay -- sorry that I wasn't clear -- not properly handling the phase produced garbage *AUDIO*.  I wasn't really looking at using the FFT for any numerical purpose at that time.  So with audio, I didn't really have much of an opportunity to massage the signal as much as you suggested.

I will tell you one thing though -- I think that my next venture into the time/frequency type transforms will be more likely a complex MDCT instead.  I know that you don't get magic for free -- but when people have had the patience to be a trailblazer using the complex MDCT, they have sometimes gotten good results.   I know that the normal (or a variation) MDCT is often used in audio compression, but the complex MDCT supports more flexibility for signal processing purposes.
The FFT domain is 'old hat' nowadays -- I was drawing FFT and even DCT type butterfly diagrams for undergraduate papers in EE in 1979.  I truly don't remember everything, but over the last year or so I have been reading some of the books that I collected over the years on the subject of DCTs, Lapped transforms, etc (the black DCT book, Malvar's book, and every document that I can find online.)   There aren't a lot of papers on the complex MDCT, but it does seem very interesting.
So much of the really cool stuff requires some concentration and a long startup time (a few weeks), but I am having so much fun with my easy stuff (DolbyA, REALLY GOOD expander/NR project, and a pretty good compressor package.)
I truly hope that I get a chance to work on some new technolgy (for me) before I mentally slow down -- I know that I have at least 1-2 more years to do on the mostly time domain compressor/expander/NR projects, so hope that health holds up!!!

John

## Re: Audio Summing Algorithm

##### Reply #40 – 2018-05-13 00:39:21
Very interesting discussion spawned by a spambot.

(It was a verbatim repost of this 2010 mailing list post, thanks reporter who may choose to name themself in a reply.)

SimplePortal 1.0.0 RC1 © 2008-2019