
= General concepts

[[import-export]]
== Import/export

ReaLearn can import and export data in 2 formats:

link:https://www.json.org/json-en.html[JSON]::
A wide-spread data exchange format.
It's a text format, so if you are familiar with the search & replace feature of your favorite link:https://en.wikipedia.org/wiki/Text_editor[text editor], this is one way to do batch editing.

link:https://luau.org/[Luau]::
A full-blown programming language derived from the famous Lua language that is also used in REAPER itself.

[TIP]
====

For the programmers and script junkies out there: It's perfectly possible to program ReaLearn from outside by passing it a snippet of JSON via https://www.reaper.fm/sdk/reascript/reascripthelp.html#TrackFX_SetNamedConfigParm[`TrackFX_SetNamedConfigParm()`].
Parameter name is `set-state`.
This mechanism is implemented on ReaLearn side using https://www.reaper.fm/sdk/vst/vst_ext.php[REAPER's named parameter mechanism] (search for `named_parameter_name`).

Example that assumes that the first FX of the first track is a ReaLearn instance:

[source,lua]
----
local track = reaper.GetTrack(0, 0)
local state = [[
{
  "controlDeviceId": "62",
  "feedbackDeviceId": "fx-output",
  "mappings": [
    {
      "name": "1",
      "source": {
        "type": 1,
        "channel": 0,
        "number": 64
      },
      "mode": {},
      "target": {
        "type": 2
      }
    }
  ]
}
]]
reaper.TrackFX_SetNamedConfigParm(track, 0, "set-state", state)
----
====

[#feedback-relay]
== Feedback relay

Feedback _relay_ happens when a feedback-enabled mapping becomes inactive and another feedback-enabled mapping with the same xref:key-concepts.adoc#source[] becomes active. In that case, ReaLearn has to swap the displayed value of the previous mapping target with the displayed value of the new mapping target.