Пример #1
0
        public PeqDataViewModel NewParam()
        {
            if (RequiredBiquads <=
                (int)(DataModel.SpeakerPeqType))
            {
                var dm = new PeqDataModel
                {
                    Frequency  = 1000,
                    FilterType = FilterType.Peaking,
                    IsEnabled  = true,
                    BandWidth  = 1,
                    Boost      = 0,
                    Order      = 2,
                    Id         = PeqDataModels.Count
                };



                //vms might not be initiated, add viewmodel before model as initialisation wraps all available models
                var vm = new PeqDataViewModel(dm);
                PeqDataViewModels.Add(vm);

                PeqDataModels.Add(dm);
                var sl = new SpeakerLogic(DataModel);
                sl.AssignBiquads(dm);

                return(vm);
            }
            throw new Exception("not enough biquads");
        }
Пример #2
0
        private void SetModelHandlers(PeqDataViewModel model1)
        {
            model1.BiquadsChanged += OnChangeBiquads;

            model1.DraggablePoint.MouseRightButtonDown += (sender, args) =>
            {
                if (!model1.HasBandwidth())
                {
                    return;
                }
                if (PlotterChildren.Contains(model1.BandWidthPoint) ||
                    PlotterChildren.Contains(model1.BandwidthArrow))
                {
                    return;
                }

                if (model1.BandWidthPoint == null)
                {
                    return;
                }
                PlotterChildren.Add(model1.BandWidthPoint);

                if (model1.BandwidthArrow == null)
                {
                    return;
                }
                PlotterChildren.Add(model1.BandwidthArrow);
            };

            model1.BandWidthPoint.MouseRightButtonDown += (q, i) => RemoveBandwith(model1);
            model1.RemoveThisParam += RemovePeqParam;
        }
Пример #3
0
        private void UpdateBiquads(PeqDataViewModel vm)
        {
            if (!_flowId.HasValue)
            {
                return;
            }
            var usedBiquads = new List <int>(vm.PeqDataModel.Biquads);
            var sl          = new SpeakerLogicForFlow(DataModel, _flowId.Value);

            sl.AssignBiquads(vm.PeqDataModel);
            var toClear = usedBiquads.Except(vm.PeqDataModel.Biquads).ToArray();

            CommunicationViewModel.AddData(sl.GetEmptyDspData(toClear));
            CommunicationViewModel.AddData(sl.GetEmtptyRedundancyData(toClear));
        }
Пример #4
0
        private void TypeChanged(BiquadsChangedEventArgs bf, PeqDataViewModel vm)
        {
            if ((vm.FilterType != FilterType.LinkWitzHp && vm.FilterType != FilterType.LinkWitzLp && vm.Order < 3) &&
                (bf.RequestFilterType == FilterType.LinkWitzHp || bf.RequestFilterType == FilterType.LinkWitzLp) &&
                (DataModel.PEQ.RequiredBiquads() >= (int)DataModel.SpeakerPeqType))
            {
                bf.Cancel = true;
                vm.ResetType();
                return;
            }

            vm.SetType(bf.RequestFilterType);
            vm.SetOrder(2);
            vm.UpdateFilterType();
            UpdateBiquads(vm);
            SendParamData(vm.PeqDataModel);
        }
Пример #5
0
        private void AddNew(PeqDataModel data)
        {
            var dm = new PeqDataModel
            {
                Id         = PeqDataModels.Count,
                FilterType = data.FilterType,
                IsEnabled  = data.IsEnabled,
                BandWidth  = data.BandWidth,
                Boost      = data.Boost,
                Frequency  = data.Frequency,
                Order      = data.Order,
                Gain       = data.Gain,
            };

            //dm.Parse(data);

            PeqDataModels.Add(dm);
            var vm = new PeqDataViewModel(dm);

            vm.RemoveThisParam += RemovePeqParam;
            PeqDataViewModels.Add(vm);
        }
Пример #6
0
        private void OrderChanged(BiquadsChangedEventArgs bf, PeqDataViewModel vm)
        {
            //check if this change fits in current filter:
            //value has to be smaller than current value;
            //the order is odd. In this case half of a biquad is used already;
            //There is space left.
            var oldValue = vm.Order;

            vm.SetOrder(bf.RequestOrder);
            if (DataModel.PEQ.RequiredBiquads() <= (int)DataModel.SpeakerPeqType)
            {
                vm.SetOrder(bf.RequestOrder);
                vm.UpdateFilterType();
                UpdateBiquads(vm);
                SendParamData(vm.PeqDataModel);
            }
            else
            {
                vm.SetOrder(oldValue);
                bf.Cancel = true;
            }
        }
Пример #7
0
 public void OnRemoveParam(PeqDataViewModel s)
 {
     PeqDataModels.Remove(s.PeqDataModel);
     PeqDataViewModels.Remove(s);
     ReorderIds(PeqDataViewModels);
 }
Пример #8
0
 private void RemoveVm(PeqDataViewModel s)
 {
     PlotterChildren.Remove(s.DraggablePoint);
     PlotterChildren.Remove(s.LineData);
     RemoveBandwith(s);
 }
Пример #9
0
 private void RemoveBandwith(PeqDataViewModel model1)
 {
     PlotterChildren.Remove(model1.BandWidthPoint);
     PlotterChildren.Remove(model1.BandwidthArrow);
 }
Пример #10
0
 private void FilterChanged(BiquadsChangedEventArgs bf, PeqDataViewModel vm)
 {
     SendParamData(vm.PeqDataModel);
 }