This project has moved and is read-only. For the latest updates, please go here.

WasapiLoopback to 16bit?

Jul 25, 2013 at 9:43 AM
How to i convert WasapiLoopback to 16bit?

I know NAudio got something like this built in, but i don´t know how to use it for this.

Jul 26, 2013 at 2:04 PM
there isn't a one-liner as it really depends what you are doing next with the audio (e.g. writing to file, putting into a buffered wave provider). The manual way is use BitConverter.ToSingle on every four bytes, and then multiply by Int16.MaxValue to make it into an Int16.
Jul 26, 2013 at 2:07 PM
I want to use it as sending through udp.
Like a waveinevent,

udpClient.Send(e.Buffer, e.BytesRecorded, otherPartyIP.Address.ToString(), 1500);

I want to do like that, but i need to change it to 16 bit right before that.

Jul 26, 2013 at 2:14 PM
then I'd just use the technique I mentioned above then. You can speed it up using WaveBuffer if you know how. Bind a WaveBuffer to the recorded byte array and you can access each sample individually. Then convert them all to shorts my multiplying by Int16.MaxValue and writing into a new buffer to be sent over UDP. WaveBuffer can help you again there letting you write shorts into a byte array
Jul 26, 2013 at 2:27 PM
Well this is way beyond me, will have to read up on this.
I can see what you are saying, but i can´t understand it (new to c#), but hopefully it will get me somewhere.