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 audio add-on 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!
== Audio block == Audio samples are normally in the range -1 to 1. Indices are zero-based, and values written by an add-on must be finite. {| class="wikitable" ! Method !! Effect or result |- | <code>audio:size()</code> || Number of samples in the block. |- | <code>audio:sampleRate()</code> || Sample rate in hertz. |- | <code>audio:sessionTime()</code> || Time in seconds at the start of the block. |- | <code>audio:samplePosition()</code> || Absolute sample position at the start of the block. |- | <code>audio:get(index)</code> || Reads one sample. |- | <code>audio:set(index, value)</code> || Replaces one sample. |- | <code>audio:map(function(sample, index, time) ... end)</code> || Replaces every sample with the callback result. |- | <code>audio:gain(amount)</code> || Applies a constant linear gain. |- | <code>audio:limit(peak)</code> || Limits samples to the symmetric positive peak. |- | <code>audio:mixTone(frequencyHz, level)</code> || Adds a sine tone and reserves headroom. |- | <code>audio:mixTone(frequencyHz, level, reserveHeadroom)</code> || Adds a tone with optional headroom reservation. |- | <code>audio:fill(value)</code> || Replaces the block with a constant value. |- | <code>audio:peak()</code> || Absolute peak of the current block. |- | <code>audio:rms()</code> || Root mean square level of the current block. |} The tone frequency must be at least zero and below half the sample rate. The peak supplied to <code>limit</code> must be positive.
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)