Пример #1
0
        /// <summary>
        /// Set the Denoise control
        /// </summary>
        /// <param name="value">
        /// The value part of the CLI string
        /// </param>
        /// <param name="custom">
        /// The custom denoise setting.
        /// </param>
        public void SetDeNoise(Denoise value, string custom)
        {
            text_customDN.Text    = string.Empty;
            text_customDN.Visible = false;
            switch (value)
            {
            case Denoise.Off:
                drop_denoise.SelectedIndex = 0;
                break;

            case Denoise.Weak:
                drop_denoise.SelectedIndex = 2;
                break;

            case Denoise.Medium:
                drop_denoise.SelectedIndex = 3;
                break;

            case Denoise.Strong:
                drop_denoise.SelectedIndex = 4;
                break;

            default:
                drop_denoise.SelectedIndex = 1;
                text_customDN.Text         = custom;
                text_customDN.Visible      = true;
                break;
            }
        }
Пример #2
0
 /// <summary>
 /// 填充参数
 /// </summary>
 /// <param name="args">原有参数</param>
 /// <returns>填充后的参数</returns>
 public virtual Dictionary <string, string> FillArgs(Dictionary <string, string> args)
 {
     if (args == null)
     {
         args = new Dictionary <string, string>();
     }
     if (FenceId > 0)
     {
         args["fence_id"] = FenceId.ToString();
     }
     if (string.IsNullOrWhiteSpace(FenceName) == false)
     {
         args["fence_name"] = FenceName;
     }
     if (string.IsNullOrWhiteSpace(MonitoredPerson) == false)
     {
         args["monitored_person"] = MonitoredPerson;
     }
     args["coord_type"] = CoordType.ToString();
     if (Denoise > 0)
     {
         args["denoise"] = Denoise.ToString();
     }
     return(args);
 }
Пример #3
0
 //feed the filters with data input
 public void Feed(double input)
 {
     if (Reset)
     {
         //reset filter memory
         Trend.output   = input;
         Denoise.output = input;
         Tilt.output    = input;
         Reset          = false;
     }
     Trend.Feed(input); Denoise.Feed(input); Tilt.Feed(input);
     Smooth = Tilt.output - Trend.output;
     Sudden = Denoise.output - Tilt.output;
 }
        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="values">
        /// The values.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Any() && values.Count() == 2)
            {
                Denoise denoiseChoice = (Denoise)values[1];

                if (denoiseChoice == Denoise.hqdn3d)
                {
                    return(new List <DenoisePreset> {
                        DenoisePreset.Weak, DenoisePreset.Medium, DenoisePreset.Strong, DenoisePreset.Custom
                    });
                }

                if (denoiseChoice == Denoise.NLMeans)
                {
                    return(new List <DenoisePreset> {
                        DenoisePreset.Ultralight, DenoisePreset.Light, DenoisePreset.Medium, DenoisePreset.Strong, DenoisePreset.Custom
                    });
                }
            }

            return(Enumerable.Empty <DenoisePreset>());
        }
Пример #5
0
 /// <summary>
 /// Set the Denoise control
 /// </summary>
 /// <param name="value">
 /// The value part of the CLI string
 /// </param>
 /// <param name="custom">
 /// The custom denoise setting.
 /// </param>
 public void SetDeNoise(Denoise value, string custom)
 {
     text_customDN.Text = string.Empty;
     text_customDN.Visible = false;
     switch (value)
     {
         case Denoise.Off:
             drop_denoise.SelectedIndex = 0;
             break;
         case Denoise.Weak:
             drop_denoise.SelectedIndex = 2;
             break;
         case Denoise.Medium:
             drop_denoise.SelectedIndex = 3;
             break;
         case Denoise.Strong:
             drop_denoise.SelectedIndex = 4;
             break;
         default:
             drop_denoise.SelectedIndex = 1;
             text_customDN.Text = custom;
             text_customDN.Visible = true;
             break;
     }
 }
Пример #6
0
        private void InitDataProcessors()
        {
            try
            {
                var featParams = Loader.Properties;
                SelectedDataProcessors = new List <IDataProcessor>();

                double lowFreq   = double.Parse(featParams["-lowerf"], CultureInfo.InvariantCulture.NumberFormat);
                double hiFreq    = double.Parse(featParams["-upperf"], CultureInfo.InvariantCulture.NumberFormat);
                int    numFilter = int.Parse(featParams["-nfilt"], CultureInfo.InvariantCulture.NumberFormat);

                // TODO: should not be there, but for now me must preserve
                // backward compatibility with the legacy code.
                if (Loader is KaldiLoader)
                {
                    FilterBank = new MelFrequencyFilterBank2(lowFreq, hiFreq, numFilter);
                }
                else
                {
                    FilterBank = new MelFrequencyFilterBank(lowFreq, hiFreq, numFilter);
                }

                SelectedDataProcessors.Add(FilterBank);

                if ((featParams.get("-remove_noise") == null) || (featParams.get("-remove_noise").Equals("yes")))
                {
                    Denoise = new Denoise(
                        typeof(Denoise).GetField <S4Double>("LambdaPower").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaA").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaB").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("LambdaT").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("MuT").DefaultValue,
                        typeof(Denoise).GetField <S4Double>("MaxGain").DefaultValue,
                        typeof(Denoise).GetField <S4Integer>("SmoothWindow").DefaultValue);

                    // denoise.newProperties();
                    Denoise.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                    SelectedDataProcessors.Add(Denoise);
                }

                if ((featParams.get("-transform") != null) &&
                    (featParams.get("-transform").Equals("dct")))
                {
                    Dct = new DiscreteCosineTransform2(
                        numFilter,
                        typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                else if ((featParams.get("-transform") != null) &&
                         (featParams.get("-transform").Equals("kaldi")))
                {
                    Dct = new KaldiDiscreteCosineTransform(numFilter, typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                else
                {
                    Dct = new DiscreteCosineTransform(numFilter, typeof(DiscreteCosineTransform).GetField <S4Integer>("PropCepstrumLength").DefaultValue);
                }
                Dct.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                SelectedDataProcessors.Add(Dct);

                if (featParams.get("-lifter") != null)
                {
                    Lifter             = new Lifter(int.Parse(featParams.get("-lifter"), CultureInfo.InvariantCulture.NumberFormat));
                    Lifter.Predecessor = SelectedDataProcessors[SelectedDataProcessors.Count - 1];
                    SelectedDataProcessors.Add(Lifter);
                }


                this.LogInfo("Cepstrum component auto-configured as follows: " + ToString());
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }
        }