2 stable releases

2.1.0 Sep 2, 2024
2.0.0 Aug 28, 2024
1.2.0 Aug 21, 2024

#421 in Network programming

Download history 175/week @ 2024-08-05 63/week @ 2024-08-12 367/week @ 2024-08-19 136/week @ 2024-08-26 164/week @ 2024-09-02

905 downloads per month

MIT license

33KB
671 lines

Audioleaf

An audio visualizer for Nanoleaf Canvas

Installation

Install from cargo with cargo install audioleaf. Make sure that the directory with cargo binaries (by default $HOME\.cargo\bin) is added to your $PATH.

For users of Arch-based distros, audioleaf is also available as a package in the AUR. You can install it with your AUR helper of choice, for example with yay: yay -S audioleaf.

Configuration

All configuration of audioleaf is done through the audioleaf.toml file, located in $HOME/.config/audioleaf. All the options are described below:

  • audio_device: The audio input device that will be the source of audio data for the visualizer.
  • min/max_freq: The minimum/maximum frequency (in Hz) to be included in the visualization.
  • default_gain: A non-negative real number, the bigger it is the more the audio samples are amplified before being visualized. While in audioleaf you can decrease and increase gain with the - and = keys. This settings doesn't affect your listening volume.
  • hues: A list of hues to be used in the visualizer's color palette, specified as angles between 0 and 360 degrees on the standard color wheel.
  • nl_config.primary_axis: The primary coordinate by which the panels will be sorted. Possible values are "x" (left → right) and "y" (bottom → top).
  • nl_config.sort_primary/secondary: The direction in which the panels will be sorted on the primary/secondary axis. Possible values are "asc" (ascending) and "desc" (descending).
  • nl_config.active_panels: A list of numbers of panels that should be lit up during visualization. These numbers relate to the sorting method mentioned earlier. For example, if you sorted your panels first by Y ascending, then by X descending, then the first panel will be in the lower right-hand corner of your setup and the last one will be in the upper left-hand corner. Frequencies will be visualized according to these panel numbers: the higher the number, the higher the frequency.
  • nl_config.token_file_path: The path where audioleaf will look for the file containing the Nanoleaf authentication token.
  • nl_config.ip: The local IP address of your Nanoleaf device.
  • nl_config.port: The port on your host to which the UDP socket handling the connection to the panels will be bound.

Usage

IMPORTANT: When running audioleaf for the first time, do the following:

  • Press and hold your Nanoleaf control panels's power button for about 5 seconds, until the icons start sequentially flashing.
  • While the icons are flashing, run audioleaf --ip <local ip address of your Nanoleaf device> (for example audioleaf --ip 192.168.0.101). You can find that IP address by logging in to your WiFi router's admin panel and navigating to the DHCP clients list. Your Nanoleaf will have a MAC address starting with 00:55:DA:5. Simply copy its assigned IP address.
  • If everything went correctly, audioleaf will notify you about it. Check your ~/.config directory - a directory audioleaf with two files in it (audioleaf.toml - the config file and nltoken - containing the Nanoleaf auth token) will have been created there.

Make sure to take a look at the config file and edit the options to match your Nanoleaf setup - the default settings are suited to my own panels and will very likely not work well with yours.

After a successful first-time setup, simply run audioleaf to launch the program. To see available options add the --help flag. Press Shift + Q to quit.

Troubleshooting

If you're playing audio and nothing is showing on your panels, check (for example using pavucontrol on Linux) if your recording device for Audioleaf isn't set to e.g. your microphone, if you have one.

Dependencies

~10–44MB
~679K SLoC