Hello Mark,
Thank you for the reply.. I was able to modify your code to convert live RTP stream into WAV. I also used your CreatePcmStream method to convert the RTP packets into PCM stream and then dynamically wrote that PCM stream into a wav file updating the header everytime I write new data because in my case the requirement is to play the live WAV file as it gets generated. At this point I have couple of questions if you can please provide some insight:
1) The WAV file that I have generated is using the MuLaw WAV format i.e. WaveFormat.CreateMuLawFormat(8000, 1). Even though the WAV file is generated properly I get a clicking throughout the audio play. I verified that the RTP packets are received in proper sequence and none of them are lost. So I am getting a valid RTP stream. However while conversion to PCM something is happening and the WAV file plays with clicking sound throughout. On the other hand I have tried getting this same audio file converted into WAV through another medium and it plays fine. When I compared the WAV headers here is the diff that I saw:
The correct WAV file header:
channels: 2
sampleRate: 11025
fmtAvgBPS: 44100
fmtBlockAlign: 4
bitDepth: 16
The WAV file header generated using your code:
channels: 1
sampleRate: 8000
fmtAvgBPS: 16000
fmtBlockAlign: 2
bitDepth: 16
I believe the correct WAV file is generated in stereo mode with 2 channels. So I tried creating a new wavformat as follows:
WaveFormat waveformat = new WaveFormat(44100, 16, 2);
But when I do this the stream is no longer converted into PCM and it is directly written into WAV file which is not a valid output. So is there any way I can improve the quality of my WAV file? Is there a way to create PCM stream using different WAV formats through your code?
2) Also, what is the best way to convert RTP into WAV? Do we always have to go via the PCM route? What would be the best route in my case?
Thank you..
Regards,
Saleh
Thank you for the reply.. I was able to modify your code to convert live RTP stream into WAV. I also used your CreatePcmStream method to convert the RTP packets into PCM stream and then dynamically wrote that PCM stream into a wav file updating the header everytime I write new data because in my case the requirement is to play the live WAV file as it gets generated. At this point I have couple of questions if you can please provide some insight:
1) The WAV file that I have generated is using the MuLaw WAV format i.e. WaveFormat.CreateMuLawFormat(8000, 1). Even though the WAV file is generated properly I get a clicking throughout the audio play. I verified that the RTP packets are received in proper sequence and none of them are lost. So I am getting a valid RTP stream. However while conversion to PCM something is happening and the WAV file plays with clicking sound throughout. On the other hand I have tried getting this same audio file converted into WAV through another medium and it plays fine. When I compared the WAV headers here is the diff that I saw:
The correct WAV file header:
channels: 2
sampleRate: 11025
fmtAvgBPS: 44100
fmtBlockAlign: 4
bitDepth: 16
The WAV file header generated using your code:
channels: 1
sampleRate: 8000
fmtAvgBPS: 16000
fmtBlockAlign: 2
bitDepth: 16
I believe the correct WAV file is generated in stereo mode with 2 channels. So I tried creating a new wavformat as follows:
WaveFormat waveformat = new WaveFormat(44100, 16, 2);
But when I do this the stream is no longer converted into PCM and it is directly written into WAV file which is not a valid output. So is there any way I can improve the quality of my WAV file? Is there a way to create PCM stream using different WAV formats through your code?
2) Also, what is the best way to convert RTP into WAV? Do we always have to go via the PCM route? What would be the best route in my case?
Thank you..
Regards,
Saleh