public Controller()
 {
     curFilter = DFMFilter.delayFilter;
     curSignal = 2 * DFMSignal.PeriodicSignal2 + DFMSignal.PeriodicSignal3;
     maxLength = 8;
     Reload();
 }
        public void LoadFilter(string path, Controller controller)
        {
            DFMFilter filter = LoadFilterFromFile(path);

            SaveFilter(filter);
            GetSavedFilters();
            controller.CurFilter = filter;
        }
 void SaveFilter(DFMFilter filter)
 {
     string[] lines = new string[3];
     lines[0] = "Filter " + filter.Name;
     lines[1] = filter.UpperCoefsString;
     lines[2] = filter.LowerCoefsString;
     File.WriteAllLines(FilterDir + @"\" + filter.Name, lines);
 }
Exemple #4
0
        static DFMFilter()
        {
            DFMCoefList upper1 = new DFMCoefList(1, 0);
            DFMCoefList upper2 = new DFMCoefList(2);
            DFMCoefList upper3 = new DFMCoefList(0, 1);
            DFMCoefList upper4 = new DFMCoefList(0.5, 0.5);
            DFMCoefList lower1 = new DFMCoefList(1, 0);
            DFMCoefList lower2 = new DFMCoefList(1, -0.5);

            identityFilter = new DFMFilter(upper1, lower1);
            doublingFilter = new DFMFilter(upper2, lower1);
            delayFilter    = new DFMFilter(upper3, lower1);
            fadeFilter     = new DFMFilter(upper1, lower2);
            avg2Filter     = new DFMFilter(upper4, lower1, "Average2");
        }
        DFMFilter LoadFilterFromFile(string path)
        {
            string[] lines = File.ReadAllLines(path);
            if (!lines[0].ToLower().StartsWith("filter "))
            {
                throw new FileFormatException("File is not formatted as a filter file");
            }
            string[] namelines = lines[0].Split(' ');
            string   name      = namelines[1];

            string[]    uppernums = lines[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            DFMCoefList upper     = new DFMCoefList(uppernums.Select(x => double.Parse(x)).ToArray());

            string[]    lowernums = lines[2].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            DFMCoefList lower     = new DFMCoefList(lowernums.Select(x => double.Parse(x)).ToArray());

            if (lower[0] == 0)
            {
                throw new ArgumentException("First denominator coefficient can't be 0");
            }
            DFMFilter filter = new DFMFilter(upper, lower, name);

            return(filter);
        }