Exemplo n.º 1
0
        public void BesselH4Th()
        {
            var x = DspCoefficients.GetXoverSOS(384, 4, FilterType.BesselLp, 48000).Select(n => n.DspParams());
            var y =
                new[]
            {
                new[]
                {
                    0.000605188228776, 0.001210376457552, 0.000605188228776, 1.914182371441551,
                    -0.916603124356656
                },
                new[]
                {
                    0.000605188228776, 0.001210376457552, 0.000605188228776, 1.914182371441551,
                    -0.916603124356656
                },
            };

            var i = 0;

            foreach (var d in x)
            {
                Assert.IsTrue(d.SequenceEqual(y[i++], new DspParamComarer()));
            }
        }
Exemplo n.º 2
0
        public void BiquadXover1StOrder()
        {
            var x = DspCoefficients.GetXoverSOS(1000, 1, FilterType.ButterworthLp, 48000).First().DspParams();
            var y = new[] { 0.061511768503622, 0.061511768503622, 0, 0.876976462992757, 0 };

            Assert.IsTrue(x.SequenceEqual(y, new DspParamComarer()));
        }
Exemplo n.º 3
0
        public override IEnumerable <PeqParam> GetParamData()
        {
            var c = DspCoefficients.GetBiquadSos(PEQDataModel.Boost, PEQDataModel.Frequency,
                                                 PEQDataModel.BandWidth, true, DspCoefficients.Fs);

            yield return(GetSosParamPackage(c, GetBiquad(0)));
        }
Exemplo n.º 4
0
        public void LinkWitz4Th()
        {
            var x = DspCoefficients.GetXoverSOS(512, 4, FilterType.LinkWitzHp, 48000).Select(n => n.DspParams());
            var y =
                new[]
            {
                new[]
                {
                    0.953714080094688, -1.907428160189375, 0.953714080094688, 1.905284625122248,
                    -0.909571695256502
                },
                new[]
                {
                    0.953714080094688, -1.907428160189375, 0.953714080094688, 1.905284625122248,
                    -0.909571695256502
                },
            };

            var i = 0;

            foreach (var d in x)
            {
                Assert.IsTrue(d.SequenceEqual(y[i++], new DspParamComarer()), "failed on biquad " + (i - 1));
            }
        }
Exemplo n.º 5
0
        public void LinkWitz6Th()
        {
            var x = DspCoefficients.GetXoverSOS(384, 6, FilterType.LinkWitzLp, 48000).Select(n => n.DspParams());
            var y =
                new[]
            {
                new[]
                {
                    0.000601309320184, 0.001202618640367, 0.000601309320184, 1.901913563002136,
                    -0.904318800282870
                },
                new[]
                {
                    0.000616045308739, 0.001232090617477, 0.000616045308739, 1.948522813110796,
                    -0.950986994345750
                },

                new[]
                {
                    0.000616045308739, 0.001232090617477, 0.000616045308739, 1.948522813110796,
                    -0.950986994345750
                },
            };

            var i = 0;

            foreach (var d in x)
            {
                Assert.IsTrue(d.SequenceEqual(y[i++], new DspParamComarer()), "failed on biquad " + (i - 1));
            }
        }
Exemplo n.º 6
0
        public void BiquadXover2NdOrder()
        {
            var butter2Lp1000A = DspCoefficients.GetXoverSOS(1000, 2, FilterType.ButterworthLp, 48000).First().DspParams();
            var butter2Lp1000B = new[] { 0.003916126660547, 0.007832253321095, 0.003916126660547, 1.815341082704568, -0.831005589346758 };

            Assert.IsTrue(butter2Lp1000A.SequenceEqual(butter2Lp1000B, new DspParamComarer()));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Low Pilot
        ///         0 1 2
        /// Watts   A B AB
        ///         3 4 5
        /// Ohm     A B AB
        /// High Pilot
        ///         6 7 8
        /// Watts   A B AB
        ///         9 1011
        /// Ohm     A B AB
        /// </summary>
        public static double[] GetLoads(FlowModel flow, MainUnitModel main)
        {
            var ret = new double[12];

            if (main.DspCopy.Count < 131070)
            {
                return(Enumerable.Range(0, 12).Select(n => 0.0).ToArray());
            }
            var ks = main.DspCopy.Skip(McuDat.KreisInstall).Skip(flow.Id * 72).Take(72).ToArray();

            for (var g = 0; g < 2; g++)
            {
                var start = 12 + g * 18;

                //stored load high pilot a, b, ab
                for (var i = 0; i < 3; i++)
                {
                    ret[i + g * 6] = (DspCoefficients.Nfb(new[]
                    {
                        ks[start + i * 2],
                        ks[start + i * 2 + 1]
                    }));
                }
            }
            for (var g = 0; g < 2; g++)
            {
                //add resistance to array
                for (var i = 0; i < 3; i++)
                {
                    switch (flow.AmplifierOperationMode)
                    {
                    case AmplifierOperationMode.Bridged100V:
                    case AmplifierOperationMode.Trafo:
                        var q = ret[i + g * 6];
                        ret[i + 3 + g * 6] = q < .01 ? 0 : Math.Round(10000 / ret[i + g * 6], 0);

                        break;

                    case AmplifierOperationMode.Single50V:
                        q = ret[i + g * 6];
                        ret[i + 3 + g * 6] = q < 0.01 ? 0 : Math.Round(2500 / ret[i + g * 6], 0);
                        break;

                    default:
                        ret[i + 3 + g * 6] = 0;
                        break;
                    }
                }
            }
            for (int i = 0; i < ret.Length; i++)
            {
                if (ret[i] < 10)
                {
                    ret[i] = 0;
                }
            }

            return(ret);
        }
Exemplo n.º 8
0
        private void ReceivedDemuxByte(GetDspValue d)
        {
            //set demuxer for this channel
            var data = (DspCoefficients.DemuxBytes(McuDat.DemuxAlarm[_flow.Id % 12], _flowMux[_flow.Id % 12] + 2, _flowMux[_flow.Id % 12])).ToArray();
            var q    = new DspData(data, _main.Id);

            CommunicationViewModel.AddData(q);
        }
Exemplo n.º 9
0
 private void SetToneControl()
 {
     foreach (var flow in Main.DataModel.Cards.First().Flows)
     {
         var tb = DspCoefficients.BassTreble(Main.DspCopy, flow.Id);
         flow.Bass   = tb.Item1;
         flow.Treble = tb.Item2;
     }
 }
Exemplo n.º 10
0
        private void Update()
        {
            var sos = DspCoefficients.GetToneControl(_flow.Bass,
                                                     _flow.Treble);
            bool b;

            CommunicationViewModel.AddData(bool.TryParse(LibraryData.Settings["SafeloadEnabled"], out b) && b
                        ? new SafeToneControl(sos, _flow.Id)
                        : new SetToneControl(sos, _flow.Id));
            RaisePropertyChanged(() => DisplaySetting);
        }
Exemplo n.º 11
0
        public void LinkWitz2Nd()
        {
            var x = DspCoefficients.GetXoverSOS(512, 2, FilterType.LinkWitzHp, 48000).First().DspParams();
            var y =

                new[]
            {
                0.936180987547197, -1.872361975094395, 0.936180987547197, 1.870257846804933, -0.874466103383856
            };

            Assert.IsTrue(x.SequenceEqual(y, new DspParamComarer()));
        }
Exemplo n.º 12
0
        public void Bessel2Nd()
        {
            var x = DspCoefficients.GetXoverSOS(10000, 2, FilterType.BesselHp, 48000).First().DspParams();
            var y =

                new[]
            {
                0.342719267599336, -0.685438535198671, 0.342719267599336, 0.281858695809837, -0.089018374587505
            };

            Assert.IsTrue(x.SequenceEqual(y, new DspParamComarer()));
        }
Exemplo n.º 13
0
        public void BiquadSosTest()
        {
            var t = DspCoefficients.GetBiquadSos(10, 14000, 1, true, 48000).DspParams();
            var y = new[]
            {
                1.599326168924671,
                0.374162504619094,
                -0.153673263162329,
                -0.374162504619094,
                -0.445652905762343
            };

            Assert.IsTrue(t.SequenceEqual(y, new DspParamComarer()));
        }
Exemplo n.º 14
0
        public void DemuxMux()
        {
            var muz   = DspCoefficients.DemuxBytes(555, 3, 2).ToArray();
            var demux = DspCoefficients.DemuxSelected(SkipAdress(muz));

            Assert.AreEqual(2, demux);

            muz = DspCoefficients.DemuxBytes(1000, 10, 9).ToArray();
            var q = SkipAdress(muz);

            demux = DspCoefficients.DemuxSelected(q);
            Assert.AreEqual(9, demux);

            muz   = DspCoefficients.DemuxBytes(30, 2, 1).ToArray();
            demux = DspCoefficients.DemuxSelected(SkipAdress(muz));
            Assert.AreEqual(1, demux);
        }
Exemplo n.º 15
0
        public void SosXOver3RdOrder()
        {
            var butter3Lp1000A = DspCoefficients.GetXoverSOS(1000, 3, FilterType.ButterworthLp, 48000).Select(n => n.DspParams());
            var butter3Lp1000B =
                new[]
            {
                new [] { 0.061511768503622, 0.061511768503622, 0, 0.876976462992757, 0 },
                new [] { 0.004015505022858, 0.008031010045716, 0.004015505022858, 1.861408444532108, -0.877470464623539 }
            };

            var i = 0;

            foreach (var d in butter3Lp1000A)
            {
                Assert.IsTrue(d.SequenceEqual(butter3Lp1000B[i++], new DspParamComarer()));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        ///     tonecontrol blocks (flow 0-4, card 0)
        /// </summary>
        /// <returns>packages for sending tone control</returns>
        public async Task SetToneControls(IProgress <DownloadProgress> iProgress)
        {
            _toneControlPackages = 0;
            var list = new List <SetToneControl>(
                Main.Cards.First().Flows
                .Select(flow => new SetToneControl(DspCoefficients.GetToneControl(flow.Bass, flow.Treble), flow.Id)));

            CommunicationViewModel.AddData(list);

            foreach (var setToneControl in list)
            {
                await setToneControl.WaitAsync();

                iProgress.Report(new DownloadProgress()
                {
                    Total    = 4,
                    Progress = ++_toneControlPackages
                });
            }
        }
Exemplo n.º 17
0
        private void SetSliders(FlowModel flow)
        {
            if (flow.Id > GenericMethods.StartCountFrom)
            {
                flow.InputSlider = GetGainSlider.DbValue(Main.DspCopy, SliderType.Input,
                                                         (flow.Id - GenericMethods.StartCountFrom) % 5);
            }

            //set pilotTone frequencies
            var pilot = Main.DspCopy.Skip(0xF113 + 72 * flow.Id + 60).First();

            flow.PilotFrequency = PilotToneConverter.PilotFreqDict.ContainsKey(pilot)
                ? PilotToneConverter.PilotFreqDict[pilot]
                : 0;

            flow.InputSlider = GetGainSlider.DbValue(Main.DspCopy, SliderType.Input, flow.Id);
            flow.PageGain    = GetGainSlider.DbValue(Main.DspCopy, SliderType.Page, flow.Id);
            flow.OutputGain  = GetGainSlider.DbValue(Main.DspCopy, SliderType.Output, flow.Id);


            //demux link
            flow.Path = DspCoefficients.Link(Main.DspCopy, flow.Id);
        }
Exemplo n.º 18
0
        public void BesselH3Rd()
        {
            var x = DspCoefficients.GetXoverSOS(10, 3, FilterType.BesselHp, 48000).Select(n => n.DspParams());
            var y =
                new[]
            {
                new[]
                {
                    0.999345929525232, -0.999345929525232, 0, 0.998691859050465, 0
                },
                new[]
                {
                    0.998867231486796, -1.997734462973593, 0.998867231486796, 1.997733607207339,
                    -0.997735318739846
                }
            };

            var i = 0;

            foreach (var d in x)
            {
                Assert.IsTrue(d.SequenceEqual(y[i++], new DspParamComarer()));
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Sends a multi biquad passband filter
 /// there should be enough biquads assigned to this filter
 /// </summary>
 public override IEnumerable <PeqParam> GetParamData()
 {
     return(DspCoefficients.GetXoverSOS(PEQDataModel.Frequency, PEQDataModel.Order,
                                        PEQDataModel.FilterType, DspCoefficients.Fs).Select((source, index) =>
                                                                                            GetSosParamPackage(source, GetBiquad(index))));
 }