Exemplo n.º 1
0
        public DsdiffProcessor(DsdiffReader reader, DsdiffWriter writer, DsdiffFilters filters)
        {
            _dsdiffReader  = reader;
            _dsdiffWriter  = writer;
            _dsdiffFilters = filters;

            InitBitTranslator();
        }
Exemplo n.º 2
0
        public void Process()
        {
            Console.WriteLine("> Processing DSD file: {0}", Path.GetFileName(InputFile));

            try
            {
                if (InputLogFile != "")
                {
                    try
                    {
                        Console.WriteLine("> Writing log for input file into: {0}", InputLogFile);
                        var result = Analysis.GetFileResponse(InputFile, InfoFile, 1024);

                        var logOutFile = new StreamWriter(InputLogFile);

                        foreach (var r in result)
                        {
                            logOutFile.Write("{0};{1}\n", r.Item1, r.Item2);
                        }

                        logOutFile.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: Unable to write input file log - " + ex.Message + "\n" + ex.StackTrace);
                    }
                }

                if (LogOnly.ToLower() == "true")
                {
                    return;
                }

                // Reader
                var inFileStream = File.Open(InputFile, FileMode.Open);

                var reader = new DsdiffReader(inFileStream);

                if (reader.CompressionType != "DSD ")
                {
                    throw new Exception("Invalid compression type - only DSD files supported");
                }

                if (reader.ChannelsCount != 2)
                {
                    throw new Exception(
                              string.Format("Invalid number of channels in DSDIFF file: {0}. Only 2-channel files supported",
                                            reader.ChannelsCount));
                }

                // Writer
                var outFileStream = File.Open(OutputFile, FileMode.Create);

                using (var filters = new DsdiffFilters(ConfigFile, 2822400))
                    using (var writer = new DsdiffWriter(outFileStream, (ushort)filters.Count))
                        using (var processor = new DsdiffProcessor(reader, writer, filters))
                        {
                            //_globalProcessor = processor;
                            processor.Go();
                        }

                //_globalProcessor = null;

                inFileStream.Close();
                inFileStream.Dispose();

                outFileStream.Close();
                outFileStream.Dispose();

                Console.WriteLine("Successfully shutted down\n");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }