Add set eq
Release / build (amd64, darwin, macos-latest) (push) Has been cancelled
Release / build (amd64, linux, ubuntu-latest) (push) Has been cancelled
Release / build (amd64, windows, windows-latest) (push) Has been cancelled
Release / build (arm64, darwin, macos-latest) (push) Has been cancelled
Release / build (arm64, linux, ubuntu-latest) (push) Has been cancelled
Release / release (push) Has been cancelled
Release / update-homebrew (push) Has been cancelled

This commit is contained in:
Bjarne Øverli
2026-03-29 23:41:00 +02:00
parent aadf6141e1
commit fde4b8b8a5
7 changed files with 96 additions and 5 deletions
+1
View File
@@ -281,6 +281,7 @@ cliamp.player.set_volume(-5) -- set volume in dB (-30 to +6)
cliamp.player.set_speed(1.25) -- set playback speed (0.25 to 2.0)
cliamp.player.seek(30) -- seek to 30 seconds
cliamp.player.toggle_mono() -- toggle mono output
cliamp.player.set_eq_preset("Rock") -- switch EQ preset by name (sets bands + UI label)
cliamp.player.set_eq_band(1, 6) -- set EQ band 1 to +6 dB (bands 1-10, -12 to +12)
```
+8
View File
@@ -85,6 +85,14 @@ func registerControlAPI(L *lua.LState, cliamp *lua.LTable, ctrl *ControlProvider
return 0
}))
L.SetField(tbl, "set_eq_preset", L.NewFunction(func(L *lua.LState) int {
if !guard("set_eq_preset") {
return 0
}
ctrl.SetEQPreset(L.CheckString(1))
return 0
}))
L.SetField(tbl, "set_eq_band", L.NewFunction(func(L *lua.LState) int {
if !guard("set_eq_band") {
return 0
+4 -3
View File
@@ -63,9 +63,10 @@ type ControlProvider struct {
ToggleMono func()
TogglePause func()
Stop func()
Seek func(secs float64)
Next func() // injected via prog.Send
Prev func() // injected via prog.Send
Seek func(secs float64)
SetEQPreset func(name string) // injected via prog.Send
Next func() // injected via prog.Send
Prev func() // injected via prog.Send
}
// Manager owns all loaded plugins and dispatches events to them.
+3 -2
View File
@@ -275,8 +275,9 @@ func run(overrides config.Overrides, positional []string) error {
Seek: func(secs float64) {
_ = p.Seek(time.Duration(secs * float64(time.Second)))
},
Next: func() { prog.Send(mpris.NextMsg{}) },
Prev: func() { prog.Send(mpris.PrevMsg{}) },
SetEQPreset: func(name string) { prog.Send(ui.SetEQPresetMsg{Name: name}) },
Next: func() { prog.Send(mpris.NextMsg{}) },
Prev: func() { prog.Send(mpris.PrevMsg{}) },
})
}
+73
View File
@@ -0,0 +1,73 @@
-- auto-eq.lua — Automatically switch EQ preset based on track genre.
local p = plugin.register({
name = "auto-eq",
type = "hook",
version = "1.0.0",
description = "Switch EQ based on track genre",
permissions = {"control"},
})
-- Map genres to EQ presets. Keys are lowercase for case-insensitive matching.
local genre_map = {
rock = "Rock",
["alt-rock"] = "Rock",
["hard rock"] = "Rock",
metal = "Rock",
punk = "Rock",
grunge = "Rock",
pop = "Pop",
["synth-pop"] = "Pop",
jazz = "Jazz",
["smooth jazz"] = "Jazz",
bossa = "Jazz",
classical = "Classical",
orchestra = "Classical",
electronic = "Electronic",
edm = "Electronic",
techno = "Electronic",
house = "Electronic",
trance = "Electronic",
ambient = "Electronic",
["hip-hop"] = "Hip-Hop",
["hip hop"] = "Hip-Hop",
rap = "Hip-Hop",
trap = "Hip-Hop",
["r&b"] = "R&B",
rnb = "R&B",
soul = "R&B",
folk = "Acoustic",
acoustic = "Acoustic",
["singer-songwriter"] = "Acoustic",
country = "Acoustic",
podcast = "Podcast",
speech = "Podcast",
lofi = "Late Night",
["lo-fi"] = "Late Night",
chill = "Late Night",
}
local last_preset = nil
p:on("track.change", function(track)
local genre = (track.genre or ""):lower()
local preset = genre_map[genre]
if not preset then
-- Try partial match for compound genres like "Indie Rock".
for key, val in pairs(genre_map) do
if genre:find(key, 1, true) then
preset = val
break
end
end
end
preset = preset or "Flat"
if preset ~= last_preset then
cliamp.player.set_eq_preset(preset)
last_preset = preset
cliamp.log.info("EQ -> " .. preset .. " (genre: " .. (track.genre or "unknown") .. ")")
end
end)
+3
View File
@@ -17,6 +17,9 @@ import (
// — Message types used by tea.Cmd constructors —
// SetEQPresetMsg is sent by Lua plugins to change the EQ preset by name.
type SetEQPresetMsg struct{ Name string }
type tracksLoadedMsg []playlist.Track
// feedsLoadedMsg carries tracks resolved from remote feed/M3U URLs,
+4
View File
@@ -1296,6 +1296,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.player.Close()
m.quitting = true
return m, tea.Quit
case SetEQPresetMsg:
m.SetEQPreset(msg.Name)
return m, nil
}
return m, nil