I am very new to audio or mp3 stuff, was looking for a way to have a feature to split an mp3 file in C#, asp.net. After googling for a good 3-day without much of a great help, I am hoping that somebody here can point me to a right direction.
Can I use NAudio to accomplish this? Is there any sample code for that? Thanks in advance.
An MP3 File is made up of a sequence of MP3 frames (plus often ID3 tags on the beginning and end). The cleanest way to split an MP3 file then is to copy a certain number of frames into a new file (and optionally bring the ID3 tags along too if that is important).
NAudio's MP3FileReader
class features a ReadNextFrame
method. This returns an MP3Frame
class, which contains the raw data as a byte array in the RawData
property. It also includes a SampleCount
property which you can use to accurately measure the duration of each MP3 Frame.