本文整理匯總了C#中NAudio.Wave.Mp3FileReader.CopyTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Mp3FileReader.CopyTo方法的具體用法?C# Mp3FileReader.CopyTo怎麽用?C# Mp3FileReader.CopyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NAudio.Wave.Mp3FileReader
的用法示例。
在下文中一共展示了Mp3FileReader.CopyTo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MP3ToWav
/// <summary>
/// Convert MP3 file to WAV using NAudio classes only
/// </summary>
/// <param name="mp3FileName">MP3 filename</param>
/// <param name="waveFileName">WAV filename</param>
public static void MP3ToWav(string mp3FileName, string waveFileName)
{
using (var reader = new Mp3FileReader(mp3FileName))
using (var writer = new WaveFileWriter(waveFileName, reader.WaveFormat))
reader.CopyTo(writer);
}
示例2: Mp3ToPcm
public RawAudioData Mp3ToPcm(string fileName)
{
var resStream = new MemoryStream();
var result = new RawAudioData();
if (File.Exists(fileName))
{
using (var mp3 = new Mp3FileReader(fileName))
{
var frame0 = mp3.ReadNextFrame();
result.SampleRate = frame0.SampleRate;
result.BitRate = frame0.BitRate;
mp3.Seek(0, SeekOrigin.Begin);
mp3.CopyTo(resStream);
}
}
result.Data = resStream.ToArray();
return result;
}