PV_DiffMags Spectral difference of magnitudes


chain = PV_DiffMags(chain1, chain2)


Finds the magnitude difference (in each frequency bin) between two signals, and stores those (absolute) magnitude differences to the magnitude bins of the first signal. In other words, the output consists of an FFT chain with the phases of chain1, and magnitudes corresponding to the absolute difference of chain1 and chain2.


Compare this against [FFTDiffMags] which is very similar but sums the differences to form a single control-rate output.


Example


s.boot;

b = Buffer.alloc(s, 1024);

c = Buffer.alloc(s, 1024);


(

x = {

var sig1, sig2, chain1, chain2, chainOut, out;


sig1 = Saw.ar(440);

sig2 = Saw.ar(660);

chain1 = FFT(b.bufnum, sig1);

chain2 = FFT(c.bufnum, sig2);

chainOut = PV_DiffMags(chain1, chain2);


out = IFFT(chainOut);


// You hear a sequence: sig1 for 1 sec, sig2 for 1 sec, 

//  then the difference for 2 secs.

(Select.ar(LFSaw.kr(0.25).range(0, 4), [sig1, sig2, out, out]) * 0.1).dup


}.play;

)

x.free;

b.free; c.free;