Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
SimTX Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Lua modulation API
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Native-rate audio === Input audio is resampled to the Lua processing rate by default. In this mode, <code>ctx:audioN()</code> matches <code>ctx:n()</code>, <code>ctx:audioSampleRate()</code> matches <code>ctx:sampleRate()</code>, and the one-to-one helpers can be used normally. A modulation may set <code>resample_audio = false</code> to receive audio at the source's native rate: <syntaxhighlight lang="lua"> simtx.modulation { name = "Custom resampler", sample_rate = 240000, resample_audio = false, process = function(ctx) local outputCount = ctx:n() local outputRate = ctx:sampleRate() local inputCount = ctx:audioN() local inputRate = ctx:audioSampleRate() -- Read native input with ctx:audio(index). -- Produce outputCount samples with ctx:iq() or ctx:generate(). -- Keep filter and FIFO state in Lua across calls. end, } </syntaxhighlight> The input and output blocks cover the same elapsed duration, subject to sample-count rounding. Their sample counts can differ. During extreme downsampling, an output block can occasionally contain zero samples. When the input and output rates or block sizes differ, <code>ctx:map()</code>, <code>ctx:passthrough()</code>, <code>ctx:gain()</code>, and <code>ctx:mixTone()</code> raise an error because they require one input sample per output sample. Use <code>ctx:audio()</code> to read the native block and write the resampled result with <code>ctx:iq()</code> or <code>ctx:generate()</code>. The extension is responsible for its resampling filter, FIFO, and state. The registration fields are documented in [[Lua extension API#Modulation declaration|Lua extension API]].
Summary:
Please note that all contributions to SimTX Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
SimTX Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)