private void ProcessAction(DriverCore driver, double FcLP, double FcHP, Color color, string splText, string phaseText) { double splAtFcLP; double phaseAtFcLP; double splAtFcHP; double phaseAtFcHP; double factoredFcLP; double factoredFcHP; Filters.Calculate(driver, FrequencyRange.dynamicFreqs , FcLP, out splAtFcLP, out phaseAtFcLP , FcHP, out splAtFcHP, out phaseAtFcHP , out factoredFcLP, out factoredFcHP , hpIsInverted, offsetMm, lpIsOffset, hpIsOffset); Curves.AddTargetComplexCurves(systemGraph, driver , color, splText, splText, phaseText , FcLP, splAtFcLP, phaseAtFcLP , FcHP, splAtFcHP, phaseAtFcHP); if (driver.target.section == FilterCore.Section.LP) { UpdateFactorLP(factoredFcLP); besselFcPhaseLP.Text = phaseAtFcLP.ToString("F0"); FilterSPL.Instance.lowpass = driver.splInterpolated; // For graph export option } if (driver.target.section == FilterCore.Section.HP) { UpdateFactorHP(factoredFcHP); besselFcPhaseHP.Text = phaseAtFcHP.ToString("F0"); FilterSPL.Instance.highpass = driver.splInterpolated; // For graph export option } Action.Update.SystemResponse(systemGraph, drivers, phaseToggleSum); }
/// <summary> /// Used only to initialize at startup /// </summary> private void CalculateAll() { double FcLP = 1000; double FcHP = 1000; double splAtFcLP = 1; double phaseAtFcLP = 0; double splAtFcHP = 1; double phaseAtFcHP = 0; double factoredFcLP; double factoredFcHP; double[,] groupDelay; double max; // Lowpass section if (IsFilterConsistentWithOrder(trgtOrderLP, trgtTypeLP)) { FcLP = Convert.ToDouble(trgtFreqLP.Value); Filters.Calculate(drivers.woofer1, FrequencyRange.dynamicFreqs , FcLP, out splAtFcLP, out phaseAtFcLP , FcHP, out splAtFcHP, out phaseAtFcHP , out factoredFcLP, out factoredFcHP); FilterSPL.Instance.lowpass = drivers.woofer1.target.splInterpolated; Curves.AddTargetComplexCurves(systemGraph, drivers.woofer1 , Color.Blue, "LowpassSPL", "LowpassSPL", "LowpassPhase" , FcLP, splAtFcLP, phaseAtFcLP , FcHP, splAtFcHP, phaseAtFcHP); besselFcPhaseLP.Text = phaseAtFcLP.ToString(); UpdateFactorLP(FcLP); // Lowpass delay groupDelay = GroupDelay.Calculate(drivers.woofer1.target.splInterpolated, out max); Curves.AddGroupDelayCurves(systemGraph, groupDelay, Color.Violet, "LowpassDelay", "LowpassDelay", curveIsVisible: true, yMax: max); } // Highpass section if (IsFilterConsistentWithOrder(trgtOrderHP, trgtTypeHP)) { FcHP = Convert.ToDouble(trgtFreqHP.Value); Filters.Calculate(drivers.tweeter, FrequencyRange.dynamicFreqs , FcLP, out splAtFcLP, out phaseAtFcLP , FcHP, out splAtFcHP, out phaseAtFcHP , out factoredFcLP, out factoredFcHP , hpIsInverted); //FilterSPL.Instance.lowpass = drivers.tweeter.target.splInterpolated; FilterSPL.Instance.highpass = drivers.tweeter.target.splInterpolated; Curves.AddTargetComplexCurves(systemGraph, drivers.tweeter , Color.Red, "HighpassSPL", "HighpassSPL", "HighpassPhase" , FcLP, splAtFcLP, phaseAtFcLP , FcHP, splAtFcHP, phaseAtFcHP); besselFcPhaseHP.Text = phaseAtFcHP.ToString(); UpdateFactorHP(FcHP); // Highpass delay groupDelay = GroupDelay.Calculate(drivers.tweeter.target.splInterpolated, out max); Curves.AddGroupDelayCurves(systemGraph, groupDelay, Color.Orange, "HighpassDelay", "HighpassDelay", curveIsVisible: true, yMax: max); } // System sum section double[,] sum = (new FilterCore().SumResponses(drivers.woofer1.target.splInterpolated, drivers.tweeter.target.splInterpolated)); Curves.AddSummedComplexCurves(systemGraph, sum , Color.Black, "SummedSPL", "SummedSPL", "SummedPhase" , FcLP, splAtFcLP, phaseAtFcLP , FcHP, splAtFcHP, phaseAtFcHP); // System delay groupDelay = GroupDelay.Calculate(sum, out max); Curves.AddGroupDelayCurves(systemGraph, groupDelay, Color.Green, "SystemDelay", "SystemDelay", curveIsVisible: true, yMax: max); FilterSPL.Instance.lowpass = drivers.woofer1.target.splInterpolated; FilterSPL.Instance.highpass = drivers.tweeter.target.splInterpolated; }