Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Getting realtime ASIO audio and sending over TCP

$
0
0
Hello,

I am trying to get the ASIO audio input so that I can stream via TCP. I have it working well with the WaveIn, but I'm only receiving static on the TCP client when I try the same thing with ASIO.
 void asioOut_AudioAvailable(object sender, AsioAudioAvailableEventArgs e)
        {
            if (s == null)
            {
                s = myList.AcceptSocket();
            }
                
                var samples = e.GetAsInterleavedSamples();

//lame attempt to convert to byte array
            var byteArray = new byte[samples.Length * 4];
            Buffer.BlockCopy(samples, 0, byteArray, 0, byteArray.Length);
//////

            byte[] encoded = codec.Encode(byteArray, 0, byteArray.Length);
            s.Send(encoded, SocketFlags.None);


            writer.WriteSamples(samples, 0, samples.Length);
        }
I think my problem is 2 fold:
  • the AsioSampleType is being set as int32LSB - I believe I need this as a 16 bit file. Do I have to dither this on the fly before sending?
  • Also, the e.GetAsInterleavedSamples(); is returning as a float array. How I convert to byte array?
The WriteSample is writing the recording to a .wav file, so I know I have my input working.

Thanks! Having a lot of fun experimenting with this.

-Mike

Viewing all articles
Browse latest Browse all 5831

Latest Images

Trending Articles



Latest Images