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!"); } }
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(); }
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(); }
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!"); }