<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.simtx.net/index.php?action=history&amp;feed=atom&amp;title=Lua_extension_API</id>
	<title>Lua extension API - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.simtx.net/index.php?action=history&amp;feed=atom&amp;title=Lua_extension_API"/>
	<link rel="alternate" type="text/html" href="https://wiki.simtx.net/index.php?title=Lua_extension_API&amp;action=history"/>
	<updated>2026-08-06T11:09:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.simtx.net/index.php?title=Lua_extension_API&amp;diff=567&amp;oldid=prev</id>
		<title>Clanker: Add and update user documentation for Lua extensions and the catalog</title>
		<link rel="alternate" type="text/html" href="https://wiki.simtx.net/index.php?title=Lua_extension_API&amp;diff=567&amp;oldid=prev"/>
		<updated>2026-08-06T09:12:24Z</updated>

		<summary type="html">&lt;p&gt;Add and update user documentation for Lua extensions and the catalog&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The &amp;#039;&amp;#039;&amp;#039;SimTX Lua extension API&amp;#039;&amp;#039;&amp;#039; is the public interface available to extension entry files and modules. API version 1 provides registration functions, declarative controls and inputs, digital signal processing helpers, and type-specific callback objects.&lt;br /&gt;
&lt;br /&gt;
== Version check ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
simtx.require_api(1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;simtx.api_version&amp;lt;/code&amp;gt; contains the available API version. &amp;lt;code&amp;gt;simtx.require_api(version)&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; when the requested positive version is available and raises an error otherwise.&lt;br /&gt;
&lt;br /&gt;
== Registration functions ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Alias&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.modulation{...}&amp;lt;/code&amp;gt; || Registers a modulation or media mode. || &amp;lt;code&amp;gt;simtx.register{...}&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.addon{...}&amp;lt;/code&amp;gt; || Registers an audio add-on. || &amp;lt;code&amp;gt;simtx.processor{...}&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.action{...}&amp;lt;/code&amp;gt; || Registers a user-invoked tool. || &amp;lt;code&amp;gt;simtx.tool{...}&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.theme{...}&amp;lt;/code&amp;gt; || Registers an application theme. || None&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Names must be 1 to 64 printable characters and must be unique within their type in one package. A package may call a registration function more than once.&lt;br /&gt;
&lt;br /&gt;
== Modulation declaration ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field !! Default !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; || Required || Display name.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt; || Empty || User-facing description.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;bandwidth&amp;lt;/code&amp;gt; || 3000 for IQ, usual width for audio output || Suggested initial transmit bandwidth in hertz. The operator may change it.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;controls&amp;lt;/code&amp;gt; || Empty || List of controls described below.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;quot;audio&amp;quot;&amp;lt;/code&amp;gt; || Shorthand for one input. &amp;lt;code&amp;gt;&amp;quot;none&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;quot;generator&amp;quot;&amp;lt;/code&amp;gt; declare a source-free mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;inputs&amp;lt;/code&amp;gt; || One required audio input || List of declared inputs. It cannot be combined with &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;quot;iq&amp;quot;&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;quot;iq&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;audio&amp;quot;&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;{type=&amp;quot;audio&amp;quot;, modulation=&amp;quot;USB&amp;quot;}&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; || None || Optional &amp;lt;code&amp;gt;function(ctx)&amp;lt;/code&amp;gt; called once when a session starts.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;process&amp;lt;/code&amp;gt; || Required || &amp;lt;code&amp;gt;function(ctx)&amp;lt;/code&amp;gt; called for each output block. &amp;lt;code&amp;gt;modulate&amp;lt;/code&amp;gt; is an alias.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; || None || Optional &amp;lt;code&amp;gt;function(ctx)&amp;lt;/code&amp;gt; called once when the session closes.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
An IQ-output mode produces complex baseband directly. An audio-output mode produces mono audio and then uses a built-in RF modulation selected by the operator. The default built-in modulation is USB. Any built-in mode other than IQ may be used.&lt;br /&gt;
&lt;br /&gt;
The callback object is documented in [[Lua modulation API]].&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
Controls create ordinary transmitter widgets and provide live values to callbacks. An ID must start with a letter or underscore, contain only letters, digits, and underscores, and contain at most 64 characters. Control and input IDs in one modulation must be unique.&lt;br /&gt;
&lt;br /&gt;
The helper form is recommended:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
controls = {&lt;br /&gt;
  simtx.controls.slider(&amp;quot;gain&amp;quot;, {&lt;br /&gt;
    label = &amp;quot;Gain&amp;quot;, help = &amp;quot;Linear input gain.&amp;quot;, unit = &amp;quot;x&amp;quot;,&lt;br /&gt;
    precision = 2, min = 0, max = 2, step = 0.01, default = 1,&lt;br /&gt;
  }),&lt;br /&gt;
  simtx.controls.toggle(&amp;quot;enabled&amp;quot;, {label = &amp;quot;Enabled&amp;quot;, default = true}),&lt;br /&gt;
  simtx.controls.text(&amp;quot;message&amp;quot;, {label = &amp;quot;Message&amp;quot;, default = &amp;quot;CQ&amp;quot;}),&lt;br /&gt;
  simtx.controls.choice(&amp;quot;shape&amp;quot;, {&lt;br /&gt;
    label = &amp;quot;Shape&amp;quot;,&lt;br /&gt;
    options = {&lt;br /&gt;
      &amp;quot;soft&amp;quot;,&lt;br /&gt;
      {value = &amp;quot;hard&amp;quot;, label = &amp;quot;Hard edges&amp;quot;},&lt;br /&gt;
    },&lt;br /&gt;
    default = &amp;quot;soft&amp;quot;,&lt;br /&gt;
  }),&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The equivalent long form is a table with an &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt;. The slider aliases are &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;. Checkbox aliases are &amp;lt;code&amp;gt;check&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;toggle&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; is a text alias. Choice aliases are &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dropdown&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;combo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Control !! Fields and defaults !! Lua value&lt;br /&gt;
|-&lt;br /&gt;
| Slider || &amp;lt;code&amp;gt;min=0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;max=1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;step=0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;default=min&amp;lt;/code&amp;gt;, optional &amp;lt;code&amp;gt;unit&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;precision&amp;lt;/code&amp;gt; || Number&lt;br /&gt;
|-&lt;br /&gt;
| Checkbox || &amp;lt;code&amp;gt;default=false&amp;lt;/code&amp;gt; || Boolean&lt;br /&gt;
|-&lt;br /&gt;
| Text || &amp;lt;code&amp;gt;default=&amp;quot;&amp;quot;&amp;lt;/code&amp;gt; || String&lt;br /&gt;
|-&lt;br /&gt;
| Choice || Non-empty &amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; is the first option || String value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All controls accept &amp;lt;code&amp;gt;label&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;. A label defaults to the ID. Help text may contain at most 300 characters. Slider units may contain at most 16 characters. Slider precision may be 0 to 8, or may be omitted so the interface derives it from the step. Slider values and bounds must be finite, &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt; must exceed &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt;, and the default must be within the range.&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
Inputs ask the operator for data needed by a modulation. Audio uses the normal &amp;#039;&amp;#039;&amp;#039;Transmission Source&amp;#039;&amp;#039;&amp;#039; section. Other types create file pickers below the modulation controls.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
inputs = {&lt;br /&gt;
  simtx.inputs.audio(&amp;quot;audio&amp;quot;, {label = &amp;quot;Programme audio&amp;quot;}),&lt;br /&gt;
  simtx.inputs.image(&amp;quot;picture&amp;quot;, {&lt;br /&gt;
    label = &amp;quot;Picture&amp;quot;, required = true,&lt;br /&gt;
    accept = {&amp;quot;png&amp;quot;, &amp;quot;jpg&amp;quot;, &amp;quot;jpeg&amp;quot;},&lt;br /&gt;
  }),&lt;br /&gt;
  simtx.inputs.video(&amp;quot;clip&amp;quot;, {required = false}),&lt;br /&gt;
  simtx.inputs.file(&amp;quot;data&amp;quot;, {extensions = {&amp;quot;txt&amp;quot;, &amp;quot;bin&amp;quot;}}),&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each input accepts &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;label&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;help&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;required&amp;lt;/code&amp;gt;, and a filename-extension list named either &amp;lt;code&amp;gt;accept&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;extensions&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;required&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;. Canonical types are &amp;lt;code&amp;gt;audio&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;image&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;video&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt;. Audio aliases are &amp;lt;code&amp;gt;sound&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;microphone&amp;lt;/code&amp;gt;. Image aliases are &amp;lt;code&amp;gt;picture&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;photo&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;movie&amp;lt;/code&amp;gt; is a video alias. File aliases are &amp;lt;code&amp;gt;bytes&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;binary&amp;lt;/code&amp;gt;. The default file filters are WAV, MP3, AIFF, AIF, and AU for audio; PNG, JPEG, GIF, and BMP for images; and MP4, MOV, and M4V for video. A generic file input has no default filter.&lt;br /&gt;
&lt;br /&gt;
The objects supplied for image, video, and file inputs are documented in [[Lua modulation API]].&lt;br /&gt;
&lt;br /&gt;
== DSP helpers ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Result&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.dsp.db(decibels)&amp;lt;/code&amp;gt; || Converts a voltage or amplitude ratio in decibels to a linear value using 10&amp;lt;sup&amp;gt;dB/20&amp;lt;/sup&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.dsp.to_db(linear)&amp;lt;/code&amp;gt; || Converts an absolute linear amplitude to decibels. Zero returns negative infinity.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.dsp.clamp(value, minimum, maximum)&amp;lt;/code&amp;gt; || Restricts a value to the inclusive range. The maximum must not be below the minimum.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;simtx.dsp.lerp(from, to, amount)&amp;lt;/code&amp;gt; || Returns &amp;lt;code&amp;gt;from + (to - from) * amount&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Standard Lua facilities ==&lt;br /&gt;
The computation-oriented base, string, table, math, bit32, and coroutine functions are available. Package modules use the restricted &amp;lt;code&amp;gt;require&amp;lt;/code&amp;gt; described in [[Lua extension manifest]]. File, network, operating-system, Java, package-loader, and debug access are not available.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua extensions]]&lt;/div&gt;</summary>
		<author><name>Clanker</name></author>
	</entry>
</feed>