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
- 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=-2
in end of/etc/modprobe.d/alsa-base.conf
to prevent loopback device for getting first card index - Enable loopback device
modprobe snd-aloop
(and type linesnd-aloop
to /etc/modules to make it permanent) - Included are 2 different asound configuration files:
asound.conf.loopback
andasound.conf.mic
. Chooseasound.conf.mic
, if you have a microphone attached to your raspberry pi through e.g. an external USB sound card. The sound levels recorded by the microphone will be used to create the effects. If you do not have a microphone, useasound.conf.loopback
to utilize the loopback device. - Rename the chosen asound configuration file to
.asoundrc
and copy it to 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.py
with options:--config=<path>
path to hyperion config file (defaults to./hyperion.config.json
)--gui
for gui--json
for network connection (--host=<ip> --port=<port>
)--help
to 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
- Enable audio so we can use alsa and loopback: Add
dtparam=audio=on
to/boot/config.txt
.
- 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=-2
in 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-aloop
to /etc/modules to make it permanent) - Included are 2 different asound configuration files:
asound.conf.loopback
andasound.conf.mic
. Chooseasound.conf.mic
, if you have a microphone attached to your Raspberry pi through e.g. an external USB sound card. The sound levels recorded by the microphone will be used to create the effects. If you do not have a microphone, useasound.conf.loopback
to utilize the loopback device. - Rename the chosen asound configuration file to
.asoundrc
and copy it to your home folder (backup old if exists) and change the soundcard index if needed ("hw:<card>,<device>"
, checkaplay -l
) * - 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/music
runmpc ls | mpc add
to add all files to playlist, thenmpc play
(checkmpc help
for 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-5
but uses quite a lot of CPU.python main.py --effect color_spectrum
- You can also modify
config.json
and just runpython main.py
- Exit by typing
x
and enter
- Copy one of the script & config pairs in
effects/
(e.g.myeffect.py
andmyeffect.json
) and then it can be passed as--effect=myeffect
(json values can be read fromhyperion.args
like in normal hyperion effects) - Adjust gstreamer parameters
- See
spectrum_dump.py
for explanation of parameters for GstSpectrumDump - Using
vumeter
andbands
you can adjust the type of received magnitudes (self.magnitudes
)- With
vumeter=True
you get 4 magnitudes which correspond to peaks and decays for the L/R channels - With
vumeter=False
you get spectrum magnitudes for the amount ofbands
(defaults to 128)
- With
- See
- Update the leds by modifying the bytearray
self.ledsData
according to values inself.magnitudes
(I've done it in methodupdate_leds()
)
- 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
- 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
mirror
to false if you want to use whole strip instead of splitting and mirroring - TODO: Adjustable colors
- New config parameter
matrix
- Modified version for matrix setups, need to use protobuf connection instead of json
- Disable black border detection in hyperion config for this to work properly
* Check this if you have pulseaudio: #4
** Windows instructions were removed since performance was poor due to the fact that Gstreamer is meant for Linux