A comprehensive light controller for the MiLight bridge version 5.
MiLight-Controller
(working name) makes it possible to control your MiLight light bulbs and led strips from any device with a web browser.
Simply run the server on a device on your network and connect to it via your browser. Your MiLight bridges will already show up, you only need to select one and are ready to go! To use the build in music controller, go to settings and select an audio stream from the device the server is running on.
This project is currently in a beta stage. Feedback would be greatly appreciated!
The Music visualizer will listen to the selected audio stream and apply a light effect every time it detects a beat. To fine tune the beat detection you can modify the following settings on the web ui:
About 43 times a second the algorithm takes a sample of the current audio output. In the first step the audio sample gets normalized to avoid the volume of impacting the beat detection. After that, we compute the energy of the sample. The energy is simply the sum of the absolute values in the buffer. The energy then gets stored in a buffer, together with the last 86 (~2 seconds, this value may not be final) samples energy. We use this buffer to then calculate the variance of all values in it. This will help to adjust to different styles of music, by dynamically adjusting the threshold. The threshold is calculated using the variance, a user set sensitivity as well as a static value. If the current energy is greater than the threshold, and the last detected beat is at least n milliseconds ago, where n is the user input value for Beat cooldown, a beat gets detected.
This beat detection algorithm is loosely based on the article Beat Detection Algorithms by Frédéric Patin. If you are interested in this topic, a more in depth description and more complex algorithms, I can recommend his article. Please note the beat detection algorithm used in this project is not exactly what he describes.
An alternative implementation, better suited for music with a lot of noise, may come in the feature, but the current version already works pretty well.
Java 15 and a MiLight Bridge v.5 is required. In case you have another MiLight Bridge, feel free to test this and contact me with your results.
Download the latest release from the releases page.
After that, you can simply execute MiLightController.sh
or execute the jar via a terminal of your choice, e.g. under windows: java -jar '.\MiLight Controller.jar'
.
Your Ip Address as well as the used port will show up in the terminal after the server is started.
To use the music visualizer an audio stream needs to be selected. To select an audio stream, got to the settings (click on the 3 bars on the top right -> settings) and select one of the available streams under "Audio input for music visualizer".
If you want to use the output of your pc, you currently need some type of audio loopback. If you use Windows, you can use the Stereomix or try the primary sound recording driver. Otherwise, you can try using a physical audio loop back with e.g. a jack cable.
If you have any suggestions or general feedback, feel free to contact me: contact.liebald(at)gmail.com
Apache License 2.0