From 11f01972930de6a0faa80ab721ee1b162d72b38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81mie=20Ducastel?= Date: Sat, 5 Jul 2025 15:18:40 +0200 Subject: [PATCH] =?UTF-8?q?recup=20roadmap=20/=20id=C3=A9es=20mpdbox=20dep?= =?UTF-8?q?uis=20github/jducastel/phatbeat=20(=C3=A0=20supprimer)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++- mpdbox.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 mpdbox.md diff --git a/README.md b/README.md index 3677d16..6e2e5a0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Audio python player for Piromoni's [phat beat](https://github.com/pimoroni/phat-beat) / pirate radio kit -Projet / roadmap : +## Projet / roadmap : 1. lecture de fichiers locaux - Sur l'exemple de [pirate juke box](https://github.com/andywarburton/pirate_jukebox), lecture de fichiers mp3 d'un dossier. @@ -27,6 +27,10 @@ Projet / roadmap : 2. construction de playlist de fichiers locaux par scan d'un dossier 3. interface web pour construire des playlists, depuis fichier local et/ou deezer etc ? +## roadmap ter / mpd box + +voir [mpdbox](mpdbox.md) + ## A regarder ? - https://pad.p2p.legal/s/rec-machine diff --git a/mpdbox.md b/mpdbox.md new file mode 100644 index 0000000..502dbb2 --- /dev/null +++ b/mpdbox.md @@ -0,0 +1,108 @@ +# MPD BOX on Pimoroni's Phat Beat / pirate radio +1. Use [Python Music Player Daemon](https://www.musicpd.org/) as a service to play both local files and playlists (including radio urls) on the phat beat. + +2. Use [beets](http://beets.io/) (optionnaly ?) to organize / import the local music library + +3. Use [MPD client lib](https://www.musicpd.org/libs/python-musicpd/) in a python script running as a service. It will act as a MPD client to control the local MPD server service, through the phat beat buttons. + + Others clients should be able to control played music through the local network. (Many android clients are available). Command-line client [mpc](https://linux.die.net/man/1/mpc) is available. + +## Installation +Install MPD (server/daemon) and MPC (client) +```shell +apt-get install mpd mpc +``` + +`mpc` client won't be able to retrieve / adjust volume until editing configuration file at `/etc/mpd.conf` to replace line + +``` +audio_output { + mixer_type "hardware" +} +``` + +by + +``` +audio_output { + mixer_type "software" +} +``` + +## Troubleshooting +### Disable PiVumeter + +If you tried the VLC radio project before, you may have to [get rid of pivumter](https://forums.pimoroni.com/t/getting-rid-of-pivumeter/6187/2) like this : + +> Try editing /etc/asound.conf and changing: +``` +pcm.softvol_and_pivumeter { + type softvol + slave.pcm "pivumeter" + control { + name "PCM" + card 0 + } +} +``` +> to: +``` +pcm.softvol_and_pivumeter { + type softvol + slave.pcm "hw:0,0" + control { + name "PCM" + card 0 + } +} +``` + +Removing `/etc/asound.conf` entirely will disable the `alsamixer` command, which may be used to set global sound level. + + +## Roadmap +client service script still to do. See ideas below. + +### Controls +Use button holding (next / prev) to cycle through available playlists. + +### LED +Visual feedback when using buttons (setting volume / browsing playlist(s)). + +Replace Pimoroni's green pivumeter by a _rainbow_ one. +Integrated within the _client_ service or decoupled ? + +Something along this : + +```python +def set_volume(self, level=3): + if level >= 0 and level <= 8: + self.volume = level + self.player.set_volume(self.volume*12) # 0-96 + self.show_volume(level) + +def volume_up(self, pin): + self.set_volume(self.volume + 1) + +def volume_down(self, pin): + self.set_volume(self.volume - 1) + +def show_volume(self, level, saturation=1.0, value=0.2): + phatbeat.clear() + for i in range(0,8): + # definition de la teinte en fonction de la "hauteur" du pixel + # pour un effet "arc en ciel" + # on divise 360° par 8 "crans" (=45°) + # et on decale arbitrairement de 45° pour ne pas débuter sur rouge + hue = 315 - 45*i # definition de la teinte (8 crans = 45°) + if level > i: + r, g, b = [int(x * 255) for x in colorsys.hsv_to_rgb(hue / 360.0, saturation, value)] + phatbeat.set_pixel(7-i, r, g, b, 0.1, channel=0) + phatbeat.set_pixel(7-i, r, g, b, 0.2, channel=1) + phatbeat.show() + +``` + +On the second led bar, show playlist or track progress ? + +Maybe representing playlist as a color spectre and adjusting shown part of the spectre to available leds / size of the playlist ?