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

User avatar
By SM7I
#49782 Hi !

I´m creating a solution for the NodeMCU where it will stream TCP data fron a server. This is actually an audiostream from an hamradio station.

This works fine if I put the recieved stream into a file on spiffs and then fire up the PCM module to read the file and play it.

However this is not really what I want to do. I want the PCM module to, more or less, in realtime play the stream. But, and this is my problem, when I fire up the PCM module to read from a string then no sound is heard.

I get the feeling that PCM module is limited to read datafiles directly from spiffs and not from variables containing the same datastring as what the file contains.

Can somebody please help me out to a solution, or confirm my suspicion on this ?

I would be very happy if PCM could support reading from a variable as well...this would solve my problem...
User avatar
By marcelstoer
#49790 I suspect you were following our example at https://github.com/nodemcu/nodemcu-firm ... y_file.lua, right? And then rather than reading from file in drv:on("data", file.read) you'd read from your "custom" stream?
User avatar
By SM7I
#49817 Yes, I did follow the documentation regarding the PCM module and how to use it.

To straighten up any questionmarks I´ll basically draft the steps I did:

First test was just to read a binary file from spiffs. That file was stored on spiffs by recieving a TCP stream of audiodata from my server.
That went well to play with the PCM module by opening and reading the file, then using the filename as parameter to drv:play

Second test was to recieve another TCP stream of audiodata, but instead putting it into a variable. The variable stored the audiodata fine, but using the variable as parameter to drv:play, instead of a filename, didn´t work. No errors or such, the PCM module would simply not put out any audio,

Any idea how to solve this ?
User avatar
By marcelstoer
#49835 Why don't you show us some code? I'm a bit confused by your statement "using the filename as parameter to drv:play" because the only parameter drv:play supports is the sample rate. The key to me seems that you replace

Code: Select alldrv:on("data", file.read)

with
Code: Select alldrv:on("data", your-own-function-that-returns-a-chunk-of-data-from-your-variable)