public static SpeakerDataModel ParseParametricEq(Speaker speaker) { var ret = new SpeakerDataModel(); if (!speaker.Bandpass.Any() || !speaker.PEQ.Any() || !speaker.PEQ[0].Band.Any() || speaker.PEQ[0].Band.Count() > 9) { throw new FileFormatException("The file has no valid data"); } ret.PEQ = new List <PeqDataModel>(); if (speaker.Bandpass[0].HighPass != null) { ret.PEQ.Add(Create(speaker.Bandpass[0].HighPass[0], true)); } if (speaker.Bandpass[0].LowPass != null) { ret.PEQ.Add(Create(speaker.Bandpass[0].LowPass[0], false)); } foreach (var band in speaker.PEQ[0].Band) { ret.PEQ.Add(Create(band)); } //set id's: for (var i = 0; i < ret.PEQ.Count; i++) { ret.PEQ[i].Id = i; } return(ret); }
public void SpeakerDataViewModelTest() { //todo: incomplete, untested var q = new SpeakerDataModel(); //var t = new SpeakerDataViewModel(); //t.AddNewParam.Execute(null); }
public static string DisplayValue(SpeakerDataModel model, bool isPreset = false) { if (string.IsNullOrWhiteSpace(model.SpeakerName)) { return(string.Empty); } return(model.SpeakerName.Truncate(13)); }
public void SendPresetTest() { //todo:fix this var speakerModel = new SpeakerDataModel { SpeakerPeqType = SpeakerPeqType.BiquadsPreset }; var spdvm = new SpeakerLogic(speakerModel); //var z = spdvm.GetPresetData(0); }
/// <summary> /// Design constructor /// </summary> public SpeakerDataViewModel() { _speakerData = new SpeakerDataModel { PEQ = new List <PeqDataModel>() { new PeqDataModel(), new PeqDataModel() } }; }
//private readonly int _flowId; public SpeakerLogic(SpeakerDataModel model) { Model = model; if (model.PEQ == null) { model.PEQ = new List <PeqDataModel>(); } UpdateIntegraty(); }
public SpeakerDataViewModel(SpeakerDataModel speakerData, int?flowId = null) { _speakerData = speakerData; _flowId = flowId; if (speakerData.PEQ != null) { DbMagnitude = Fourier(speakerData.PEQ).Max(); } PopulateActionField(); }
protected FilterLogicBase(PeqDataModel peqDataModel, SpeakerDataModel model, int flowId) : base(peqDataModel) { _model = model; FlowId = flowId; if (PEQDataModel.Biquads == null) { throw new Exception("No biquads are defined for this filter"); } if (new[] { PEQDataModel }.RequiredBiquads() > PEQDataModel.Biquads.Count) { throw new Exception("Not enough biquads are defined for this filter"); } }
private SpeakerDataModel TestSpeaker() { var speakerdata = new SpeakerDataModel { SpeakerPeqType = SpeakerPeqType.BiquadsPreset, PEQ = new List <PeqDataModel>(), }; speakerdata.PEQ.Add(TestPeqParam(FilterType.ButterworthHp, 2000, 6)); speakerdata.PEQ.Add(TestPeqParam(FilterType.ButterworthLp, 20000, 4)); speakerdata.PEQ.Add(TestPeqParam(FilterType.LinkWitzHp, 100, 4)); speakerdata.PEQ.Add(TestPeqParam(FilterType.Peaking, 1000, 4)); speakerdata.PEQ.Add(TestPeqParam(FilterType.BesselHp, 2000, 4)); return(speakerdata); }
public static SpeakerDataModel ParseParametricEq(ParametricEQ speaker) { var ret = new SpeakerDataModel { PEQ = new List <PeqDataModel>() }; for (var i = 1; ; i++) { var t = Create(speaker.Property.Where(s => EndNumber(s.name, i)) .ToDictionary(k => k.name.Substring(0, k.name.Length - 1).ToLower(), k => k.value)); if (t == null) { break; } ret.PEQ.Add(t); } return(ret); }
public CrossoverLogic(PeqDataModel peqDataModel, SpeakerDataModel model, int flowId) : base(peqDataModel, model, flowId) { }
public SpeakerLogicForFlow(SpeakerDataModel model, int flowId) : base(model) { _flowId = flowId; }
public PeakingLogic(PeqDataModel peqDataModel, SpeakerDataModel model, int flowId) : base(peqDataModel, model, flowId) { }
public static bool Import(SpeakerDataViewModel speaker) { var dlg = new OpenFileDialog { Filter = "Peq files (*.peq)|*.peq|Seq files (*.seq)|*.seq", DefaultExt = "Peq files (*.peq)|*.peq|Seq files (*.seq)|*.seq" }; if (!String.IsNullOrWhiteSpace(Settings.Default.RecentLocationImport)) { dlg.InitialDirectory = Settings.Default.RecentLocationImport; } var q = dlg.ShowDialog(); if (!q.HasValue || !q.Value || String.IsNullOrWhiteSpace(dlg.FileName)) { return(false); } Settings.Default.RecentLocationImport = dlg.FileName; Settings.Default.Save(); SpeakerDataModel sp = null; try { var ext = dlg.FileName.Split('.').Last(); switch (ext) { case "seq": { var t = FileManagement.OpenEqFile <Speaker>(dlg.FileName); sp = ParseParametricEq(t); } break; case "peq": { var t = FileManagement.OpenEqFile <ParametricEQ>(dlg.FileName); sp = ParseParametricEq(t); } break; } } catch (Exception e) { #if !DEBUG MessageBox.Show(e.Message, "Could not open file", MessageBoxButton.OK, MessageBoxImage.Error); #endif return(false); } if (sp == null) { return(false); } MessageBoxResult res; if (speaker.Biquads < 1) { res = MessageBoxResult.OK; } else if (sp.PEQ.RequiredBiquads() + speaker.RequiredBiquads <= (int)speaker.SpeakerPeqType) { res = MessageBox.Show("Would you like to replace the old configuration? (Press no to add to existing)", "Import", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); } else { res = MessageBox.Show("Would you like to replace the old configuration?", "Import", MessageBoxButton.OKCancel, MessageBoxImage.Question); } switch (res) { case MessageBoxResult.Yes: case MessageBoxResult.OK: speaker.Clear(); speaker.SendMyName(); speaker.AddRange(sp.PEQ); break; case MessageBoxResult.No: speaker.AddRange(sp.PEQ); break; } speaker.CopySpeakerName(8.RandomString()); speaker.RedrawMasterLine(); return(true); }