presets   chat   music   threads  
Tutorial: Basic equalizer manipulation with Lua
deer

Lua console

To get access to the console, just run the command eqe core in Terminal or SSH. It will give you a prompt where you can run Lua code.

Once you're done messing around, you can type exit to exit the console.

Equalizer manipulation

Here are some lines of code that you can run that change the EQ:

eqe.preamp = 20 --> set preamp
eqe[2] = filters.eq --> create a new peaking EQ band
eqe[3] = filters.highpass --> create a new highpass band
eqe[3] = nil --> delete a band
eqe.load 'name of preset' --> load preset
eqe.save 'name of preset' --> save preset
eqe.flatten() --> flatten EQ to system default (basically turning it off)

And here's how to change properties of specific band. When changing the gain, frequency or Q-factor of a band, you will have to run eqe.update() in order for the changes to take effect:

eqe[1].gain = -0.5 --> set gain of first band
eqe[1].frequency = 10000 --> set frequency of first band
eqe[1].Q = 0.6 --> set Q-factor of first band
eqe.update(1) --> apply changes to EQ

Running Lua through activator

See this thread for more info.

Custom filter types

All of the filters were scripted in Lua, found in /var/tweak/com.r333d.eqe/lua/core/filter. You can create your own custom filter types. For example, here's the code for the peaking EQ (found in /var/tweak/com.r333d.eqe/lua/core/filter/eq.lua):

local super = require 'filter/base/gain'
local filter = super:new()

function filter:process(omega, alpha, A)
    local a0 = 1 + alpha/A
    local omegaC = math.cos(omega)

    return
        (1 + alpha*A) / a0,
        (-2 * omegaC) / a0,
        (1 - alpha*A) / a0,
        (-2 * omegaC) / a0,
        (1 - alpha/A) / a0
end

return filter

I honestly don't understand how biquad filters work (I copy pasted this code from here) but if you do, this can be pretty powerful.

Conclusion

This is a pretty barebones intro. There's a lot more you can do with this, I will amend this with more documentation later.