Volume control PI in Node-Red

1,103 views
Skip to first unread message

Peter Scargill

unread,
Jan 5, 2016, 8:15:59 AM1/5/16
to Node-RED
I wonder if anyone here is a step ahead of me.  In the THINGBOX is a VOLUME node (which I could not get to work) - so back in the world of ordinary Node-Red - has anyone come up with a Node-Red node which will allow control of the PI volume... would be useful as I've done a speech flow using mpg123 and ivonatts - and in my latest installation it's a tad quiet - of course you can go into Linux but it would be so much better if you could prefix - say an alarm sound with high volume or general speech with low volume..

Any takers?

Nathanaël Lécaudé

unread,
Jan 5, 2016, 10:38:11 AM1/5/16
to Node-RED
You can control the volume of the ALSA mixer using an exec node in Node-RED with this command:

amixer --quiet -c 1 set Digital VOLUME

Where Digital is the name of the parameter you want to control and VOLUME is the value. 

Peter Scargill

unread,
Jan 5, 2016, 10:52:39 AM1/5/16
to node...@googlegroups.com

I tried that (Raspberry Pi 2 running Wheezy playing an MP3 file) with a space after the word Digital (I am using the 3.5mm connector for audio) and different values as parameter passed by an inject node. Made no difference at all ???

 

Pete.

--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YGITXaAOnzM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Scargill

unread,
Jan 5, 2016, 11:12:55 AM1/5/16
to node...@googlegroups.com

Thanks for that – you started me off

amixer cset numid=1 --

 

That did the job with 100% stuck on the end  - a little sub-node I think as 40% is almost silent.. Got it – great.

 

From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Nathanaël Lécaudé
Sent: 05 January 2016 15:38
To: Node-RED <node...@googlegroups.com>
Subject: [node-red] Re: Volume control PI in Node-Red

 

You can control the volume of the ALSA mixer using an exec node in Node-RED with this command:

--

Nathanaël Lécaudé

unread,
Jan 5, 2016, 11:26:21 AM1/5/16
to Node-RED, pe...@scargill.org
This also works:

[{"id":"45776f8a.ba889","type":"ui_tab","z":"e17f5ace.1e80a8","name":"Home","icon":"dashboard","order":"1"},{"id":"7b75ca20.848a34","type":"ui_slider","z":"e17f5ace.1e80a8","tab":"45776f8a.ba889","name":"Slider","topic":"","group":"","order":1,"min":0,"max":"100","x":130,"y":200,"wires":[["c871e3ff.378e2"]]},{"id":"3058a916.cfa756","type":"exec","z":"e17f5ace.1e80a8","command":"amixer set PCM","addpay":true,"append":"","useSpawn":"","name":"","x":438.5,"y":200,"wires":[[],[],[]]},{"id":"c871e3ff.378e2","type":"function","z":"e17f5ace.1e80a8","name":"","func":"msg.payload = msg.payload + \"%\";\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":200,"wires":[["3058a916.cfa756"]]}]

Peter Scargill

unread,
Jan 5, 2016, 11:49:40 AM1/5/16
to node...@googlegroups.com

I was so pleased the numid thing worked I did a little blog item – I’ll try yours now – thanks! http://tech.scargill.net/raspberry-pi-volume-in-node-red/

maxime....@digitalairways.com

unread,
Jan 6, 2016, 3:45:56 AM1/6/16
to Node-RED, pe...@scargill.org
Hello Peter,

The volume node from thethingbox works as you do on your blog post.
Here an example with this node:


[{"id":"45776f8a.ba889","type":"ui_tab","z":"e17f5ace.1e80a8","name":"Home","icon":"dashboard","order":"1"},{"id":"7b75ca20.848a34","type":"ui_slider","z":"e17f5ace.1e80a8","tab":"45776f8a.ba889","name":"Slider","topic":"","group":"","order":1,"min":0,"max":"100","x":130,"y":200,"wires":[["c871e3ff.378e2"]]},{"id":"3058a916.cfa756","type":"exec","z":"e17f5ace.1e80a8","command":"amixer set PCM","addpay":true,"append":"","useSpawn":"","name":"","x":438.5,"y":200,"wires":[[],[],[]]},{"id":"c871e3ff.378e2","type":"function","z":"e17f5ace.1e80a8","name":"","func":"msg.payload = msg.payload + \"%\";\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":200,"wires":[["3058a916.cfa756"]]}]

If you any troubles with it, please tell me, I can help you.

Maxime
TheThingBox Team

Peter Scargill

unread,
Jan 6, 2016, 4:01:42 AM1/6/16
to node...@googlegroups.com

Thanks for that.  I found my modification necessary as for some reason all the volume seems to be concentrated at one end of the scale. Good idea to use the slider from UI

 

Pete.

Reply all
Reply to author
Forward
0 new messages