0

I’m working to VOIP Windows Phone project (Soft-phone application for Windows Phone). At the present, I (Windows phone soft-phone) can receive and heard voice of another soft-phone, only ONE-WAY. I can send my voice (RTP packets) to another soft-phone, but it contains full noise. I followed this http://www.codeproject.com/Articles/14237/Using-the-G711-standard?msg=2573223#xx2573223xx to encode and decode RTP packet between U-law and PCM. The decoding function worked well with me, but encoding didn’t.

I decoded RTP packet and play it with sample rate is 8000Khz (it is sample rate of U-law format). Here's my code to play it :

SoundEffect soundEffect = new SoundEffect(buffer, 8000, AudioChannels.Mono);
SoundEffectInstance soundInstance = soundEffect.CreateInstance();
soundInstance.Play();

And about encoding, I used microphone of Windows Phone to record voice=>encode to U-Law format=>put into RTP packet=>Send. But these packets contain full noise and another soft-phone (destination call) only receive noise and noise.

The format of recorded data of microphone is : PCM 16 bit - 16KHz. Do you have any solutions to help me to solve it?

Regards and thank you a lot.

hthoang88
  • 1
  • 3
  • where's your code to handle the capture and encoding? – Rowland Shaw May 04 '12 at 10:53
  • Here's how to do it on Windows 7 http://sipsorcery.codeplex.com/SourceControl/changeset/view/73596#1316981 although I don't know if that will be particularly useful to you since you won't be able to use the NAudio library on WP7. – sipsorcery May 04 '12 at 12:44
  • @hthoang88 : were you able to make use of Microphone framework to record the audio, i am doing the same thing and my server supports rate is 20ms, and going through Microphone documentation, the buffer rate should be 100ms to 1000ms , how you were able to get 320 sample – Amitg2k12 Nov 22 '12 at 12:32

1 Answers1

0

@Rowland: I used microphone of WP to capture data

public Microphone microphone = Microphone.Default;     
private byte[] buffer; 
Queue<byte[]> recordedVoice = new Queue<byte[]>(); 

It will get 320byte for each time

microphone.GetData(buffer);    

and i saved it into a Queue

recordedVoice.Enqueue(buffer);

Then I'll encode each item of recordedVoice to U-Law format (Encoding function referenced from http://www.codeproject.com/Articles/14237/Using-the-G711-standard?msg=2573223#xx2573223xx ) :

byte[] encoded = G711MuLaw.G711MuLawEncode(recordedVoice.Dequeue());

But it didn't encode correctly.

@sipwiz : I thinh NAudio don't support for WP7, because it'a C# project, not Silverlight.

@Rowland & sipwiz : I'm so happy when received your responses, thank you a lot.

hthoang88
  • 1
  • 3