I’m new with NAudio and I need to achieve following:
I have a sip Event that return to me an uint rtp buffer that I convert in byte[] Chunk with following code:
rtpChunk = new byte[buflen];
Marshal.Copy(buf, rtpChunk, 0, buflen);
I have one other bytes[] chunk of background music.
var backChunk = new byte[buflen];
Array.Copy(bot.BackgroundBuffer, bot.BackgroundBufferIndex, backChunk, 0, buflen);
I need to mix together and retrieve the mixed chunk in byte[] and send back as uint rtp packet with following code:
Marshal.Copy(mixedChunk, 0, buf, buflen);
So how can I achieve with NAudio:
byte[] mixedChunk = MixChunks(rtpChunk, backChunk);
P.S: The sample Rate, Bits, Channel are equals for bought chunks:
8000, 16, 1
Thank you for help, Piercarlo
Dears, thanking for suggestions, I searched and I adapted some source code found on NAudio github repository to achieve my goal, so I post the solution that is working, may be will be usefull for some other else.
I premise that this code is handling only Raw Audio bytes, if you want to save the result on a ".wav" file you need to add the Header.
Method is the following: