As the title says... Chat on...

User avatar
By SM7I
#49858 Yes, ofcourse...I mean drv:on

Here´s some code:

First the connection to server and retrieval of audiostream.

conn3 = net.createConnection(net.TCP, 10)
conn3:connect(4051, serverip)
conn3:on("receive", function(conn3, audio) buffer=audio end)

Then the PCM part:

drv = pcm.new(pcm.SD, 6)
drv:on("data", buffer)
drv:play(pcm.RATE_8K)

The buffer variable always contain the audio data and can be printed, but not played by PCM module.

If I write the stream to disk, then it can be played by drv:on and with the complement of file.open() and file.read(). However this requires that the file will be closed after writing before reading and that´s not really suitable for me due to delay and loss.
User avatar
By marcelstoer
#49983 I can't test this myself due to lack of hardware but this surprises me:

SM7I wrote:conn3:on("receive", function(conn3, audio) buffer=audio end)


How do you guarantee that you don't play an empty uninitialized buffer? I'd have expected to see something like this instead:

Code: Select allconn3:on("receive", function(conn3, audio)
  drv = pcm.new(pcm.SD, 6)
  drv:on("data", audio)
  drv:play(pcm.RATE_8K)
end)