Building up Reference for Target
The reference function is to analyze which parts of the reference signal should be fetched out, or to be imitated by my target signal, and all the information of specific segments of the reference signal would be stored and averaged into a segment signal in 4496 length, which is easily applied in FFT and would be acted as a FIR filter for modulate the target signal.
The code decomposes the reference signal to mid and side channel respectively, picks up the specific segments depending on whether their RMS bigger than average RMS of the whole signal, and builds up the corresponding spectrum for reference mid and side in 4496 length.