Automation points for the master Lua

En lua, How do I set automation points for the master volume?
Sorry; the manual is very difficult to navigate.

If you find the manual too dense, I suggest to search example scripts instead.

Start by searching for master → master_out, and gain → gain_control and you’ll find that the “Fader Automation” snippet provides most of the information…

github’s search functionality isn’t bad (ardour/share/scripts at master · Ardour/ardour · GitHub), or you can use your favorite IDE…

I hope that helps.

1 Like

Is my script correct for master volume automation?

-- Vérifier qu'une session est ouverte
    if not Session then
      print("❌ Aucune session Ardour active.")
      return
    end

    -- Récupérer le master bus
    local master = Session:master_out()
    if not master then
      print("❌ Master introuvable.")
      return
    end
    print("✅ Master trouvé : " .. master:name())

   -- 🔹 Récupérer le contrôle de gain
   local gain_control = master:gain_control()
    if not gain_control then
      print("❌ Contrôle de gain introuvable.")
      return
    end

    -- Liste d’automation
    local alist = gain_control:alist()
    if not alist then
      print("❌ Impossible d’obtenir la liste d’automation du gain.")
      return
    end

    -- Effacer tous les anciens points
    alist:clear(Temporal.timepos_t(0), Temporal.timepos_t(1e9))
    print("🧹 Points d’automation effacés.")


    -- Taux d’échantillonnage
    local sr = Session:nominal_sample_rate()
    print("🎚️ Sample rate :", sr)

    Session:begin_reversible_command("Automation Volume Master")

    for pair in string.gmatch(gainPoints, "([^;]+)") do
      local t, g = pair:match("([^,]+),([^,]+)")
      local time_sec = tonumber(t)
      local mult = tonumber(g)
      if time_sec and mult then
        -- Conversion du facteur → dB → coefficient interne
        local db = 20 * math.log(mult, 10)
        local coeff = ARDOUR.DSP.dB_to_coefficient(db)

        -- ✅ Conversion secondes → échantillons
        local sample_pos = math.floor(time_sec * sr)
        local timepos = Temporal.timepos_t(sample_pos)

        alist:add(timepos, coeff)
        print(string.format("→ t=%.1fs (%.0f samples) | mult=%.2f | %.2fdB | coeff=%.6f",
              time_sec, sample_pos, mult, db, coeff))
      else
        print("⚠️ Erreur de parsing :", pair)
      end
    end

    Session:commit_reversible_command(nil)
    print("âś… Automation du volume master mise Ă  jour.")

It’s not far off.

  • You can use clear_list() [1] instead of :clear(..., ...) with large time value.
  • Why do you convert gain-factor to dB manually, and the convert it back using a built-in function?
  • you do need to add before/after state for undo as shown in the “Fader Automation” snippet that I mentioned above

Also where does gainPoints come from?

[1] The Ardour Manual - Lua Bindings Class Reference

1 Like

Looks like LLM output. Excessive emoji use and commenting always gives it away. Not judging, but you will not get around diving into the documentation. The models are usually not well trained on application specific dsl such as Ardour LUA. Take it as an opportunity to be guided into the right direction of learning.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.