我如何剪切一段时间的mp3文件并将其转换为使用 N audio 的波形,而不保存硬盘中的任何文件? (我希望得到字节数组!)
答案 0 :(得分:1)
请参阅以下代码:
string nMP3Folder = "FOLDER PATH";
string nMP3SourceFilename = "SOURCE MP3 FILENAME";
string nMP3OutputFilename = "YOUR OUTPUT MP3 FILENAME";
using (Mp3FileReader rdr = new Mp3FileReader(nMP3Folder + nMP3SourceFilename))
{
int count = 1;
Mp3Frame objmp3Frame = reader.ReadNextFrame();
System.IO.FileStream _fs = new System.IO.FileStream(nMP3Folder + nMP3OutputFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write);
while (objmp3Frame != null)
{
if (count > 500) //retrieve a sample of 500 frames
return;
_fs.Write(objmp3Frame.RawData, 0, objmp3Frame.RawData.Length);
count = count + 1;
objmp3Frame = rdr.ReadNextFrame();
}
_fs.Close();
}
另请参阅以下问题以获取更多链接: