private void ApplyPreset(ImpulsePreset newPreset) { preset = newPreset; ImpulseConfig.Clear(); foreach (var ic in preset.ImpulseConfig) { var vm = AddImpulseConfigVm(ic); Task.Delay(100).ContinueWith(_ => vm.Update()); } MixingConfig = new MixingViewModel(preset.MixingConfig, preset.SamplerateTransformed) { OnUpdateCallback = () => updateRateLimiter.Pulse() }; SelectedImpulseConfigIndex = 0; NotifyPropertyChanged(nameof(MixingConfig)); NotifyPropertyChanged(nameof(Samplerate)); NotifyPropertyChanged(nameof(ImpulseLength)); NotifyPropertyChanged(nameof(Normalize)); NotifyPropertyChanged(nameof(WindowMethod)); NotifyPropertyChanged(nameof(SamplerateReadout)); NotifyPropertyChanged(nameof(ImpulseLengthReadout)); updateRateLimiter.Pulse(); }
public SpectrumStageViewModel(ImpulsePreset preset, ImpulseConfig config, SpectrumStage stage, int index, Action onUpdateCallback) { this.applySources = preset.ImpulseConfig.TakeWhile(x => x != config).OrderBy(x => x.Index).ToArray(); applySources = new[] { new ImpulseConfig() { Name = "None", Index = -1 } }.Concat(applySources).ToArray(); this.config = config; this.stage = stage; this.onUpdateCallback = onUpdateCallback; Index = index; }
private ImpulseConfigViewModel AddImpulseConfigVm(ImpulseConfig ic) { var vm = new ImpulseConfigViewModel(ic, preset, loadSampleDirectory) { OnUpdateCallback = () => updateRateLimiter.Pulse(), OnLoadSampleCallback = dir => loadSampleDirectory = Path.GetDirectoryName(dir), ImpulseLength = preset.ImpulseLengthTransformed, Samplerate = preset.SamplerateTransformed }; ImpulseConfig.Add(vm); return(vm); }
public static string SerializeImpulse(ImpulseConfig impulseConfig) { JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = new WritablePropertiesOnlyResolver() }; settings.Formatting = Formatting.Indented; string json = JsonConvert.SerializeObject(impulseConfig, settings); return(json); }
private void AddImpulse() { var ic = new ImpulseConfig { Name = "New Impulse", Samplerate = preset.SamplerateTransformed }; preset.ImpulseConfig = preset.ImpulseConfig.Concat(new[] { ic }).ToArray(); var vm = AddImpulseConfigVm(ic); Task.Delay(100).ContinueWith(_ => vm.Update()); SelectedImpulseConfigIndex = ImpulseConfig.Count - 1; UpdateApplySources(); updateRateLimiter.Pulse(); }
public ImpulseConfigViewModel(ImpulseConfig config, ImpulsePreset preset, string loadSampleDirectory) { this.impulseConfig = config; this.preset = preset; this.loadSampleDirectory = loadSampleDirectory; this.updateRateLimiter = new LastRetainRateLimiter(100, UpdateInner); LoadSampleCommand = new DelegateCommand(_ => LoadSampleDialog()); ClearSampleCommand = new DelegateCommand(_ => ClearSample()); PreviousSampleCommand = new DelegateCommand(_ => LoadPreviousSample()); NextSampleCommand = new DelegateCommand(_ => LoadNextSample()); AddStageCommand = new DelegateCommand(_ => AddStage()); RemoveStageCommand = new DelegateCommand(_ => RemoveStage()); MoveStageLeftCommand = new DelegateCommand(_ => MoveStageLeft()); MoveStageRightCommand = new DelegateCommand(_ => MoveStageRight()); PlotImpulseBase = true; LoadSampleData(); selectedSpectrumStageIndex = config.SpectrumStages.Length - 1; }
private void RemoveImpulse() { if (SelectedImpulse == null) { return; } var impulses = new List <ImpulseConfig>(); foreach (var ic in preset.ImpulseConfig) { if (ic != SelectedImpulse.ImpulseConfig) { impulses.Add(ic); } } preset.ImpulseConfig = impulses.ToArray(); ImpulseConfig.RemoveAt(selectedImpulseConfigIndex); UpdateApplySources(); updateRateLimiter.Pulse(); }