I'm new in c# and i want to send voice over ip but I have a problem here.
private Byte[] arr;
private void send()
{
arr = File.ReadAllBytes("wave path");
con = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// ...
con.Send(arr, 0, arr.length, 0);
con.Close();
}
Now its ok i can convert wave to byte by
File.ReadAllBytes("wave path");
But actually I want to send wave from microphone Directly (not from wave File)
So I use NAudio.dll
for record audio and this is the code
private void button2_Click(object sender, EventArgs e)
{
int devicenum = 0;
sourcestream = new NAudio.Wave.WaveIn();
sourcestream.DeviceNumber = devicenum;
sourcestream.WaveFormat = new NAudio.Wave.WaveFormat(4410, NAudio.Wave.WaveIn.GetCapabilities(devicenum).Channels);
NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourcestream);
waveOut = new NAudio.Wave.DirectSoundOut();
waveOut.Init(waveIn);
sourcestream.StartRecording();
waveOut.Play();
}
and i test it its play audio from microphone
how can i convert waveOut
to array byte so i can send it
waveOut.Play();
I found some videos write audio to wave file and again read byte from file. Any way to convert audio Directly to array byte?