hyperion-audio-effects
hyperion-audio-effects copied to clipboard
Hyperion audio effects dev kit using Gstreamer
Hyperion audio effects
Examples: https://www.youtube.com/watch?v=zLPZ6Lzbmgc https://www.youtube.com/watch?v=AOv9BwbtA6w
Dev kit for creating audio visualizations for hyperion.
- Update 27/3/2016: Config file (config.json), matrix configurator, protobuf support
- Update 8/4/2015: Some improvements and cleanup, new video
- Update 31/3/2015: New parameters and hyperion config file parsing
Installation and running on Debian **
- Install Gstreamer 1.0 and PyGI:
sudo apt-get install libgstreamer1.0-0 gir1.2-gstreamer-1.0 gir1.2-glib-2.0 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-good gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-pulseaudio python-gi - Install Tkinter for GUI:
sudo apt-get install python-tk - Install pip:
sudo apt-get install python-pip - Install dependencies:
sudo pip install -r requirements.txt(or use virtualenv if you like) - Put
options snd-aloop index=-2in end of/etc/modprobe.d/alsa-base.confto prevent loopback device for getting first card index - Enable loopback device
modprobe snd-aloop(and type linesnd-aloopto /etc/modules to make it permanent) - Put the included
.asoundrcto your home folder (backup old if exists) and change the soundcard index if needed ("hw:<card>,<device>", checkaplay -l) * - Reboot or reload alsa
sudo alsa force-reload - Run
python main.pywith options:--config=<path>path to hyperion config file (defaults to./hyperion.config.json)--guifor gui--jsonfor network connection (--host=<ip> --port=<port>)--helpto see all options
- Play some audio
- Levels should be drawn to gui, also sent to hyperion if json enabled
- Exit by closing the GUI or Ctrl+c
Installation and running on OSMC (RPi 2)
- Enable audio so we can use alsa and loopback: Add
dtparam=audio=onto/boot/config.txt.
- Why? https://discourse.osmc.tv/t/alsa-doesnt-work-after-last-update/10600
- Install Gstreamer 1.0, alsa, PyGI and pip:
sudo apt-get install libgstreamer1.0-0 gir1.2-gstreamer-1.0 gir1.2-glib-2.0 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-good gstreamer1.0-tools gstreamer1.0-alsa alsa-base alsa-utils python-gi python-pip - Install git (
sudo apt-get install git) and clone this repo (git clone https://github.com/RanzQ/hyperion-audio-effects.git), or just download as zip and extract - Install python dependencies
cd hyperion-audio-effects/ && sudo pip install -r requirements.txt - Put
options snd-aloop index=-2in end of/etc/modprobe.d/alsa-base.conf(the file doesn't exist, just create it) to prevent loopback device for getting first card index - Enable loopback device
sudo modprobe snd-aloop(and type linesnd-aloopto /etc/modules to make it permanent) - Put the included
.asoundrcto your home folder and change the soundcard index on line 21 if needed (checkaplay -l, for me"hw:0,0"works, this depends on if you use usb-audio etc.) - Reboot
- Now you must choose how to play some music. Kodi/OSMC doesn't support the loopback setup and Spotify can't be installed (maybe possible soon, check spotifyd), so I went with mpd and mpc
sudo apt-get install mpd mpc.
- To get audio working with
mpd, I needed to copy the alsa config to be globalsudo cp .asoundrc /etc/asound.conf - After adding some music to
/var/lib/mpd/musicrunmpc ls | mpc addto add all files to playlist, thenmpc play(checkmpc helpfor all commands). - You can select between HDMI and Headphone jack with
amixer cset numid=3 2(HDMI) /amixer cset numid=3 1(Headphone) - I didn't find a way to adjust the audio level that the effects receives, I've done that using Spotify
- Finally you can try the audio-effects :)
cd hyperion-audio-effects/python main.py --effect vumeter- The heavier effect works with setting
"band-width-exp": 4-5but uses quite a lot of CPU.python main.py --effect color_spectrum - You can also modify
config.jsonand just runpython main.py - Exit by typing
xand enter
Effects development
- Copy one of the script & config pairs in
effects/(e.g.myeffect.pyandmyeffect.json) and then it can be passed as--effect=myeffect(json values can be read fromhyperion.argslike in normal hyperion effects) - Adjust gstreamer parameters
- See
spectrum_dump.pyfor explanation of parameters for GstSpectrumDump - Using
vumeterandbandsyou can adjust the type of received magnitudes (self.magnitudes)- With
vumeter=Trueyou get 4 magnitudes which correspond to peaks and decays for the L/R channels - With
vumeter=Falseyou get spectrum magnitudes for the amount ofbands(defaults to 128)
- With
- See
- Update the leds by modifying the bytearray
self.ledsDataaccording to values inself.magnitudes(I've done it in methodupdate_leds())
Effect: VU Meter
- Volume bars for left and right of your hyperion setup, or by setting indices manually
- Min and max volume and colors can be adjusted from config
Effect: Color spectrum
- Leds strip is divided into octaves 1-8
- Low frequencies start from red, ending in pink at high frequencies
- Adjust your sound volume if the leds are too dim or bright (no volume normalization yet)
- Config has a field
band-width-exp, if you have performance issues, try with higher values (it sets FFT bin size to 2^x Hz, e.g. 2^3 = 8 Hz, affects on bass accuracy) - Set
mirrorto false if you want to use whole strip instead of splitting and mirroring - Color range can be adjusted with
hue-fromandhue-toparameters (0.0-1.0) - New config parameter
matrix- Modified version for matrix setups, need to use protobuf connection instead of json
- Example config.json for matrix:
{
"json": false,
"proto": true,
"effect": "color_spectrum",
"config": "/etc/hyperion/hyperion.config.json",
"host": "localhost",
"port": 19445,
"audiosrc": "autoaudiosrc",
"interval": 50,
"matrix": true
}
Contribute
Pull requests are welcome but try to follow the style in existing code and check yours using pylint (.pylintrc included).
* Check this if you have pulseaudio: #4
** Windows istructions were removed since performance was poor due to the fact that Gstreamer is meant for Linux