Audio Out Issue

Hello,

I have node red running on a Raspberry Pi and am using the Audio Out node to play wav files. There are two other Pi's that connect to the dashboard. When I was developing the code, the wav file played correctly but I only had one connection to the dashboard. Once i had the system complete I noticed the audio sounded choppy and would cut in and out. I verified that if only one dashboard connection is made the audio plays correctly again.

My question is why does having multiple browsers connected to the dashboard affect the rendering of the audio file? Also, is there a way to fix it? In the current iteration I need the audio to play from the browser as Node Red is not running on the two remote pi's.

Thank you.

I’m pretty sure this has to do with the fact that all three browsers are sharing the same dashboard.

From https://flows.nodered.org/node/node-red-dashboard:

Multiple Users

This does NOT support multiple individual users. It is a view of the status of the underlying Node-RED flow, which itself is single user. If the state of the flow changes then all clients will get notified of that change.

Messages coming from the dashboard do have a msg.socketid , and updates like change of tab, notifications, and audio alerts will be directed only to that session. Delete the msg.sessionid to send to all sessions.

If I understand correctly, each browser is getting the audio pushed to it, but they shouldn't interfere with each other right? It's almost as if the audio is playing 3 times on each browser. 3 browsers, 3 audios whereas I'm expecting it to be one audio per browser.

So you are saying that if I delete the sessionId then it will play correctly for each browser?

Is there another node that is better to use for my purpose than the Audio Out node?

Just to clarify my last message. As of right now, the audio plays in all 3 browsers. But the audio doesn't sound correct.

I thought re-iterating my problem might help generate some ideas. I'm using a Raspberry Pi running Node Red as an alarm system. There is a simple dashboard with three buttons alarm 1, alarm 2, and idle. When a button is pressed I use a Read In node to read a .wav file and send the output into an Audio out node.

When I connect to the dashboard from one browser on a remote device, the audio sounds great and behaves as expected. I am using two remote Pi's that are not running Node Red as audio players. They each open a browser and point to the same dashboard.

As far as I know, I don't want to utilize the multi-user dashboard because I want a button press to activate the audio on all three Pi's. It doesn't matter which connection of the dashboard presses the button, i want the change to be reflected in all three. So they should always be in the same "alarm state".

This all works properly, however, when all three browsers are connected to the dashboard, the audio sounds choppy, and sometimes doubled, on all three instances. It is almost like the Node Red flow is injecting the audio three times into the Audio Out node instead of once. I don't see where I can delete a msg.sessionId for the audio going into the Audio Out node. I also don't see one on the output of the button press. Perhaps I am missing it. I'm wondering if there is a way to fix this, or if I should use another node besides the Audio Out to play audio through the dashboard.

Have you tried using two PC’s to connect to the pi’s NR dashboard and see if the issue happens then?

What type Pi’s are the three pi’s you are using and what OS release are they each using and what else is running on them?

Sorry for the long delay. My second child was born recently and I have been unable to perform the test. I do have some answers to your quedtions however.

I have not tried using only PC's connected to the dashboard, but i have used a PC and a Pi connected and the problem occurs on both the PC and Pi dashboards.

All the Pi's are 3b+, are using Raspbian Buster, and they are not running anything else major. Of course there will be background processes, and there may be some routine to keep the pi's from going to sleep, but I am not actively running any other personal applications or software.

Congradulations on your second child and I hope you are getting some good nights sleep!

I've been playing trying to reproduce and I have two mac's connected to a flow running on a Rpi (Pi 3 Model B Rev 1.2 running Buster) and I'm not having any issue.
Can you export your flow and attach it to a reply and how big is the file you are trying to play?

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Thank you! I'm sleeping about as well as I can :wink:

I will try to re-create the problem with a simpler flow and will upload when it is ready.

This turned into one of those strange occurrences. I had to reboot all of the Pi's for a reason unrelated to Node-Red, and upon rebooting I attempted to re-create the issue and the audio is playing correctly from my PC speakers with all Pi's connected to the dashboard. Go figure. I will have to wait a couple of weeks until I am back in the vicinity of where the system is deployed, but at that time I will test and see if the audio coming from the Pi's are fixed as well. I will post an update once I find out.