Erel's Walkie-Talkie example is a very nice simple example for Android <--> Android voice.
I'm trying to implement a PC <--> Android version with the same Android application Erel posted.
Using the NAudio library on the PC seems to be the simplest way to do this, let me know if you think otherwise.
For starters I'm just trying to get PC --> Android direction audio working, but am having the android application crash out after a second with an Out Of Memory exception every time the PC application starts streaming bytes to it, within about a second.
Below is my PC side VB.net code which is performing the socket connection and audio streaming.
Any thoughts or ideas most welcome!
I'm trying to implement a PC <--> Android version with the same Android application Erel posted.
Using the NAudio library on the PC seems to be the simplest way to do this, let me know if you think otherwise.
For starters I'm just trying to get PC --> Android direction audio working, but am having the android application crash out after a second with an Out Of Memory exception every time the PC application starts streaming bytes to it, within about a second.
B4X:
java.lang.OutOfMemoryError
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:172)
at java.lang.Thread.run(Thread.java:856)
Below is my PC side VB.net code which is performing the socket connection and audio streaming.
B4X:
Public Class Form1
Dim WithEvents AudioIn As New NAudio.Wave.WaveIn()
Dim SocketOut As New Net.Sockets.TcpClient
Dim NetworkStreamOut As Net.Sockets.NetworkStream
Private Sub btnConnect_Click(sender As System.Object, e As System.EventArgs) Handles btnConnect.Click
AudioIn.DeviceNumber = 0 ' PC Microphone
AudioIn.WaveFormat = New NAudio.Wave.WaveFormat(22050, 16, 1) ' Sample Rate, Bits per Sample, Channels
SocketOut.Connect("192.168.0.14", 21341) ' Android Device IP
Do While Not SocketOut.Connected
Application.DoEvents()
Loop
AudioIn.StartRecording()
NetworkStreamOut = SocketOut.GetStream
End Sub
Private Sub AudioIn_DataAvailable(sender As Object, e As NAudio.Wave.WaveInEventArgs) Handles AudioIn.DataAvailable
If e.Buffer.Length > 0 Then
NetworkStreamOut.Write(e.Buffer, 0, e.Buffer.Length)
NetworkStreamOut.Flush()
End If
End Sub
End Class
Any thoughts or ideas most welcome!