/// <summary> /// Combines files into one in the order they are passed in.. /// </summary> /// <param name="bufferMultiplier">The multiplier to use against the OptimalBufferSize of the file for the read buffer, sometimes a larger than optimal buffer size is better.</param> /// <param name="filepaths">The file paths to combine</param> /// <param name="outputStream">The stream to save the combined file to.</param> public static void Combine(Stream outputStream, int bufferMultiplier, params string[] filepaths) { var inputStreams = new Stream[filepaths.Length]; for (var i = 0; i < filepaths.Length; i++) { inputStreams[i] = new WmaStreamReader(filepaths[i]); } Combine(outputStream, bufferMultiplier, inputStreams); }
private static void WriteFile(Mp3Writer wmaOutput, WmaStreamReader wmaInput, byte[] buffer, long stopPosition) { if (stopPosition == -1) { stopPosition = wmaInput.Length + 1; } int read; //Read the file until we hit our stop position, or the end of the file. while (wmaInput.Position < stopPosition && (read = wmaInput.Read(buffer, 0, buffer.Length)) > 0) { wmaOutput.Write(buffer, 0, read); } }
private static void WriteFile(Mp3Writer wmaOutput, WmaStreamReader wmaInput, byte[] buffer) { WriteFile(wmaOutput, wmaInput, buffer, -1); }
private static void WriteFile(WmaWriter wmaOutput, WmaStreamReader wmaInput, byte[] buffer, long stopPosition) { if (stopPosition == -1) { stopPosition = wmaInput.Length + 1; } int read; //Read the file until we hit our stop position, or the end of the file. while (wmaInput.Position < stopPosition && (read = wmaInput.Read(buffer, 0, buffer.Length)) > 0) { wmaOutput.Write(buffer, 0, read); } }
private static void WriteFile(WmaWriter wmaOutput, WmaStreamReader wmaInput, byte[] buffer) { WriteFile(wmaOutput, wmaInput, buffer, -1); }
public static void WmaToMp3(Stream wmaInputStream, Stream outputStream, Mp3WriterConfig mp3Format, int bufferMultiplier) { WmaToMp3Delegate convert = wmaStream => { var writer = new Mp3Writer(outputStream, mp3Format ?? new Mp3WriterConfig(wmaStream.Format, new BE_CONFIG(wmaStream.Format))); var buffer = new byte[writer.OptimalBufferSize*bufferMultiplier]; WriteToStream(writer, wmaStream, buffer); }; var tempStream = wmaInputStream as WmaStreamReader; if (tempStream != null) { convert(tempStream); } else { using (var wmaStream = new WmaStreamReader(wmaInputStream)) { convert(wmaStream); } } }
public static void WmaToWma( string wmafilePath, Stream outputStream, WmaWriterConfig wmaFormat, int bufferMultiplier) { using (var wmaStream = new WmaStreamReader(wmafilePath)) { var writer = new WmaWriter(outputStream, wmaFormat); var buffer = new byte[writer.OptimalBufferSize*bufferMultiplier]; WriteToStream(writer, wmaStream, buffer); } }