I created a TCP Audio Chat(Basic) ...
It works for about 1 second, then it say buffer full
I wish to use this as a tablet to front Door tablet Intercom
Server
WaveIn waveIn = new WaveIn();
waveIn.BufferMilliseconds = 50;
waveIn.DeviceNumber = 0;
waveIn.WaveFormat = new WaveFormat(44100, 1);
waveIn.DataAvailable += WaveIn_DataAvailable;
waveIn.StartRecording();
private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
{
try
{
byte[] decodedData = null;
decodedData = G711.Encode_aLaw(e.Buffer, 0, e.Buffer.Length);
Stream.Write(decodedData, 0, decodedData.Length);
}
catch (Exception ex)
{
}
}
>
Client
<
WaveOut waveOut;
WaveIn sourceStream;
waveOut = null;
sourceStream = null;
waveOut = new WaveOut();
sourceStream = new WaveIn();
sourceStream.BufferMilliseconds = 50;
sourceStream.DeviceNumber = 0;
sourceStream.WaveFormat = new WaveFormat(44100, 1);
waveProvider = new BufferedWaveProvider(sourceStream.WaveFormat);
waveOut.Init(waveProvider);
waveOut.Play();
byte[] decodedData = null;
byte[] bytes = new byte[1024];
try
{
while(true)
{
textBox1.AppendText(Encoding.ASCII.GetString(bytes, 0, bytes.Length));
stream.Read(bytes, 0, bytes.Length);
decodedData = G711.Decode_aLaw(bytes, 0, bytes.Length);
waveProvider.AddSamples(decodedData, 0, decodedData.Length);
}
}catch(Exception ex) { }
The problem is the buffer bytes ...
What I have tried:
I have tried many version of this including using
sourceStream.DataAvailable += SourceStream_DataAvailable;
No joy
I hope there a solution ...