• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Building a wireless remote volume control with a rotary knob for Raspberry pi - help needed with Python

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,509
Likes
3,354
Location
Detroit, MI
Just for reference what version of CamillaDSP/GUI/pycamilladsp/pycamilladsp-plot are you on?

It almost sounds like it is just a display issue with the GUI.

Do you use the quick switch config functionality in the simplified view? If so I wonder if the issue is that the config is changed but the active configuration is not. I talked with Henrik a little bit about this here -> #3,727. Can you check and see if your active configuration (the one with the green highlighted A in the Files tab) matches the configuration loaded in the GUI?

Michael
 
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Just for reference what version of CamillaDSP/GUI/pycamilladsp/pycamilladsp-plot are you on?
Camilladsp 1.0.3 pycamilladsp1.0.0 backend 1.0.0 pycamilladsp-plot no idea, how can I check it?
It almost sounds like it is just a display issue with the GUI.

Do you use the quick switch config functionality in the simplified view?
You mean regularly? I do not.
If so I wonder if the issue is that the config is changed but the active configuration is not. I talked with Henrik a little bit about this here -> #3,727. Can you check and see if your active configuration (the one with the green highlighted A in the Files tab) matches the configuration loaded in the GUI?
Yes it does. Also, as i have changed my DAC this weekend, the only configuration that works as of today is the active one, so no room for variable there.
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,509
Likes
3,354
Location
Detroit, MI
Camilladsp 1.0.3 pycamilladsp1.0.0 backend 1.0.0 pycamilladsp-plot no idea, how can I check it?

You mean regularly? I do not.

Yes it does. Also, as i have changed my DAC this weekend, the only configuration that works as of today is the active one, so no room for variable there.

I don't think pycamilladsp-plot really matters. I'm on the 1.0.1 backend, I wonder if that is the difference.

Michael
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
I don't think pycamilladsp-plot really matters. I'm on the 1.0.1 backend, I wonder if that is the difference.

Michael
Is that something I can update separately to check or would I need to update the whole thing?
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,509
Likes
3,354
Location
Detroit, MI
Is that something I can update separately to check or would I need to update the whole thing?

It is pretty easy to update the backend, pycamilladsp and pycamilladsp-plot.

Code:
rm -r ~/camilladsp/camillagui ~/camilladsp/camillagui.zip
wget https://github.com/HEnquist/camillagui-backend/releases/download/v1.0.1/camillagui.zip -P ~/camilladsp/
unzip ~/camilladsp/camillagui.zip -d ~/camilladsp/camillagui
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp.git
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp-plot.git
sudo service camilladsp restart

Only thing else you need to do is set update_config_symlink to true in ~/camilladsp/camillagui/config/camillagui.yml.

Michael
 
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
It is pretty easy to update the backend, pycamilladsp and pycamilladsp-plot.

Code:
rm -r ~/camilladsp/camillagui ~/camilladsp/camillagui.zip
wget https://github.com/HEnquist/camillagui-backend/releases/download/v1.0.1/camillagui.zip -P ~/camilladsp/
unzip ~/camilladsp/camillagui.zip -d ~/camilladsp/camillagui
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp.git
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp-plot.git
sudo service camilladsp restart

Only thing else you need to do is set update_config_symlink to true in ~/camilladsp/camillagui/config/camillagui.yml.

Michael
thanks Michael. Did the update but still does not work how i think it should. What it does now is:

if i change bass or treble in the simplified view of the gui in my smartphone, the change becomes effective (i.e., i increase the bass to +6db, and the bass indeed increases), but the simplified gui in my laptop and the filters tab do not get updated.
If then i refresh the page, the settings go back to the values saved in the config, but without becoming effective (the music still sounds with bass at +6db).
No such issues with the volume, it gets correctly actualized everywhere.

Just reporting this back in case it is of interest for you, no need to fix it from my side as i never use the gui
here is my camillagui.yml in case (i set update_config_symlink to true as you suggested:

---
camilla_host: "127.0.0.1"
camilla_port: 1234
port: 5000
config_dir: "~/camilladsp/configs"
coeff_dir: "~/camilladsp/coeffs"
default_config: "~/camilladsp/default_config.yml"
active_config: "~/camilladsp/active_config.yml"
active_config_txt: "~/camilladsp/active_config.txt"
log_file: "~/camilladsp/camilladsp.log"
update_config_symlink: true
update_config_txt: false
on_set_active_config: null
on_get_active_config: null
supported_capture_types: null
supported_playback_types: null

additional info: if i check the two boxes
Apply automatically
Save automatically
in the configuration box and then i move the bass/treble sliders, these changes reflect in the filters tab, but if i refresh again the two boxes revert to unchecked and i am in the same situation as before.
 
Last edited:

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,509
Likes
3,354
Location
Detroit, MI
thanks Michael. Did the update but still does not work how i think it should. What it does now is:

if i change bass or treble in the simplified view of the gui in my smartphone, the change becomes effective (i.e., i increase the bass to +6db, and the bass indeed increases), but the simplified gui in my laptop and the filters tab do not get updated.
If then i refresh the page, the settings go back to the values saved in the config, but without becoming effective (the music still sounds with bass at +6db).
No such issues with the volume, it gets correctly actualized everywhere.

Just reporting this back in case it is of interest for you, no need to fix it from my side as i never use the gui
here is my camillagui.yml in case (i set update_config_symlink to true as you suggested:

---
camilla_host: "127.0.0.1"
camilla_port: 1234
port: 5000
config_dir: "~/camilladsp/configs"
coeff_dir: "~/camilladsp/coeffs"
default_config: "~/camilladsp/default_config.yml"
active_config: "~/camilladsp/active_config.yml"
active_config_txt: "~/camilladsp/active_config.txt"
log_file: "~/camilladsp/camilladsp.log"
update_config_symlink: true
update_config_txt: false
on_set_active_config: null
on_get_active_config: null
supported_capture_types: null
supported_playback_types: null

additional info: if i check the two boxes
Apply automatically
Save automatically
in the configuration box and then i move the bass/treble sliders, these changes reflect in the filters tab, but if i refresh again the two boxes revert to unchecked and i am in the same situation as before.

What I am seeing is consistent with your experience. If I make a change to Bass / Treble in one instance of the GUI it is reflected correctly in that instance of the GUI. However it does not apply to another instance of the GUI unless I hit "Fetch from DSP". Also Apply / Save Automatically did not persist after I refresh.

I agree it would be nice if Bass / Treble were like Volume in that they were reflected consistently across all instances of the GUI.

Michael
 
  • Like
Reactions: MCH

jaymarnz

Member
Joined
Dec 31, 2022
Messages
20
Likes
45
I was also inspired by the thread My Kingdom For A Remote Volume Knob!

So, if anyone is interested I've put together an open source web socket server for the Surface Dial. I'm currently using this in conjunction with a display app I built for BluOS streamers like the Node. The display app runs entirely within a browser. I use an old Android tablet I had lying around.

The web socket server should run on pretty much any Linux box with Bluetooth. I'm running it on a Raspberry Pi which also serves up the web page for the Android tablet. But you don't have to use the Surface Dial server with the display app. It can be used on its own to control another streamer, preamp, etc. That's why I wrote it as a generic web socket server. It provides a stream of rotations or clicks that could also be used for bass/treble or other adjustments or you can use them to do whatever you want within the limits of having just a few gestures. Example output:

JSON:
{ "button" : "down" }
{ "button" : "up" }
{ "degrees" : "3.1" }

It's working well for volume, mute and pause/resume functions. The only gotcha is the Surface Dial falls asleep too quickly and you have to interact with it (click or rotate) to wake it up before it starts working again. Lots of people talking about that but I haven't found a work-around yet.

I don't have a photo of the display along with the Surface Dial next to it but I'm sure you get the idea from this one. The RPi is hidden under the bench.

BluViewPhoto.jpg
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
I was also inspired by the thread My Kingdom For A Remote Volume Knob!

So, if anyone is interested I've put together an open source web socket server for the Surface Dial. I'm currently using this in conjunction with a display app I built for BluOS streamers like the Node. The display app runs entirely within a browser. I use an old Android tablet I had lying around.

The web socket server should run on pretty much any Linux box with Bluetooth. I'm running it on a Raspberry Pi which also serves up the web page for the Android tablet. But you don't have to use the Surface Dial server with the display app. It can be used on its own to control another streamer, preamp, etc. That's why I wrote it as a generic web socket server. It provides a stream of rotations or clicks that could also be used for bass/treble or other adjustments or you can use them to do whatever you want within the limits of having just a few gestures. Example output:

JSON:
{ "button" : "down" }
{ "button" : "up" }
{ "degrees" : "3.1" }

It's working well for volume, mute and pause/resume functions. The only gotcha is the Surface Dial falls asleep too quickly and you have to interact with it (click or rotate) to wake it up before it starts working again. Lots of people talking about that but I haven't found a work-around yet.

I don't have a photo of the display along with the Surface Dial next to it but I'm sure you get the idea from this one. The RPi is hidden under the bench.

View attachment 272728

That's awesome, thanks for sharing! I wish my dial didn't die just before starting this project. It is the ideal device for the task, but i was not willing to spend 70 euros on a new one...
Member @Gilbers also managed to get his dial working, i believe he uses it with a pi zero that triggers a IR blaster.
 

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
Have you shared your script, @MarcosCh, and if not, would you? I would really like to use the tone control functionality. I have not read any details how this was implemented, did I miss this? Is it a proper tone curve?
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Have you shared your script, @MarcosCh, and if not, would you? I would really like to use the tone control functionality. I have not read any details how this was implemented, did I miss this? Is it a proper tone curve?
Hi @changer
You can find a working script for the mqtt knob doing bass/treble control attached to post #47 and attached again here with some corrections. Please use the one attached to this post. You will have to adapt it of course to your IP address and id of your knob etc. I recommend you to read post #47 and the ones around it. If you want to do something similar starting from scratch, you will have to follow the instructions in post #2 first, and the python script will be your last step.

Is it a proper tone curve?
It is the tone curve that you want it to be. The control just changes the gain of two filters (Bass and Treble) that you need to set up beforehand in camilladsp, add them to your configuration, and very important, make sure you name them "Bass" and "Treble" if you are following this tutorial.
@HenrikEnquist recommends the following in the camilladsp GUI, but of course you can set the filters as you wish:

1679172775917.png


If you already followed the tutorial to build the volume control, to add the tone functionality should not take you more than a couple of minutes, but if you are starting from scratch, i am sure you will have more questions. Don't hesitate asking, will do my best to answer. Good luck!

link to post #47:

 

Attachments

  • 2023-03-18 tonecontrol.zip
    1,004 bytes · Views: 49

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
Thank you very much for the conclusive answer and also for sharing your work! This tool will complete my streaming setup. I will order the dial / knob tomorrow and begin with setting up Jesper’s (user lykkedk over at diyaudio) “SuperPlayer,” a CamillaDSP enabled piCorePlayer in the meantime. And most probably some questions will arise in the course of setting everything up.
 
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
Thank you very much for the conclusive answer and also for sharing your work! This tool will complete my streaming setup. I will order the dial / knob tomorrow and begin with setting up Jesper’s (user lykkedk over at diyaudio) “SuperPlayer,” a CamillaDSP enabled piCorePlayer in the meantime. And most probably some questions will arise in the course of setting everything up.
I have no idea how camilladsp in piCorePlayer works, but to get the volume/tone control working, make sure you install pycamilladsp as well (the python library for camilladsp):

 

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
yes, it could become a complication that piCorePlayer is running on TinyCore Linux, let’s see if it can be made working.

This is the pCP implementation of CamillaDSP. Development thread:
Github:
 

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
So I ran into the issue that there is no working mosquitto build (.tcz) for TinyCoreLinux (piCorePlayer) available and building the extension following https://akeil.de/posts/mosquitto-mqtt-on-tinycore/ failed at compilation. there seems to be a dependency missing:
In file included from mosquitto_ctrl.c:29:
mosquitto_ctrl.h:21:10: fatal error: cjson/cJSON.h: No such file or directory
21 | #include <cjson/cJSON.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
Tried to install c-json but I could not solve the issue yet. Will meet with a friend who's more literate in this resorts.
 
  • Like
Reactions: MCH

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
I am almost there using the script with piCorePlayer / TinyCore.

To sum requirements up (I will leave a detailed description once everything works):
- mosquitto is available as an extension
- node.js can be downloaded as a binary for armv7l from their site
- zigbee2mqtt and paho-mqtt both run

The issue I am facing now, however, is another: I am using this freshly developed and nicely working integration of camillaDSP to piCoreplayer:

For some reason, your script does not find the installation of camilladsp:

tc@pCP:~$ python3 /home/tc/tonecontrol.py
Traceback (most recent call last):
File "/home/tc/tonecontrol.py", line 5, in <module>
from camilladsp import CamillaConnection
ModuleNotFoundError: No module named 'camilladsp'

Any leads?

Edit: I searched for camilladsp wit WinSCP and found the following locations:
Screenshot 2023-09-15 115656.png
 
Last edited:
  • Like
Reactions: MCH
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
I am almost there using the script with piCorePlayer / TinyCore.

To sum requirements up (I will leave a detailed description once everything works):
- mosquitto is available as an extension
- node.js can be downloaded as a binary for armv7l from their site
- zigbee2mqtt and paho-mqtt both run
- I could not start zigbee2mqtt from bootlocal.sh, that crashed the system, still working on this

The issue I am facing now, however, is another: I am using this freshly developed and nicely working integration of camillaDSP to piCoreplayer:

For some reason, your script does not find the installation of camilladsp:



Any leads?
Great that you are almost there!
The line of the code:
"from Camilladsp import CamillaConnection" that seems to be at the origin of the error, I took it from pycamilladsp original instructions and from the many example scripts @mdsimon2 published in his tutorial. It seems to be the standard way to get connected to camilladsp.


i don't know what the error means, i would suggest asking the experts in the subject matter at the camilladsp tutorial thread.
 
OP
M

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,641
Likes
2,251
My guess is @changer does not have pycamilladsp installed.

Michael

and if this is the case, is 100% my fault as i did not describe this in the original posts (i had it already installed)

@changer you need pycamilladsp. To install it, you can follow the instructions in post #3 of the camilladsp tutorial (steps 11 and following). Here:

 

changer

Addicted to Fun and Learning
Joined
Dec 4, 2020
Messages
559
Likes
602
I have installed it to TinyCoreLinux using the git that I linked to above. Here is a thread by the developer:

It works, I already use the tone controls via the gui.

Edit: In the screenshot of my last post, it says that camilladsp.py is in the /user/local...camillagui...python.../site-packages folder
 
Last edited:
Top Bottom