tags:

views:

75

answers:

1

Hi,

I am trying to read bytes from a wav file and send it across to a stream but it plays slowly. Could you please help me to know the right way of populating the byte[]?

Thanks for you help.

A: 

are you using NAudio to both read the WAV file and play the data? you need to make sure you use the same WaveFormat at both ends

Mark Heath
Hi Mark,Thanks for your response. I was trying to get in touch with you. I am happy :)Well, I am trying to intercept mic datarecieved buffer byte[] and pass a new wav file as byte[]. When passing the new sound data as byte[] I am using File.ReadAllBytes.Could you please suggest a good way of sending the byte[] in the right way?
Holly
Hi Mark, WaveStream outStream = new WaveFileReader("test.wav"); outStream = WaveFormatConversionStream.CreatePcmStream(outStream); outStream = new BlockAlignReductionStream(outStream); // reduces choppiness byte[] buffer = new byte[outStream.Length]; outStream.Read(buffer, 0, (int)outStream.Length - 1); Array.Copy(buffer, 0, newSoundByteArray, startIndex, buffer.Length);newSoundByteArray is sent to stream and is playing slow. Waveformat matches.
Holly
how do you go about playing the data?
Mark Heath
In the MicInterceptor class of SkypeFX I assign this newSoundByteArray to args.Buffer and use: bufferStream.SetLatestInBuffer(args.Buffer); //process it out through the effects OutputStream.Read(args.Buffer, 0, args.Buffer.Length); // Playing it back outStream.Write(args.Buffer, 0, args.Buffer.Length); Thanks.
Holly
ok, I didn't realise you were using SkypeFx. Skype plays it itself. You have to provide 16 bit 44.1kHz mono. Convert the audio to that format before passing it back to Skype.
Mark Heath
Thank you for your response. Could you please tell me if I've to do anything else other than the two snippets I just showed? The test.wav is of the same format 16 bit 44.1kHz mono. Please help.
Holly
Hi Mark,I see that both the wave formats match. Mic's format is 16 bit, 44100 sample rate and mono public SkypeBufferStream(int sampleRate) { waveFormat = new WaveFormat(sampleRate, 16, 1); }and test.wav's wave format is also the same. Could you please tell me what I am missing? Thanks
Holly
Hi Mark,It would be great if you could help me with your suggestion.Thanks for your help.
Holly