# Node red dashboard audio wish

**URL:** <https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798>\
**Category:** Dashboard\
**Created:** [12 November 2018 13:31 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798 "2018-11-12T13:31:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [12 November 2018 13:31 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/1 "2018-11-12T13:31:04Z")

</div>

Dont know were to post this on github to ask for it so i try it here.

I love the ui\_audio node to play audio prompts.  
But for a new project i would love to get a start and end/stop when starting playing audio and when playing is finished.  
Is it possible to get this in payload or as node status?

Thanks  
Rogier

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [12 November 2018 14:23 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/2 "2018-11-12T14:23:18Z")

</div>

...Also it would be nice to be able to stop a sound mid-play (ex: sending msg.reset).

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [12 November 2018 18:39 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/3 "2018-11-12T18:39:39Z")

</div>

Hey Dave (@dceejay),  
Both proposals make sense, especially when live audio streaming would ever see the daylight ...  
I had already implemented an experimental version of the msg.reset (or msg.stop or whatever...) since I needed to stop somehow the endless silent audio source that I start behind the scenes.

Do you have any suggestions about both proposals? Then I will take them into account, if you want. Maybe it would be useful to implement these feature requests first, since I didn't manage yet to get rid of the disturbance in the live audio stream on Android...

Thanks!  
Bart

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 November 2018 20:21 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/4 "2018-11-12T20:21:14Z")

</div>

Bart, always happy to look at a PR.  
Reset no problem.  
What is the use case for stopped and start ? Would doing that via Status (and then status node) be OK ?

Must admit not been following your progress so closely. Can you (just about) handle streams of raw packet ?

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [12 November 2018 21:14 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/5 "2018-11-12T21:14:01Z")

</div>

for me the start stop would be to control the lights during playback.  
when it start lights down, when finished lights up 😉

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [12 November 2018 21:32 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/6 "2018-11-12T21:32:30Z")

</div>

Guys, can we summarize it like this:

- Input message `msg.reset` allows the current sound to be stopped, whether it is a single audio file or an audio stream.
- Output message `msg.stop=true` is send when the current sound is stopped. I assume this might be handy e.g. when you play an mp3 file. As soon as the file is entirely played, a message is send to make sure the flow can respond e.g. by playing the next file?
- Output message `msg.start=true` is send when the current sound is started. This might be a bit less usefull (I think) because the flow already knows that the sound is started, since the flow has just now send an audio chunk to the dashboard...

> [@dceejay](#):
>
> Must admit not been following your progress so closely

About the web audio stream. @GChapo has already been testing it a lot and the current status is this (correct me Glenn if not correct!):

- On desktop browser (like e.g. Chrome) the quality is acceptable.
- On Android the sound has lots of disturbances. I still have no clue why...
- On iPhone there is no sound at all. But I think this is due to their autoplay policy. Will need to fix that also, but cannot debug it since I have no iPhone...

But I have some other private stuff that I need to finish, before I continue with the streaming (because it is taking much more time as expected ...).

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [12 November 2018 21:36 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/7 "2018-11-12T21:36:22Z")

</div>

on osx the audio is perfect!

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [12 November 2018 21:41 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/8 "2018-11-12T21:41:43Z")

</div>

Hey Rogier,

The web audio stream is another thing I'm working on. Currently the audio-out node only allows you to play a single audio fragment (e.g. an mp3 file). And that will probably work nicely on osx.

However we would like it to be able to play an infinite stream of audio fragments, e.g. from a microphone. So I have to play all these fragments **seamless** , which is not as easy as it looks. The least disturbance between the individual fragments will be very annoying for your ears. And on mobile phones (Android and iPhone) I didn't manage yet to play seamless streams. But that is another pull-request, so sorry for going off-topic ...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 November 2018 23:38 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/9 "2018-11-12T23:38:59Z")

</div>

Not sure I want to see an output pin on this node. I'd prefer the status to reflect the state of playback.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 November 2018 13:06 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/10 "2018-11-13T13:06:36Z")

</div>

Hey Dave, the status update is indeed a nice feature!  
Is there any particular reason, you don't want the audio-out node to have an output? Is it because the audio-out node doesn't accept user input, so you find it confusing? But it could be useful to have an output message when the audio fragment has been finished by the client, so you can e.g. send a new audio fragment for playback.

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [13 November 2018 13:18 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/11 "2018-11-13T13:18:35Z")

</div>

You could use a status node and set it to the audio note 😉  
That is what i have in mind to use it to trigger other things

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 November 2018 13:37 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/12 "2018-11-13T13:37:27Z")

</div>

What @RogierQ just said :-)...  
I just refer nodes that are logically the end of a flow to look like they end it...

I'd also like to retro fit some of this thinking into some of the non-dashboard audio nodes that may use the right edge button for mute etc.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 November 2018 14:02 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/13 "2018-11-13T14:02:23Z")

</div>

> [@dceejay](#):
>
> I just refer nodes that are logically the end of a flow to look like they end it..

Ok, I can clearly see your point from a visual point of view in the flow editor.

But a question about the **Status-node** : Currently I have only used the node status to display something visual in the editor, but I wasn't aware that these statusses are also passed through the flow (instead of messages) to exchange information between nodes. From some discussions I had concluded that we were only supposed to exchange data via the 'visible' wires, and that other 'invisible' data exchange was not allowed in the Node-RED philisophy?

Is there perhaps any rule of thumb for node developers? When something changes that the flow should be aware of: when should we send an output message and when should we update the node status. Perhaps I haven't done this correctly in my other contributions 🥴

Thanks !!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 November 2018 15:00 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/14 "2018-11-13T15:00:39Z")

</div>

Hi Bart,

Status messages aren't passed through the flow. They are indeed mainly for visual effect, BUT... they also create an event that the status node receives (and can filter on). This is similar to the Catch node that catches node.error events.

Status is intended to reflect the status of the flow (or node) itself - rather than the state of the message - though this is blurred :-)... So it is intended for things like the state of a network connection, the depth of a queue, if a node is active or inactive, rather than the value of the payload.... of course in a function node you can set node.status to anything so this can be abused fairly quickly :-0...

And yes it is fairly arbitrary. If it's something where you would "normally" expect it to be part of a flow eg http-request - then yes it makes sense to also handle the error as part of the output message. If it's something you have handed off to something else then status may be more appropriate. But somethings that fail a lot... do mean we change our minds... like the file output node now has an output.

Also of course if the node has an output button (like debug) then it shouldn't have a output pin as well.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 November 2018 19:22 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/15 "2018-11-13T19:22:35Z")

</div>

Hey guys,

Before I submit a pull request, it would be nice to get some 'constructive' feedback.  
Here is a **demo** , since you can not easily install my personal dashboard version:

 ![audio_stop_and_status](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f9ea36d818fcd3a05434d69a38b9b85877fdacde.gif)

Some explanation of the demo:

- When pressing '_start_' an mp3 fragment is send to the audio-out node. Once the web audio has started playing the fragment in the browser, the dashboard will send status ' **started**' back to the Node-RED flow.

- Since I couldn't add sound to this animated gif, you can watch the equalizer bar in the right screen to see whether the audio is playing or not.
- As soon as the mp3 fragment has been played 'entirely' by the web audio, the dashboard will send status ' **completed**' back to the Node-RED flow.
- When pressing '_stop_' during playback of the mp3 fragment, the web audio playback will be stopped. And the dashboard will send status ' **reset**' back to the Node-RED flow. P.S. the demo shows status text 'resetted', but I have changed the text afterwards to 'reset'.

In the info tab of the audio-out node, some extra text has been added:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/988dd3b09882950dfdb8f47c1d33b265797783d5.png)

I have tested this on Chrome Windows and Chrome android.

Remark: does anybody expect extra issues in case multiple clients are listening simultaneously to the same audio?

Bart

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [13 November 2018 20:17 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/16 "2018-11-13T20:17:39Z")

</div>

Looks perfect to me! Thanks!  
Does it also work with tts?  
Thats my main use of the audio node

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 November 2018 20:28 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/17 "2018-11-13T20:28:39Z")

</div>

@BartButenaers I'd say send a blank and no blob for end of playing - eg like the preceding http request - so it is cleared when finished. This also leaves the possibility free for "stopped" if there was ever to be a stop command, or maybe "paused" etc.... Also I'd prefer "playing" instead of started... 🙂

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [13 November 2018 21:13 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/18 "2018-11-13T21:13:02Z")

</div>

If you send a blank, is it possible to catch that change then with the status node?  
So do i have a trigger that tells me it has stopped?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 November 2018 21:28 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/19 "2018-11-13T21:28:03Z")

</div>

actually can be an empty string ""...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1e99e258583a7de695d042572d8c51bf0f2630ec.png)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 November 2018 22:14 UTC](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798/20 "2018-11-13T22:14:49Z")

</div>

> [@RogierQ](#):
>
> Does it also work with tts?

Nope. Seems that I will need to handle the speech synthesis differently:

- It should be stopped this [way](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis/cancel).
- And to detect the end of the speech playback, I think I should use [this](https://developer.mozilla.org/en-US/docs/Web/Events/soundend) event.

But for some reason I get no sound at all using TTS, so a bit difficult to test 🥴 Don't know what is wrong, because I have it on all my Raspberry's (so not a result of my dashboard changes)...

> [@dceejay](#):
>
> This also leaves the possibility free for "stopped" if there was ever to be a stop

Don't know if my demo was not clear, but when you send a `msg.reset=true` then the playback will already be stopped. So that functionality is also part of this pull request ... Do you prefer perhaps `msg.stop` instead of `msg.reset`?

> [@dceejay](#):
>
> or maybe "paused" etc

In the current version I haven't implemented pause or resume:

- Web audio can only be started or stopped. However when '_pause_' or '_resume_' is required, we would need to remember ourselves the time offset (where we have interrupted the fragment). Like in this Codepen [example](https://codepen.io/ianmcgregor/pen/EjdJZZ) .
- On the other hand, the speech synthesis seem to have pause and resume [methods](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis#Methods) out of the box.

[Next page](https://discourse.nodered.org/t/node-red-dashboard-audio-wish/4798.md?page=2)
