RPi speaker volume. Can I adjust via node-red?

529 views
Skip to first unread message

JB

unread,
Apr 24, 2018, 8:30:23 PM4/24/18
to Node-RED
This turned out to be a pretty long post, so if you don't feel like reading the whole thing, my basic question is: How can I control the volume of a sound file that is playing in NodeRED on my raspberry pi (the same machine running NodeRED).

******************

I'm brand new to all of this but using Node-RED I have managed to produce a working click track (metronome) system for my band when we play live gigs. 

I have a UI with a button for each of our songs which, when pressed, plays a pre-recorded click track (mp3 file), and the drummer can trigger these from his iPad via dashboard. I have NodeRED set to launch at startup so all we have to do is plug in the RPi, wait 20 seconds and then log on to the dashboard from any device. It's really really great.

HOWEVER....

I want to go deeper. The catalogue of songs is ever changing and it is impractical to record a new audio file for each song, especially if we are on the road. Therefor I created a flow that generates a click track based on a tempo derived from the value of a dashboard slider. Once the value is obtained, it plays a sound file (which consists of one "click") over and over at a setInterval() until stopped.

With a little help from the people here, it actually works very well!

BUT... 

It works SO well I have decided to institute options for quarter note, eighth not, and sixteenth notes. I would like to be able to assign a slider to each of those that turns the volume up or down. In other words, with one slider, I can turn quarter notes all the way up, while at the same time I can turn the eight notes to half volume. The only problem is, I can't find any way to do it or any reference to volume control other than using the GPIO to control an external device.

I know this is probably not what this powerful platform was intended for, and my skill/knowledge level is lack-luster, but there's got to be a way and I hope that someone here can point me in the right direction. Sorry for the life story!. Thanks in advance.

Colin Law

unread,
Apr 25, 2018, 3:46:23 AM4/25/18
to node...@googlegroups.com
I haven't done it myself but google suggests you can use the amixer command (which you could run via an Exec node) to do this. The man for the command can be seen at
https://linux.die.net/man/1/amixer
and if you google for something like
pi command line volume
you will find examples.  Try running the command in a terminal first to experiment with settings, then when you know what to do you can run the command from an Exec node with appropriate values.  If you get it working then add a mini-flow showing how to do it to flows.nodered.org so others can use it.

Colin


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/4a60c0e7-3272-44a1-91ab-da9085620ff2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Apr 25, 2018, 4:49:10 AM4/25/18
to node...@googlegroups.com
You don’t mention how you are playing the mp3 file. But there is this as well
--
Sent from phone.
Reply all
Reply to author
Forward
0 new messages