public static FilterProfile DifferentialSPL(double phon0, double phon1, double scale) { FilterProfile spl = new FilterProfile(); FilterProfile spl0 = Loudness.SPL(phon0); FilterProfile spl1 = Loudness.SPL(phon1); for (int j = 0; j < spl1.Count; j++) { FreqGain fg = spl1[j]; fg.Gain = scale * (spl0[j].Gain - fg.Gain); spl.Add(fg); } return(spl); }
/// <summary> /// Create a list of dB SPL equal-loudness values for a given 'phon' loudness /// (from zero, threshold, to 90) /// </summary> /// <param name="phon"></param> /// <returns>list of {frequency Hz, dB SPL}</returns> public static FilterProfile SPL(double phon) { FilterProfile lfg = new FilterProfile(); if ((phon < 0) | (phon > 120)) { throw new ArgumentException("Phon value out of bounds!"); } // Setup user-defined values for equation double Ln = phon; for (int j = 0; j < f.Length; j++) { // Deriving sound pressure level from loudness level (iso226 sect 4.1) double Af = 4.47E-3 * Math.Pow(10, (0.025 * Ln) - 1.15) + Math.Pow(0.4 * Math.Pow(10, (((Tf[j] + Lu[j]) / 10) - 9)), af[j]); double Lp = ((10 / af[j]) * Math.Log10(Af)) - Lu[j] + 94; // Return user data FreqGain fg = new FreqGain(f[j], Lp); lfg.Add(fg); } return(lfg); }