Exemple #1
0
        public FlacReader(string input, WavWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException("WavWriter");
            }

            stream = File.OpenRead(input);
            reader = new BinaryReader(stream);
            writer = output;

            context = FLAC__stream_decoder_new();

            if (context == IntPtr.Zero)
            {
                throw new ApplicationException("FLAC: Could not initialize stream decoder!");
            }

            write    = new WriteCallback(Write);
            metadata = new MetadataCallback(Metadata);
            error    = new ErrorCallback(Error);

            if (FLAC__stream_decoder_init_file(context,
                                               input, write, metadata, error,
                                               IntPtr.Zero) != 0)
            {
                throw new ApplicationException("FLAC: Could not open stream for reading!");
            }
        }
Exemple #2
0
        public static void run(string inputFile, string outputFile)
        {
            Debug.Assert(Path.GetExtension(inputFile).ToLowerInvariant() == ".flac");

            if (!File.Exists(inputFile))
            {
                throw new ApplicationException("Input file " + inputFile + " cannot be found!");
            }

            using (WavWriter wav = new WavWriter(outputFile))
                using (FlacReader flac = new FlacReader(inputFile, wav))
                    flac.Process();
        }