Sending live audio broadcast from INMP441 to MQTT Server. #989
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 18 replies
-
I dont have any experience with mqtt but I would not see any issues. Mqtt clients usually implement the stream api, so you can just use it as copy target. Just make sure that you stay within the limits if the protocol. I suggest to encode it as wav, keep the channels at 1 and the sample rate low e.g at 8000, so that you know what you get on the target. Maybe you just overlooked the issues with this microphone? |
Beta Was this translation helpful? Give feedback.
-
I added a simple example that sends white noise using the Arduino ArduinoMqttClient library. Adapting this to your library and to a different audio source should be trivial |
Beta Was this translation helpful? Give feedback.
-
Your mqttClient.read() will completely mess up the audio data. After all that's what the copier.copy() is supposed to do. I would not recommend to process the playing of the audio in the callback, but rather move it to the loop and process it with individual copy() commands there... |
Beta Was this translation helpful? Give feedback.
-
Yes you are right, the callback function is not needed for copier to work. The poll is required to keep the broker connected though. Since it is familiar with the client.loop() function of the pubsubclient mqtt library I was previously working with.
|
Beta Was this translation helpful? Give feedback.
-
But that's completely wrong! Copy needs to be from the MQTTClient to the EncodedAudioStream which has I2SStream as output! |
Beta Was this translation helpful? Give feedback.
-
So, this one worked for me on the speaker. After some testing, I have found that it works best with min delay on 8000 sampling rate and chunk size 32768 on the python side where I send wav audio from mic. Also it works better when I use the local mqtt broker server on my pc instead of the remote VPS server where the mosquitto mqtt broker was originally installed. The audio is played after 4-5 secs after sending from mic.
|
Beta Was this translation helpful? Give feedback.
-
Your logic works only correctly when you know the data size in advance. So your issue actually comes from ignoring my documentation: https://github.com/pschatzmann/arduino-audio-tools/wiki/Introduction#additional-processing-in-the-loop I would suggest to call poll only when a copy fails: if (copier.copy()==0) mqttClient.poll(); You then need to adjust the logic around out_stream.begin as well |
Beta Was this translation helpful? Give feedback.
-
I have never looked at the performance and overhead in using MQTT for audio. You might need to have a closer look at this. |
Beta Was this translation helpful? Give feedback.
-
Hi Guys This subject was interesting . But i did have a ESP32-A1S dev kit. Can i use it as well ? I looked around here on all of your work . Br |
Beta Was this translation helpful? Give feedback.
-
I am not sure what you mean with A1S Dev Kit and from where you want to get the audio. If your board has a codec chip you need to use this method described in the Wiki The AudioKit and LyraT have proper 16 bit stereo support: so it will be even easier.... |
Beta Was this translation helpful? Give feedback.
I dont have any experience with mqtt but I would not see any issues. Mqtt clients usually implement the stream api, so you can just use it as copy target. Just make sure that you stay within the limits if the protocol.
I suggest to encode it as wav, keep the channels at 1 and the sample rate low e.g at 8000, so that you know what you get on the target.
Maybe you just overlooked the issues with this microphone?