コード例 #1
0
        public FilterConfiguration(FilterBase filter)
        {
            InitializeComponent();

            if (filter != null) {
                mFilter = filter;
            }

            SetLocalizedTextToUI();
        }
コード例 #2
0
        private void buttonUseCic_Click(object sender, RoutedEventArgs e)
        {
            int delay;
            if (!Int32.TryParse(textBoxCicDelay.Text, out delay)) {
                MessageBox.Show(Properties.Resources.ErrorCicDelay);
                return;
            }
            if (delay <= 0) {
                MessageBox.Show(Properties.Resources.ErrorCicDelay);
                return;
            }

            mFilter = new CicFilter(CicFilter.CicType.SingleStage, delay);
            DialogResult = true;
            Close();
        }
コード例 #3
0
        private void InitializeUIbyFilter(FilterBase filter)
        {
            switch (filter.FilterType) {
                case FilterType.Gain:
                    textBoxGainInDB.TextChanged        -= mTextBoxGainInDbChangedEH;
                    textBoxGainInAmplitude.TextChanged -= mTextBoxGainInAmplitudeChangedEH;

                    var gain = filter as GainFilter;
                    textBoxGainInDB.Text = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(gain.Amplitude));
                    textBoxGainInAmplitude.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gain.Amplitude);

                    textBoxGainInDB.TextChanged        += mTextBoxGainInDbChangedEH;
                    textBoxGainInAmplitude.TextChanged += mTextBoxGainInAmplitudeChangedEH;
                    break;
                case FilterType.ZohUpsampler:
                    var zoh = filter as ZeroOrderHoldUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(zoh.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.ZOH;
                    break;
                case FilterType.LineDrawUpsampler:
                    var ldu = filter as LineDrawUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(ldu.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.LineDraw;
                    break;
                case FilterType.CubicHermiteSplineUpsampler:
                    var chu = filter as CubicHermiteSplineUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(chu.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.CubicHermiteSpline;
                    break;
                case FilterType.LowPassFilter:
                    var lpf = filter as LowpassFilter;
                    textBoxLpfCutoff.Text = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.CutoffFrequency);
                    comboBoxLpfLen.SelectedIndex = (int)LpfLenToLpfLenType(lpf.FilterLength);
                    textBoxLpfSlope.Text = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.FilterSlopeDbOct);
                    break;
                case FilterType.FftUpsampler:
                    var fftu = filter as FftUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(fftu.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.FFT;
                    comboBoxUpsampleLen.SelectedIndex = (int)UpsampleLenToUpsampleLenType(fftu.FftLength);
                    comboBoxFftOverlap.SelectedIndex = (int)fftu.Overlap;
                    break;
                case FilterType.WindowedSincUpsampler:
                    var wsu = filter as WindowedSincUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(wsu.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.WindowedSinc;
                    comboBoxUpsampleLen.SelectedIndex = (int)UpsampleLenToUpsampleLenType(wsu.WindowLength+1);
                    comboBoxWindowedSincMethod.SelectedIndex = (int)wsu.Method;
                    break;
                case FilterType.Mash2:
                    var mash = filter as MashFilter;
                    textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", mash.TargetBitsPerSample);
                    break;

                case FilterType.NoiseShaping:
                    var ns = filter as NoiseShapingFilter;
                    textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ns.TargetBitsPerSample);
                    comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping2nd;
                    break;
                case FilterType.ReduceBitDepth:
                    var q = filter as ReduceBitDepth;
                    textBoxTargetBitDepth.Text = string.Format(CultureInfo.CurrentCulture, "{0}", q.TargetBitsPerSample);
                    break;
                case FilterType.FirstOrderAllPassIIR:
                    var fomp = filter as FirstOrderAllPassIIRFilter;
                    textBoxFirstOrderAllPassIirA.Text = string.Format(CultureInfo.CurrentCulture, "{0}", fomp.A);
                    break;
                case FilterType.SecondOrderAllPassIIR:
                    var somp = filter as SecondOrderAllPassIIRFilter;
                    textBoxSecondOrderAllPassIirR.Text = string.Format(CultureInfo.CurrentCulture, "{0}", somp.R);
                    textBoxSecondOrderAllPassIirT.Text = string.Format(CultureInfo.CurrentCulture, "{0}", somp.T);
                    break;
                case FilterType.NoiseShaping4th:
                    var ns4 = filter as NoiseShaping4thFilter;
                    textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ns4.TargetBitsPerSample);
                    comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping4th;
                    break;
                case FilterType.TagEdit:
                    var te = filter as TagEditFilter;
                    comboBoxTagType.SelectedIndex = (int)te.TagType;
                    textBoxTagText.Text = te.Text;
                    break;
                case FilterType.Downsampler:
                    var ds = filter as Downsampler;
                    comboBoxDownsampleOption.SelectedIndex = ds.PickSampleIndex;
                    break;
                case FilterType.CicFilter:
                    var cic = filter as CicFilter;
                    textBoxCicDelay.Text = string.Format(CultureInfo.CurrentCulture, "{0}", cic.Delay);
                    break;

                case FilterType.InsertZeroesUpsampler:
                    var izu = filter as InsertZeroesUpsampler;
                    comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(izu.Factor);
                    comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.InsertZeroes;
                    break;
                case FilterType.HalfbandFilter:
                    var hbf = filter as HalfbandFilter;
                    textBoxHalfBandFilterTap.Text = string.Format(CultureInfo.CurrentCulture, "{0}", hbf.FilterLength);
                    break;
                case FilterType.Crossfeed:
                    var cf = filter as CrossfeedFilter;
                    textBoxCrossfeedCoefficientFile.Text = cf.FilterFilePath;
                    break;
                case FilterType.JitterAdd:
                    var jaf = filter as JitterAddFilter;
                    break;
                case FilterType.GaussianNoise:
                    var gnf = filter as GaussianNoiseFilter;
                    textBoxGaussianNoiseDb.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gnf.NoiseLevelDb);
                    break;
                case FilterType.DynamicRangeCompression:
                    var drc = filter as DynamicRangeCompressionFilter;
                    textBoxDynamicRangeCompressionLsbScaling.Text = string.Format(CultureInfo.CurrentCulture, "{0}", drc.LsbScalingDb);
                    break;
                case FilterType.UnevenBitDac:
                    var ubd = filter as UnevenBitDacFilter;
                    textBoxUnevenBitDacLsbScaling.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ubd.LsbScalingDb);
                    break;
                case FilterType.AddFundamentals:
                    var af = filter as AddFundamentalsFilter;
                    textBoxAddFundamentalsGain.Text = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(af.Gain));
                    break;
                }
        }
コード例 #4
0
        private void InitializeUIbyFilter(FilterBase filter)
        {
            switch (filter.FilterType)
            {
            case FilterType.Gain:
                textBoxGainInDB.TextChanged        -= mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged -= mTextBoxGainInAmplitudeChangedEH;

                var gain = filter as GainFilter;
                textBoxGainInDB.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(gain.Amplitude));
                textBoxGainInAmplitude.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gain.Amplitude);

                textBoxGainInDB.TextChanged        += mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged += mTextBoxGainInAmplitudeChangedEH;
                break;

            case FilterType.ZohUpsampler:
                var zoh = filter as ZeroOrderHoldUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(zoh.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.ZOH;
                break;

            case FilterType.LineDrawUpsampler:
                var ldu = filter as LineDrawUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(ldu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.LineDraw;
                break;

            case FilterType.CubicHermiteSplineUpsampler:
                var chu = filter as CubicHermiteSplineUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(chu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.CubicHermiteSpline;
                break;

            case FilterType.LowPassFilter:
                var lpf = filter as LowpassFilter;
                textBoxLpfCutoff.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.CutoffFrequency);
                comboBoxLpfLen.SelectedIndex = (int)LpfLenToLpfLenType(lpf.FilterLength);
                textBoxLpfSlope.Text         = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.FilterSlopeDbOct);
                break;

            case FilterType.FftUpsampler:
                var fftu = filter as FftUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(fftu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.FFT;
                comboBoxUpsampleLen.SelectedIndex      = (int)UpsampleLenToUpsampleLenType(fftu.FftLength);
                comboBoxFftOverlap.SelectedIndex       = (int)fftu.Overlap;
                break;

            case FilterType.WindowedSincUpsampler:
                var wsu = filter as WindowedSincUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex   = (int)UpsamplingFactorToUpsamplingFactorType(wsu.Factor);
                comboBoxUpsamplerType.SelectedIndex      = (int)UpsamplerType.WindowedSinc;
                comboBoxUpsampleLen.SelectedIndex        = (int)UpsampleLenToUpsampleLenType(wsu.WindowLength + 1);
                comboBoxWindowedSincMethod.SelectedIndex = (int)wsu.Method;
                break;

            case FilterType.Mash2:
                var mash = filter as MashFilter;
                textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", mash.TargetBitsPerSample);
                break;

            case FilterType.NoiseShaping:
                var ns = filter as NoiseShapingFilter;
                textBoxNoiseShapingTargetBit.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", ns.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping2nd;
                break;

            case FilterType.ReduceBitDepth:
                var q = filter as ReduceBitDepth;
                textBoxTargetBitDepth.Text = string.Format(CultureInfo.CurrentCulture, "{0}", q.TargetBitsPerSample);
                break;

            case FilterType.FirstOrderAllPassIIR:
                var fomp = filter as FirstOrderAllPassIIRFilter;
                textBoxFirstOrderAllPassIirA.Text = string.Format(CultureInfo.CurrentCulture, "{0}", fomp.A);
                break;

            case FilterType.SecondOrderAllPassIIR:
                var somp = filter as SecondOrderAllPassIIRFilter;
                textBoxSecondOrderAllPassIirR.Text = string.Format(CultureInfo.CurrentCulture, "{0}", somp.R);
                textBoxSecondOrderAllPassIirT.Text = string.Format(CultureInfo.CurrentCulture, "{0}", somp.T);
                break;

            case FilterType.NoiseShaping4th:
                var ns4 = filter as NoiseShaping4thFilter;
                textBoxNoiseShapingTargetBit.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", ns4.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping4th;
                break;

            case FilterType.TagEdit:
                var te = filter as TagEditFilter;
                comboBoxTagType.SelectedIndex = (int)te.TagType;
                textBoxTagText.Text           = te.Text;
                break;

            case FilterType.Downsampler:
                var ds = filter as Downsampler;
                comboBoxDownsampleOption.SelectedIndex = ds.PickSampleIndex;
                break;

            case FilterType.CicFilter:
                var cic = filter as CicFilter;
                textBoxCicDelay.Text = string.Format(CultureInfo.CurrentCulture, "{0}", cic.Delay);
                break;

            case FilterType.InsertZeroesUpsampler:
                var izu = filter as InsertZeroesUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(izu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.InsertZeroes;
                break;

            case FilterType.HalfbandFilter:
                var hbf = filter as HalfbandFilter;
                textBoxHalfBandFilterTap.Text = string.Format(CultureInfo.CurrentCulture, "{0}", hbf.FilterLength);
                break;

            case FilterType.Crossfeed:
                var cf = filter as CrossfeedFilter;
                textBoxCrossfeedCoefficientFile.Text = cf.FilterFilePath;
                break;

            case FilterType.JitterAdd:
                var jaf = filter as JitterAddFilter;
                break;

            case FilterType.GaussianNoise:
                var gnf = filter as GaussianNoiseFilter;
                textBoxGaussianNoiseDb.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gnf.NoiseLevelDb);
                break;

            case FilterType.DynamicRangeCompression:
                var drc = filter as DynamicRangeCompressionFilter;
                textBoxDynamicRangeCompressionLsbScaling.Text = string.Format(CultureInfo.CurrentCulture, "{0}", drc.LsbScalingDb);
                break;

            case FilterType.UnevenBitDac:
                var ubd = filter as UnevenBitDacFilter;
                textBoxUnevenBitDacLsbScaling.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ubd.LsbScalingDb);
                break;

            case FilterType.AddFundamentals:
                var af = filter as AddFundamentalsFilter;
                textBoxAddFundamentalsGain.Text = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(af.Gain));
                break;
            }
        }
コード例 #5
0
        private void buttonUseUpsampler_Click(object sender, RoutedEventArgs e)
        {
            int factor = UpsamplingFactorTypeToUpsampingfactor(comboBoxUpsamplingFactor.SelectedIndex);
            int len = UpsampleLenTypeToLpfLen(comboBoxUpsampleLen.SelectedIndex);

            switch (comboBoxUpsamplerType.SelectedIndex) {
            case (int)UpsamplerType.ZOH:
                mFilter = new ZeroOrderHoldUpsampler(factor);
                break;
            case (int)UpsamplerType.FFT:
                mFilter = new FftUpsampler(factor, len);
                break;
            case (int)UpsamplerType.InsertZeroes:
                mFilter = new InsertZeroesUpsampler(factor);
                break;
            default:
                System.Diagnostics.Debug.Assert(false);
                mFilter = new FftUpsampler(factor, len);
                break;
            }

            DialogResult = true;
            Close();
        }
コード例 #6
0
        private void buttonUseNoiseShaping_Click(object sender, RoutedEventArgs e)
        {
            int nBit;
            if (!Int32.TryParse(textBoxNoiseShapingTargetBit.Text, out nBit)) {
                MessageBox.Show(Properties.Resources.ErrorNoiseShapingBitIsNan);
                return;
            }
            if (nBit < 1 || 23 < nBit) {
                MessageBox.Show(Properties.Resources.ErrorNoiseShapingBitIsOutOfRange);
                return;
            }

            /*
            if (comboBoxNoiseShapingMethod.SelectedIndex == (int)NoiseShapingCbItemType.NoiseShaping4th
                && nBit != 1) {
                MessageBox.Show(Properties.Resources.ErrorNoiseShaping4thBitIsNot1);
                return;
            }
            */

            switch (comboBoxNoiseShapingMethod.SelectedIndex) {
            case (int)NoiseShapingCbItemType.NoiseShaping2nd:
                mFilter = new NoiseShapingFilter(nBit, 2);
                break;
            case (int)NoiseShapingCbItemType.NoiseShaping4th:
                mFilter = new NoiseShaping4thFilter(nBit);
                break;
            }
            DialogResult = true;
            Close();
        }
コード例 #7
0
        private void buttonUseHalfBandFilter_Click(object sender, RoutedEventArgs e)
        {
            int taps;
            if (!Int32.TryParse(textBoxHalfBandFilterTap.Text, out taps)) {
                MessageBox.Show(Properties.Resources.ErrorHalfbandTaps);
                return;
            }
            if (taps <= 0) {
                MessageBox.Show(Properties.Resources.ErrorHalfbandTaps);
                return;
            }

            mFilter = new HalfbandFilter(taps);
            DialogResult = true;
            Close();
        }
コード例 #8
0
        private void buttonUseDownsampler_Click(object sender, RoutedEventArgs e)
        {
            int factor = 0;
            switch (comboBoxDownsampleType.SelectedIndex) {
            case (int)DownsamplerType.Down2x:
                factor = 2;
                break;
            default:
                System.Diagnostics.Debug.Assert(false);
                return;
            }

            int pickSampleIndex = (int)comboBoxDownsampleOption.SelectedIndex;

            mFilter = new Downsampler(factor, pickSampleIndex);
            DialogResult = true;
            Close();
        }
コード例 #9
0
        private void buttonUseGaussianNoise_Click(object sender, RoutedEventArgs e)
        {
            double noiseLevelDb = 0;
                if (!Double.TryParse(textBoxGaussianNoiseDb.Text, out noiseLevelDb)) {
                    MessageBox.Show(Properties.Resources.ErrorGaussianNoiseLevel);
                    return;
                }

                mFilter = new GaussianNoiseFilter(noiseLevelDb);
                DialogResult = true;
                Close();
        }
コード例 #10
0
        private void buttonUseFirstOrderAllPassIir_Click(object sender, RoutedEventArgs e)
        {
            double a;
                if (!Double.TryParse(textBoxFirstOrderAllPassIirA.Text, out a) || 1.0 < Math.Abs(a) || a == 0) {
                    MessageBox.Show(Properties.Resources.ErrorFirstOrderAllPassIIR);
                    return;
                }

                mFilter = new FirstOrderAllPassIIRFilter(a);

                DialogResult = true;
                Close();
        }
コード例 #11
0
        private void buttonUseDynamicRangeCompression_Click(object sender, RoutedEventArgs e)
        {
            double lsbScalingDb = 1;
                if (!Double.TryParse(textBoxDynamicRangeCompressionLsbScaling.Text, out lsbScalingDb)) {
                    MessageBox.Show(Properties.Resources.ErrorDynamicRangeCompressionLsbScaling);
                    return;
                }

                mFilter = new DynamicRangeCompressionFilter(lsbScalingDb);
                DialogResult = true;
                Close();
        }
コード例 #12
0
        private void buttonUseAddJitter_Click(object sender, RoutedEventArgs e)
        {
            double sineJitterFreq;
                if (!Double.TryParse(textBoxSinusoidalJitterFreq.Text, out sineJitterFreq)) {
                    MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterFreq);
                    return;
                }
                if (sineJitterFreq < 0) {
                    MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterFreq);
                    return;
                }

                double sineJitterNanosec;
                if (!Double.TryParse(textBoxSinusoidalJitterNanoSeconds.Text, out sineJitterNanosec)) {
                    MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterAmount);
                    return;
                }
                if (sineJitterNanosec < 0) {
                    MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterAmount);
                    return;
                }

                double tpdfJitterNanosec;
                if (!Double.TryParse(textBoxTpdfJitterNanoSeconds.Text, out tpdfJitterNanosec)) {
                    MessageBox.Show(Properties.Resources.ErrorTpdfJitterAmount);
                    return;
                }
                if (tpdfJitterNanosec < 0) {
                    MessageBox.Show(Properties.Resources.ErrorTpdfJitterAmount);
                    return;
                }

                double rpdfJitterNanosec;
                if (!Double.TryParse(textBoxRpdfJitterNanoSeconds.Text, out rpdfJitterNanosec)) {
                    MessageBox.Show(Properties.Resources.ErrorRpdfJitterAmount);
                    return;
                }
                if (rpdfJitterNanosec < 0) {
                    MessageBox.Show(Properties.Resources.ErrorRpdfJitterAmount);
                    return;
                }

                int convolutionN = 1024;
                if (0 <= comboBoxFilterLength.SelectedIndex) {
                    convolutionN = mConvolutionLengthArray[comboBoxFilterLength.SelectedIndex];
                }

                mFilter = new JitterAddFilter(sineJitterFreq, sineJitterNanosec, tpdfJitterNanosec, rpdfJitterNanosec, convolutionN);

                DialogResult = true;
                Close();
        }
コード例 #13
0
        private void buttonUseAddFundamentals_Click(object sender, RoutedEventArgs e)
        {
            double v;
                if (!Double.TryParse(textBoxAddFundamentalsGain.Text, out v) || 0.0 < v) {
                    MessageBox.Show(Properties.Resources.ErrorFundamentalsGainValue);
                    return;
                }

                mFilter = new AddFundamentalsFilter(Math.Pow(10.0, v / 20.0));

                DialogResult = true;
                Close();
        }
コード例 #14
0
        private void buttonUseAddJitter_Click(object sender, RoutedEventArgs e)
        {
            double sineJitterFreq;

            if (!Double.TryParse(textBoxSinusoidalJitterFreq.Text, out sineJitterFreq))
            {
                MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterFreq);
                return;
            }
            if (sineJitterFreq < 0)
            {
                MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterFreq);
                return;
            }

            double sineJitterNanosec;

            if (!Double.TryParse(textBoxSinusoidalJitterNanoSeconds.Text, out sineJitterNanosec))
            {
                MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterAmount);
                return;
            }
            if (sineJitterNanosec < 0)
            {
                MessageBox.Show(Properties.Resources.ErrorSinusolidalJitterAmount);
                return;
            }

            double tpdfJitterNanosec;

            if (!Double.TryParse(textBoxTpdfJitterNanoSeconds.Text, out tpdfJitterNanosec))
            {
                MessageBox.Show(Properties.Resources.ErrorTpdfJitterAmount);
                return;
            }
            if (tpdfJitterNanosec < 0)
            {
                MessageBox.Show(Properties.Resources.ErrorTpdfJitterAmount);
                return;
            }

            double rpdfJitterNanosec;

            if (!Double.TryParse(textBoxRpdfJitterNanoSeconds.Text, out rpdfJitterNanosec))
            {
                MessageBox.Show(Properties.Resources.ErrorRpdfJitterAmount);
                return;
            }
            if (rpdfJitterNanosec < 0)
            {
                MessageBox.Show(Properties.Resources.ErrorRpdfJitterAmount);
                return;
            }

            int convolutionN = 1024;

            if (0 <= comboBoxFilterLength.SelectedIndex)
            {
                convolutionN = mConvolutionLengthArray[comboBoxFilterLength.SelectedIndex];
            }

            mFilter = new JitterAddFilter(sineJitterFreq, sineJitterNanosec, tpdfJitterNanosec, rpdfJitterNanosec, convolutionN);

            DialogResult = true;
            Close();
        }
コード例 #15
0
        private void buttonUseNormalize_Click(object sender, RoutedEventArgs e)
        {
            double v;
                if (!Double.TryParse(textBoxNormalizeAmplitude.Text, out v) || 0.0 < v) {
                    MessageBox.Show(Properties.Resources.ErrorNormalizeValue);
                    return;
                }

                mFilter = new NormalizeFilter(Math.Pow(10.0, v / 20.0));

                DialogResult = true;
                Close();
        }
コード例 #16
0
        private void buttonUseCrossfeedFilter_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxCrossfeedCoefficientFile.Text.Length == 0) {
                MessageBox.Show(Properties.Resources.ErrorCrossfeedFile);
                return;
            }

            mFilter = new CrossfeedFilter(textBoxCrossfeedCoefficientFile.Text);
            DialogResult = true;
            Close();
        }
コード例 #17
0
        private void buttonUseReduceBitDepth_Click(object sender, RoutedEventArgs e)
        {
            int v;
                if (!Int32.TryParse(textBoxTargetBitDepth.Text, out v) || 24 <= v || v < 1) {
                    MessageBox.Show(Properties.Resources.ErrorTargetBitDepth);
                    return;
                }

                mFilter = new ReduceBitDepth(v);

                DialogResult = true;
                Close();
        }
コード例 #18
0
        private void buttonUseGain_Click(object sender, RoutedEventArgs e)
        {
            double v;
            if (!Double.TryParse(textBoxGainInAmplitude.Text, out v)) {
                MessageBox.Show(Properties.Resources.ErrorGainValueIsNan);
                return;
            }
            if (v <= Double.Epsilon) {
                MessageBox.Show(Properties.Resources.ErrorGainValueIsTooSmall);
                return;
            }

            mFilter = new GainFilter(v);

            DialogResult = true;
            Close();
        }
コード例 #19
0
        private void buttonUseSecondOrderAllPassIir_Click(object sender, RoutedEventArgs e)
        {
            double r;
                if (!Double.TryParse(textBoxSecondOrderAllPassIirR.Text, out r) || 1.0 < Math.Abs(r) || r== 0) {
                    MessageBox.Show(Properties.Resources.ErrorSecondOrderAllPassIirR);
                    return;
                }

                double t;
                if (!Double.TryParse(textBoxSecondOrderAllPassIirT.Text, out t)) {
                    MessageBox.Show(Properties.Resources.ErrorSecondOrderAllPassIirT);
                    return;
                }

                mFilter = new SecondOrderAllPassIIRFilter(r, t);

                DialogResult = true;
                Close();
        }
コード例 #20
0
        private void buttonUseLpf_Click(object sender, RoutedEventArgs e)
        {
            double v;
            if (!Double.TryParse(textBoxLpfCutoff.Text, out v)) {
                MessageBox.Show(Properties.Resources.ErrorLpfCutoffFreqIsNan);
                return;
            }
            if (v <= 0.0) {
                MessageBox.Show(Properties.Resources.ErrorLpfCutoffFreqIsNegative);
                return;
            }

            int slope;
            if (!Int32.TryParse(textBoxLpfSlope.Text, out slope)) {
                MessageBox.Show(Properties.Resources.ErrorLpfSlopeIsNan);
                return;
            }

            if (slope <= 0) {
                MessageBox.Show(Properties.Resources.ErrorLpfSlopeIsTooSmall);
                return;
            }

            int filterLength = LpfLenTypeToLpfLen(comboBoxLpfLen.SelectedIndex);

            mFilter = new LowpassFilter(v, filterLength, slope);
            DialogResult = true;
            Close();
        }
コード例 #21
0
        private void buttonUseUnevenBitDac_Click(object sender, RoutedEventArgs e)
        {
            double lsbScalingDb = 1;
                if (!Double.TryParse(textBoxUnevenBitDacLsbScaling.Text, out lsbScalingDb)) {
                    MessageBox.Show(Properties.Resources.ErrorUnevenBitDacLsbScaling);
                    return;
                }

                mFilter = new UnevenBitDacFilter(lsbScalingDb);
                DialogResult = true;
                Close();
        }
コード例 #22
0
        private void buttonUseTagEdit_Click(object sender, RoutedEventArgs e)
        {
            TagEditFilter.Type type = TagEditFilter.Type.Title;

            switch (comboBoxTagType.SelectedIndex) {
            case (int)TagEditType.Title:
                type = TagEditFilter.Type.Title;
                break;
            case (int)TagEditType.Album:
                type = TagEditFilter.Type.Album;
                break;
            case (int)TagEditType.AlbumArtist:
                type = TagEditFilter.Type.AlbumArtist;
                break;
            case (int)TagEditType.Artist:
                type = TagEditFilter.Type.Artist;
                break;
            case (int)TagEditType.Genre:
                type = TagEditFilter.Type.Genre;
                break;
            default:
                System.Diagnostics.Debug.Assert(false);
                return;
            }

            mFilter = new TagEditFilter(type, textBoxTagText.Text);
            DialogResult = true;
            Close();
        }
コード例 #23
0
        private void buttonUseUpsampler_Click(object sender, RoutedEventArgs e)
        {
            int factor = UpsamplingFactorTypeToUpsampingfactor(comboBoxUpsamplingFactor.SelectedIndex);
                int len = UpsampleLenTypeToLpfLen(comboBoxUpsampleLen.SelectedIndex);

                FftUpsampler.OverlapType overlap = (FftUpsampler.OverlapType)comboBoxFftOverlap.SelectedIndex;
                WindowedSincUpsampler.MethodType method = (WindowedSincUpsampler.MethodType)comboBoxWindowedSincMethod.SelectedIndex;

                switch (comboBoxUpsamplerType.SelectedIndex) {
                case (int)UpsamplerType.ZOH:
                    mFilter = new ZeroOrderHoldUpsampler(factor);
                    break;
                case (int)UpsamplerType.LineDraw:
                    mFilter = new LineDrawUpsampler(factor);
                    break;
                case (int)UpsamplerType.CubicHermiteSpline:
                    mFilter = new CubicHermiteSplineUpsampler(factor);
                    break;
                case (int)UpsamplerType.FFT:
                    mFilter = new FftUpsampler(factor, len, overlap);
                    break;
                case (int)UpsamplerType.WindowedSinc:
                    mFilter = new WindowedSincUpsampler(factor, len - 1, method);
                    break;
                case (int)UpsamplerType.InsertZeroes:
                    mFilter = new InsertZeroesUpsampler(factor);
                    break;
                default:
                    System.Diagnostics.Debug.Assert(false);
                    mFilter = null;
                    break;
                }

                DialogResult = true;
                Close();
        }
コード例 #24
0
        private void InitializeUIbyFilter(FilterBase filter)
        {
            switch (filter.FilterType) {
            case FilterType.Gain:
                textBoxGainInDB.TextChanged        -= mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged -= mTextBoxGainInAmplitudeChangedEH;

                var gain = filter as GainFilter;
                textBoxGainInDB.Text = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(gain.Amplitude));
                textBoxGainInAmplitude.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gain.Amplitude);

                textBoxGainInDB.TextChanged        += mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged += mTextBoxGainInAmplitudeChangedEH;
                break;
            case FilterType.ZohUpsampler:
                var zoh = filter as ZeroOrderHoldUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(zoh.Factor);
                comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.ZOH;
                break;
            case FilterType.LowPassFilter:
                var lpf = filter as LowpassFilter;
                textBoxLpfCutoff.Text = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.CutoffFrequency);
                comboBoxLpfLen.SelectedIndex = (int)LpfLenToLpfLenType(lpf.FilterLength);
                textBoxLpfSlope.Text = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.FilterSlopeDbOct);
                break;
            case FilterType.FftUpsampler:
                var fftu = filter as FftUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(fftu.Factor);
                comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.FFT;
                comboBoxUpsampleLen.SelectedIndex = (int)UpsampleLenToUpsampleLenType(fftu.FftLength);
                break;
            case FilterType.Mash2:
                var mash = filter as MashFilter;
                textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", mash.TargetBitsPerSample);
                break;

            case FilterType.NoiseShaping:
                var ns = filter as NoiseShapingFilter;
                textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ns.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping2nd;
                break;
            case FilterType.NoiseShaping4th:
                var ns4 = filter as NoiseShaping4thFilter;
                textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", ns4.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping4th;
                break;
            case FilterType.TagEdit:
                var te = filter as TagEditFilter;
                comboBoxTagType.SelectedIndex = (int)te.TagType;
                textBoxTagText.Text = te.Text;
                break;
            case FilterType.Downsampler:
                var ds = filter as Downsampler;
                comboBoxDownsampleOption.SelectedIndex = ds.PickSampleIndex;
                break;
            case FilterType.CicFilter:
                var cic = filter as CicFilter;
                textBoxCicDelay.Text = string.Format(CultureInfo.CurrentCulture, "{0}", cic.Delay);
                break;

            case FilterType.InsertZeroesUpsampler:
                var izu = filter as InsertZeroesUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(izu.Factor);
                comboBoxUpsamplerType.SelectedIndex = (int)UpsamplerType.InsertZeroes;
                break;
            case FilterType.HalfbandFilter:
                var hbf = filter as HalfbandFilter;
                textBoxHalfBandFilterTap.Text = string.Format(CultureInfo.CurrentCulture, "{0}", hbf.FilterLength);
                break;
            case FilterType.Crossfeed:
                var cf = filter as CrossfeedFilter;
                textBoxCrossfeedCoefficientFile.Text = cf.FilterFilePath;
                break;
            }
        }
コード例 #25
0
        private void InitializeUIbyFilter(FilterBase filter)
        {
            switch (filter.FilterType)
            {
            case FilterType.Gain:
                textBoxGainInDB.TextChanged        -= mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged -= mTextBoxGainInAmplitudeChangedEH;

                var gain = filter as GainFilter;
                textBoxGainInDB.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", 20.0 * Math.Log10(gain.Amplitude));
                textBoxGainInAmplitude.Text = string.Format(CultureInfo.CurrentCulture, "{0}", gain.Amplitude);

                textBoxGainInDB.TextChanged        += mTextBoxGainInDbChangedEH;
                textBoxGainInAmplitude.TextChanged += mTextBoxGainInAmplitudeChangedEH;
                break;

            case FilterType.ZohUpsampler:
                var zoh = filter as ZeroOrderHoldUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(zoh.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.ZOH;
                break;

            case FilterType.LowPassFilter:
                var lpf = filter as LowpassFilter;
                textBoxLpfCutoff.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.CutoffFrequency);
                comboBoxLpfLen.SelectedIndex = (int)LpfLenToLpfLenType(lpf.FilterLength);
                textBoxLpfSlope.Text         = string.Format(CultureInfo.CurrentCulture, "{0}", lpf.FilterSlopeDbOct);
                break;

            case FilterType.FftUpsampler:
                var fftu = filter as FftUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(fftu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.FFT;
                comboBoxUpsampleLen.SelectedIndex      = (int)UpsampleLenToUpsampleLenType(fftu.FftLength);
                break;

            case FilterType.Mash2:
                var mash = filter as MashFilter;
                textBoxNoiseShapingTargetBit.Text = string.Format(CultureInfo.CurrentCulture, "{0}", mash.TargetBitsPerSample);
                break;

            case FilterType.NoiseShaping:
                var ns = filter as NoiseShapingFilter;
                textBoxNoiseShapingTargetBit.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", ns.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping2nd;
                break;

            case FilterType.NoiseShaping4th:
                var ns4 = filter as NoiseShaping4thFilter;
                textBoxNoiseShapingTargetBit.Text        = string.Format(CultureInfo.CurrentCulture, "{0}", ns4.TargetBitsPerSample);
                comboBoxNoiseShapingMethod.SelectedIndex = (int)NoiseShapingCbItemType.NoiseShaping4th;
                break;

            case FilterType.TagEdit:
                var te = filter as TagEditFilter;
                comboBoxTagType.SelectedIndex = (int)te.TagType;
                textBoxTagText.Text           = te.Text;
                break;

            case FilterType.Downsampler:
                var ds = filter as Downsampler;
                comboBoxDownsampleOption.SelectedIndex = ds.PickSampleIndex;
                break;

            case FilterType.CicFilter:
                var cic = filter as CicFilter;
                textBoxCicDelay.Text = string.Format(CultureInfo.CurrentCulture, "{0}", cic.Delay);
                break;

            case FilterType.InsertZeroesUpsampler:
                var izu = filter as InsertZeroesUpsampler;
                comboBoxUpsamplingFactor.SelectedIndex = (int)UpsamplingFactorToUpsamplingFactorType(izu.Factor);
                comboBoxUpsamplerType.SelectedIndex    = (int)UpsamplerType.InsertZeroes;
                break;

            case FilterType.HalfbandFilter:
                var hbf = filter as HalfbandFilter;
                textBoxHalfBandFilterTap.Text = string.Format(CultureInfo.CurrentCulture, "{0}", hbf.FilterLength);
                break;

            case FilterType.Crossfeed:
                var cf = filter as CrossfeedFilter;
                textBoxCrossfeedCoefficientFile.Text = cf.FilterFilePath;
                break;
            }
        }