Correlation
-
Hi. I made a stereo expander. Now I need a correlator. How to make it?
-
This is the basic formula for the phase
Phase = arctan(L/R)
So if the phase is 45 or 225 = 1, and phase of 135 and 315 (-45) is -1.
For your correlation meter, you need to normalize this value:
Correlation = Phase * Magnitude
Magnitude = (L^2 + R^2)^1/2
So the final formula is:
Correlation = arctan(L/R) * ((L^2 + R^2)^1/2)
-
@оранжевый
I want to put a correlator in my plugin. How to do this?)
-
@orange
I want to put a correlator in my plugin. How to do this?) -
@udalilprofile
I tried to do it in FAUST, then the value in the UI must be made with a global_cable and draw its value in a panel.import("stdfaust.lib"); //============================================================================== // CORRELATION METER // // A stereo phase correlation meter that outputs a value between -1 and +1 // indicating the phase relationship between left and right channels. // // +1 = fully correlated (mono) // 0 = fully decorrelated (wide stereo) // -1 = fully anti-correlated (out of phase) //============================================================================== // Integration time constant (in seconds) - typical range 10-100ms integration_time = hslider("Integration Time", 0.05, 0.01, 0.2, 0.001); // Small constant to prevent division by zero epsilon = 1e-10; // FAUST has a function for this but I'm lost and would like to close the implementation -.-' // Low-pass filter cutoff frequency based on integration time lpf_freq = 1.0 / (2.0 * ma.PI * integration_time); // Basic correlation meter implementation correlation_meter = _ , _ : correlation_calc with { correlation_calc(l, r) = lr_filtered / (sqrt(l2_filtered * r2_filtered) + epsilon) with { // Cross-correlation term (L * R) lr_filtered = (l * r) : fi.lowpass(1, lpf_freq); // Auto-correlation terms (L² and R²) l2_filtered = (l * l) : fi.lowpass(1, lpf_freq); r2_filtered = (r * r) : fi.lowpass(1, lpf_freq); }; }; // Alternative implementation using sum/difference method correlation_meter_alt = _ , _ : correlation_calc_alt with { correlation_calc_alt(l, r) = (sum_power - diff_power) / (sum_power + diff_power + epsilon) with { sum_sig = (l + r) * 0.5; diff_sig = (l - r) * 0.5; sum_power = (sum_sig * sum_sig) : fi.lowpass(1, lpf_freq); diff_power = (diff_sig * diff_sig) : fi.lowpass(1, lpf_freq); }; }; // Algorithm selector algorithm = nentry("Algorithm", 0, 0, 1, 1); // Main correlation calculation with algorithm selection correlation_calc = _ , _ <: (correlation_meter, correlation_meter_alt) : select2(algorithm); // Correlation meter with UI elements - following the vumeter pattern cmeter(l, r) = attach(l, correlation_calc(l, r) : hbargraph("Correlation", -1, 1)), r; // Process function - stereo input, stereo passthrough with correlation display process = cmeter;
-
Two different correlation calculation:
- Direct method using L*R / sqrt(L² * R²)
- Sum/difference method using (S² - D²) / (S² + D²)
-
Adjustable parameters:
- Integration time (10ms to 200ms)
- Algorithm selection
-
Real-time display:
- Horizontal bargraph showing correlation value
As for the implementation in HISE (UI) you need to connect the hbargraph in a
global_cable
scriptnode and draw the "bar" in a panel - this is more complicated for meSince I'm still a newbie, it would be a good idea to properly test the implementation before putting it "into production"
-