Skip to content

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

License

Notifications You must be signed in to change notification settings

aliebald/MiLight-Controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

This project is currently in a beta stage. Feedback would be greatly appreciated!

alt text

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.

General Idea

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.

Setup

Prerequisites

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.

General setup

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.

Setup the music visualizer

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.

Planned Features

  • UI style revise
  • More options for Music Modes
  • More/improved Music Modes
  • Custom Modes: Similar modes to the Build in Modes (which are build into the MiLight Controller) but more extensive.
  • Custom scenes: Create, customize and apply custom scenes. A scene defines a color, brightness and on/off state for each zone. This way it is possible to quickly change the current light setting in the whole room.
  • Saturation control
    • There is currently a problem with the binary code send to the bridge.

Contact

If you have any suggestions or general feedback, feel free to contact me: contact.liebald(at)gmail.com

License

Apache License 2.0

About

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

Topics

Resources

License

Stars

Watchers

Forks