How to merge / merge MP3 files with C #?

I have a library of different words / phrases, and to create sentences, I am currently adding a combination of these phrases to the playlist to make a sentence. Unfortunately, if a user launches applications with heavy processor use (most users), there may be a few seconds behind the average sentence (between phrases).

To combat this, I was thinking of an approach that will combine the correct combination of MP3 files on the fly into the appropriate phrase, save it in the% temp% directory, and then play this 1 MP3 file, which should overcome the problem that I am encountering with spaces.

What is the easiest way to do this in C #? Is there an easy way to do this? The files are quite small, 3-4 seconds each, and the sentence may consist of 3-20-digit phrases.

+3
source share
4 answers

MP3 files consist of "frames", each of which represents a short fragment (I think about 25 ms) of audio.

So yes, you can just concatenate them without a problem.

+1
source

here is how you can combine MP3 files using NAudio :

public static void Combine(string[] inputFiles, Stream output)
{
    foreach (string file in inputFiles)
    {
        Mp3FileReader reader = new Mp3FileReader(file);
        if ((output.Position == 0) && (reader.Id3v2Tag != null))
        {
            output.Write(reader.Id3v2Tag.RawData, 0, reader.Id3v2Tag.RawData.Length);
        }
        Mp3Frame frame;
        while ((frame = reader.ReadNextFrame()) != null)
        {
            output.Write(frame.RawData, 0, frame.RawData.Length);
        }
    }
}

see here for more information

+5
source

MP3 - , , , . . , , , , . , , .

0

:

copy /b *.mp3 c:\new.mp3

. : #?

-1
source

All Articles