private static void CreateEqualizerJson(string equalizerFilename) { var eqParams = new EqualizerParams(); eqParams.LeftChannel.Add(new EqualizerBand { Bandwidth = 1.0f, Frequency = 1000f, Gain = 6f }); eqParams.LeftChannel.Add(new EqualizerBand { Bandwidth = 1.0f, Frequency = 10000f, Gain = 6f }); eqParams.RightChannel.Add(new EqualizerBand { Bandwidth = 1.0f, Frequency = 100f, Gain = 6f }); eqParams.RightChannel.Add(new EqualizerBand { Bandwidth = 1.0f, Frequency = 6000f, Gain = 6f }); string jsonString = JsonConvert.SerializeObject(eqParams); File.WriteAllText(Path.Combine(Environment.CurrentDirectory, equalizerFilename), jsonString); }
private static void CalcAdjustVolumeFromEq(EqualizerParams eqParams) { if (eqParams == null) { return; } float maxEqGain = 0; foreach (EqualizerBand eb in eqParams.LeftChannel) { if (eb.Gain > 0) { maxEqGain = Math.Max(eb.Gain, maxEqGain); } } foreach (EqualizerBand eb in eqParams.RightChannel) { if (eb.Gain > 0) { maxEqGain = Math.Max(eb.Gain, maxEqGain); } } volumeAdjustDB = -maxEqGain; }
private static void ReadEqParams(string equalizerFilename) { if (File.Exists(Path.Combine(Environment.CurrentDirectory, equalizerFilename))) { try { string jsonString = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, equalizerFilename)); eqParams = JsonConvert.DeserializeObject <EqualizerParams>(jsonString); Console.WriteLine("Equalizer params loaded."); } catch (Exception ex) { Console.WriteLine("Can not load equalizer params. " + ex.Message); eqParams = null; } } else { Console.WriteLine("Can not find equalizer params file."); } }
public Equalizer(ISampleProvider sourceProvider, EqualizerParams eqParams) : this(sourceProvider, eqParams.LeftChannel.ToArray(), eqParams.RightChannel.ToArray()) { }