MiLight Controller

Java
MiLight
A comprehensive light controller for the MiLight bridge v5. Featuring a music visualizer and a responsive web design.

A Comprehensive Light Controller

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.
MiLight Controller

Main Features

  • Music visualizer with numerous modes
  • Select and save custom colors
  • Single and multi zone control
  • Build-in light Modes
  • Automatic bridge discovery
  • Responsive web design

Music Visualizer

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:
  • Beat cooldown: minimum time in milliseconds between beats. A high value can lead to skipped beats while a low value may lead to the same beat being detected twice. Setting this to a higher value reduces load on the network, Bridge and controllers. A good starting point could be between 80-200, but values outside this range can make sense too.
  • Beat sensitivity: changes the general sensitivity of the beat detection algorithm. A lower value will lead to more beats being detected, while a higher value will lead to less false positives.

Beat Detection Algorithm

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.

Interested? Find out More

© 2023 Alexander Liebald