HEnquist / camillagui-backend

Backend server for camillagui
GNU General Public License v3.0
18 stars 4 forks source link

Any issue running the backend/gui all the time? #35

Closed y8s closed 2 years ago

y8s commented 3 years ago

Are there any downsides to leaving the main.py running indefinitely while using camilladsp?

It would be convenient to avoid having to log in to the machine and start it up manually at power up while I'm developing my filters, but also frequently unplugging and replugging a headless Raspberry Pi's power.

It looks like it uses about 18-20% of my RPi Zero's CPU and about 7% of its memory. Is this pretty constant while I'm not making adjustments? I see it rise to ~50% CPU when changing settings or applying them to the DSP, but it doesn't last long.

Setup is a Raspberry Pi Zero W with USB OTG hub and a couple of Ugreen 2 channel USB dongles as my four outputs. Source is (for now) raspotify and miniDLNA.

For the record, it's pretty stable and clean with a couple basic filters.

HEnquist commented 3 years ago

It's meant to be left running all the time, that shouldn't cause any issues. Then again, the Pi Zero doesn't have a lot of cpu grunt, if it's struggling at some point then closing the backend when not needed could free up some cpu cycles. The load you see is likely created by a connected client (having the gui open in a browser). The gui sends request at regular intervals, so the even load is expected. Opening it in more than one browser should increase the load. And with no clients it's not really doing anything so then it should consume very little cpu.

Very nice to learn that it works on the Pi Zero! Are you using Ugreens via an alsa multi device?

JWahle commented 3 years ago

I suspected the same - I'd like to know the CPU usage without any clients connected. @y8s Please share, if you tried it.

y8s commented 3 years ago

I will run some tests on cpu usage and reply here.

It seems to run fine on the zero.

I did use alsa multi and the pulse configuration at the end of the readme for the camilla-config repo.

I also had to add a udev rule because one of the ugreens changes it's usb id depending on what is plugged in. So far an aux cord and headphones are considered different than both each other and an empty jack.

@HEnquist is there any service file or similar to run the main.py somewhere? I can write my own but was curious.

y8s commented 3 years ago

I had to hunt down all my browsers and machines where I opened the web gui, but once they were all closed htop shows 0.0 CPU% and about 3.3% of the pi zero memory for the python process.

Just added this:

[Unit]
Description=CamillaDSP Backend and GUI
After=multi-user.target

[Service]
User=pi
Type=idle
ExecStart=/usr/bin/python3 /home/pi/camillagui-backend/main.py

[Install]
WantedBy=multi-user.target
HEnquist commented 3 years ago

Great, thanks for reporting back! I didn't prepare any service file for the gui yet, would you mind if I just take yours? Also, could you show the ALSA config with the multi plugin? That could be interesting for others. Synchronous USB devices like these lock their sample clocks to the USB bus, so there won't be any drift between them. It's one of the few cases where the multi plugin becomes really interesting :)

y8s commented 3 years ago

here's my config. remember I used the pulse audio config from your config repo to make this all work

https://gist.github.com/y8s/c032f3a2ba12504eff5f0184f0dec7d1

y8s commented 3 years ago

@HEnquist sorry, forgot to answer. sure feel free to take my service file. should help any pi user with a reasonably standard install.