Documentation ¶
Overview ¶
Package ambilight implements a MPD client that is able to play .mood files generated by the moodbar utility: https://en.wikipedia.org/wiki/Moodbar Those are files that consist of 1000 RGB triples of which each represents the composition of frequencies at a certain point in an audio file.
In other words: An audio file is split in 1000(*) little parts where each part is colored based on the low frequencies (red), mids (green) and highs (blue). The combined color is then saved as RGB triple.
This mpd client can automatically create a dir with a .mood database. When a song is played the respective .mood file is located and loaded and synchronized to the music. Additionally a bit of color correction is done and (linear) fading is done between the individual samples for a smoother look.
The ambilightd can be controlled by a simple, line based network protocol which currently supports the following commands:
off -- Turn off the payback. on -- Turn the playback on. state -- Print the state ("1\n" or "0\n" on the socket) quit -- Quit ambilightd. close -- Terminate the connection.
(*) Fixed number given by the moodbar, okay for most songs today,
not very suitable for e.g. Moonsorrow with their 30+ minute songs.
Index ¶
Constants ¶
const UseDefaultMoodbar = false
UseDefaultMoodbar enables a builtin default moodbar if none was found
Variables ¶
var DefaultMoodbar = []timedColor{}/* 1000 elements not displayed */
DefaultMoodbar is played when no other moodbar was found but playback is requested. It's supposed to be a smooth soothing fade.
It was generated by this python session:
>>> import math >>> import colorsys >>> h = [i * (255 / 1000) for i in range(1000)]] >>> s = [1 for i in range(1000)] >>> v = [(+math.sin(i / 7) + 1) / 2 for i in range(1000)] >>> rgb = [tuple([int(v * 255) for v in colorsys.hsv_to_rgb(h, s, v)]) for h,s,v in zip(h, s, v)] >>> print('\n'.join(['{%d, %d, %d, 0},' % (v[0], v[1], v[2]) for v in rgb]))
Functions ¶
func Run ¶
Run starts ambilightd with the settings defined in `cfg`. It will stop execution when `ctx` was canceled. If something show-stopping occurs on startup an error is returned.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connects to a running ambilightd instance and can enable/disable the led playback, check the state or quit the daemon remotely.
type Config ¶
type Config struct { // MPDHost of the mpd server (usually localhost) MPDHost string // MPDPort of the mpd server (usually 6600) MPDPort int // Lightd host (usually localhost) LightdHost string // Lightd port (usually 3333) LightdPort int // Host of the ambilight command server AmbiHost string // Port of the command server AmbiPort int // MusicDir is the root path of the mpd database MusicDir string // MoodDir contains all moodfiles for certain files (if any) MoodDir string // UpdateMoodDatabase makes the client update the db and exit afterwards. UpdateMoodDatabase bool // Name of the RGB LED driver binary (`catlight` for my desktop) BinaryName string }
Config holds all possible adjusting screws for ambilightd.