0

如何在不将任何文件保存在硬盘中的情况下剪切一定时间的 mp3 文件并将其转换为带有N 音频的波形?(我想要字节数组的结果!)

4

1 回答 1

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

另请参阅以下问题以获取更多链接:

以编程方式修剪 MP3

于 2013-04-27T08:36:31.940 回答