Ejemplo n.º 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!");
            }
        }
Ejemplo n.º 2
0
        public static void DecodeFlacToWav(string inputFilePath, string outputFilePath)
        {
            // FLAC -> WAV
            if (!File.Exists(inputFilePath))
                throw new ApplicationException("Input file " + inputFilePath + " cannot be found!");

            using (WavWriter wav = new WavWriter(outputFilePath))
            using (FlacReader flac = new FlacReader(inputFilePath, wav))
                flac.Process();
        }
Ejemplo n.º 3
0
        public static void DecodeFlacToWav(string inputFilePath, string outputFilePath)
        {
            // FLAC -> WAV
            if (!File.Exists(inputFilePath))
            {
                throw new ApplicationException("Input file " + inputFilePath + " cannot be found!");
            }

            using (WavWriter wav = new WavWriter(outputFilePath))
                using (FlacReader flac = new FlacReader(inputFilePath, wav))
                    flac.Process();
        }
Ejemplo n.º 4
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!");
        }