:::: MENU ::::

Mixing two mp3 or wav files using NAudio and Lame

NAudio is an open source .NET library which contains a lot of useful audio related classes.
but now here i will use it to mix the mp3 or wave files so that they can be played parallel
with different sound volume like an ordinary sound composer or mixer.

this function encode the wave stream into mp3 stream and returns back

Please follow and like us:

3 Comments

  • Reply Bilal |

    HI,

    I have tried this, but only the background32 file is audible in the final file. I have tried by settings it volume to 0.0f but still not affect.

  • Reply Dev |

    I cannot make use of DMO or ACM, instead I tried using NLayer by replacing the following lines:
    Mp3FileReader mpbacground = new Mp3FileReader(“D:\\song1.mp3”);
    Mp3FileReader mpMessage = new Mp3FileReader(“D:\\song2.mp3”);

    With:
    var builderBackground = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
    var builderMessage = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
    Mp3FileReader mpbacground = new Mp3FileReader(ThumbAudioMP3, builderBackground);
    var builderBackground = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
    var builderMessage = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
    Mp3FileReader mpbacground = new Mp3FileReader(ThumbAudioMP3, builderBackground);
    Mp3FileReader mpMessage = new Mp3FileReader(stream, builderMessage);
    Mp3FileReader mpMessage = new Mp3FileReader(stream, builderMessage);

    I am skipping the lines below because they give an error: NoDriver calling acmFormatSuggest error
    WaveStream background = WaveFormatConversionStream.CreatePcmStream(mpbacground);
    WaveStream message = WaveFormatConversionStream.CreatePcmStream(mpMessage);

    I tried going directly to
    var messageOffsetted = new WaveOffsetStream(mpMessage…..)

    but that gives me the error: Only PCM supported. Any suggestions?

So, what do you think ?