private static WaveFileReader GetReader(XConvertJob param) { if (param.SourceData != null) { var mStream = new MemoryStream(param.SourceData.Length); return(new WaveFileReader(mStream)); } return(new WaveFileReader(param.SourceFileName)); }
private static void WmaToWav(XConvertJob param) { var outputFile = param.SourceFileName.ReplaceExtension(XFileType.Wav); //using (var reader = new NAudio.Wa (param.SourceFileName)) //{ // using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader)) // { // WaveFileWriter.CreateWaveFile(outputFile, pcmStream); // } //} }
private static void WavToMp3(XConvertJob param) { var savetofilename = param.SourceFileName.ReplaceExtension(XFileType.Mp3); using (var rdr = GetReader(param)) using (var wtr = new LameMP3FileWriter(savetofilename, rdr.WaveFormat, LAMEPreset.VBR_90)) { rdr.CopyTo(wtr); } param.ResulFileName = savetofilename; }
private static void WmaToMp3(XConvertJob param) { var targetFilename = param.SourceFileName.GenerateOutPutPath(XFileType.Mp3); if (param.SourceData != null) { File.WriteAllBytes(param.SourceFileName, param.SourceData); } using (var reader = new NAudio.Wave.AudioFileReader(param.SourceFileName)) using (var writer = new NAudio.Lame.LameMP3FileWriter(targetFilename, reader.WaveFormat, NAudio.Lame.LAMEPreset.STANDARD)) { reader.CopyTo(writer); } param.ResulFileName = targetFilename; }
internal static void Convert(XConvertJob param) { switch (param.DestinationFileType.Value) { case XFileType.Wav: WmaToWav(param); break; case XFileType.Mp3: WmaToMp3(param); break; default: break; } }
internal static void Convert(XConvertJob param) { switch (param.DestinationFileType.Value) { case XFileType.Mp3: WavToMp3(param); break; case XFileType.Wma: WavToWma(param); break; default: break; } //Finalize(param); }
private static void Mp3ToWav(XConvertJob param) { var outputFile = param.SourceFileName.ReplaceExtension(XFileType.Wav); if (param.SourceData != null) { } else { using (var fs = new FileStream(outputFile, FileMode.Create)) { } } using (var reader = GetReader(param)) { using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader)) { WaveFileWriter.CreateWaveFile(outputFile, pcmStream); } } param.ResulFileName = outputFile; }
private static void WavToWma(XConvertJob param) { throw new NotImplementedException(); }