sfxr.lua/doc/index.html

1798 lines
45 KiB
HTML
Raw Normal View History

2016-03-01 23:40:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>sfxr.lua Documentation</title>
<link rel="stylesheet" href="ldoc_pale.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>sfxr.lua</h1>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Constants">Constants</a></li>
2016-03-01 23:40:31 +00:00
<li><a href="#Class_Sound">Class Sound </a></li>
<li><a href="#Parameters">Parameters</a></li>
2016-03-05 20:41:25 +00:00
<li><a href="#ParametersEnvelope">ParametersEnvelope</a></li>
<li><a href="#ParametersFrequency">ParametersFrequency</a></li>
<li><a href="#ParametersVibrato">ParametersVibrato</a></li>
<li><a href="#ParametersChange">ParametersChange</a></li>
<li><a href="#ParametersDuty">ParametersDuty</a></li>
<li><a href="#ParametersPhaser">ParametersPhaser</a></li>
<li><a href="#ParametersLowpass">ParametersLowpass</a></li>
<li><a href="#ParametersHighpass">ParametersHighpass</a></li>
<li><a href="#ParametersVolume">ParametersVolume</a></li>
2016-03-05 20:03:04 +00:00
<li><a href="#Randomization">Randomization</a></li>
2016-03-05 20:41:25 +00:00
<li><a href="#SavingAndLoading">SavingAndLoading</a></li>
2016-03-01 23:40:31 +00:00
</ul>
<h2>API</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><strong>sfxr</strong></li>
</ul>
</div>
<div id="content">
<h1>Module <code>sfxr</code></h1>
2016-03-05 20:41:25 +00:00
<p>A port of the sfxr sound effect synthesizer to pure Lua, designed to be used
together with the <em>awesome</em> <a href="https://love2d.org">LÖVE</a> game framework.</p>
2016-03-01 23:40:31 +00:00
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#newSound">newSound (...)</a></td>
2016-03-05 19:27:09 +00:00
<td class="summary">Construct and return a new <a href="index.html#Sound">Sound</a> instance.</td>
2016-03-01 23:40:31 +00:00
</tr>
</table>
<h2><a href="#Constants">Constants</a></h2>
2016-03-01 23:40:31 +00:00
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#VERSION">VERSION</a></td>
<td class="summary">The module version (SemVer format)</td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#WAVEFORM">WAVEFORM</a></td>
2016-03-05 19:17:58 +00:00
<td class="summary"><a href="https://en.wikipedia.org/wiki/Waveform">Waveform</a> constants</td>
2016-03-01 23:40:31 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#SAMPLERATE">SAMPLERATE</a></td>
2016-03-05 19:17:58 +00:00
<td class="summary"><a href="https://en.wikipedia.org/wiki/Sampling_(signal_processing">Sampling rate</a> constants
2016-03-01 23:40:31 +00:00
(use the number values directly, these are just for lookup)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#BITDEPTH">BITDEPTH</a></td>
2016-03-05 19:17:58 +00:00
<td class="summary"><a href="https://en.wikipedia.org/wiki/Audio_bit_depth">Bit depth</a> constants
2016-03-01 23:40:31 +00:00
(use the number values directly, these are just for lookup)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#ENDIANNESS">ENDIANNESS</a></td>
2016-03-05 19:17:58 +00:00
<td class="summary"><a href="https://en.wikipedia.org/wiki/Endianness">Endianness</a> constants</td>
2016-03-01 23:40:31 +00:00
</tr>
</table>
<h2><a href="#Class_Sound">Class Sound </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:__init">sfxr.Sound:__init ()</a></td>
<td class="summary">Initialize the Sound instance.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:resetParameters">sfxr.Sound:resetParameters ()</a></td>
<td class="summary">Set all parameters to their default values.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:sanitizeParameters">sfxr.Sound:sanitizeParameters ()</a></td>
<td class="summary">Clamp all parameters within their sane ranges.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:generate">sfxr.Sound:generate ([rate=44100[, depth=0]])</a></td>
<td class="summary">Generate the sound and yield the sample data.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:getEnvelopeLimit">sfxr.Sound:getEnvelopeLimit ([rate=44100])</a></td>
<td class="summary">Get the maximum sample limit allowed by the current envelope.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:generateTable">sfxr.Sound:generateTable ([rate=44100[, depth=0[, tab]]])</a></td>
<td class="summary">Generate the sound into a table.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:generateString">sfxr.Sound:generateString ([rate=44100[, depth=16[, endianness=0]]])</a></td>
<td class="summary">Generate the sound to a binary string.</td>
2016-03-05 19:17:58 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:generateSoundData">sfxr.Sound:generateSoundData ([rate=44100[, depth=0[, sounddata]]])</a></td>
<td class="summary">Synthesize the sound to a LÖVE SoundData instance.</td>
2016-03-05 19:17:58 +00:00
</tr>
</table>
<h2><a href="#Parameters">Parameters</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.volume">self.volume</a></td>
<td class="summary"><strong>The sound volume and gain all samples are multiplied with</strong></td>
2016-03-01 23:40:31 +00:00
</tr>
<tr>
2016-03-05 20:03:04 +00:00
<td class="name" nowrap><a href="#self.supersampling">self.supersampling</a></td>
<td class="summary">Number of supersampling passes to perform (<em>default</em> 8)</td>
</tr>
<tr>
2016-03-01 23:40:31 +00:00
<td class="name" nowrap><a href="#self.repeatspeed">self.repeatspeed</a></td>
<td class="summary">Repeat speed:
Times to repeat the frequency slide over the course of the envelope
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.waveform">self.waveform</a></td>
2016-03-05 19:17:58 +00:00
<td class="summary">The base <a href="index.html#WAVEFORM">waveform</a> (<em>default</em> <a href="index.html#WAVEFORM">SQUARE</a>)</td>
2016-03-01 23:40:31 +00:00
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersEnvelope">ParametersEnvelope</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.envelope">self.envelope</a></td>
<td class="summary"><strong>The <a href="https://en.wikipedia.org/wiki/Synthesizer#Attack_
Decay_Sustain_Release_.28ADSR.29_envelope">ASD envelope</a> that controls the sound
amplitude (volume) over time</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.envelope.attack">self.envelope.attack</a></td>
<td class="summary">Attack time:
2016-03-05 19:17:58 +00:00
Time the sound takes to reach its peak amplitude
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.envelope.sustain">self.envelope.sustain</a></td>
<td class="summary">Sustain time:
2016-03-05 19:17:58 +00:00
Time the sound stays on its peak amplitude
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.envelope.punch">self.envelope.punch</a></td>
<td class="summary">Sustain punch:
2016-03-05 19:17:58 +00:00
Amount by which the sound peak amplitude is increased at the start of the
2016-03-01 23:40:31 +00:00
sustain time
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.envelope.decay">self.envelope.decay</a></td>
<td class="summary">Decay time:
Time the sound takes to decay after its sustain time
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersFrequency">ParametersFrequency</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.frequency">self.frequency</a></td>
<td class="summary"><strong>The base and minimum frequencies of the tone generator and their
slides</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.frequency.start">self.frequency.start</a></td>
<td class="summary">Start frequency:
Base tone of the sound, before sliding
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.frequency.min">self.frequency.min</a></td>
<td class="summary">Min frequency:
Tone below which the sound will get cut off
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.frequency.slide">self.frequency.slide</a></td>
<td class="summary">Slide:
2016-03-05 19:17:58 +00:00
Amount by which the frequency is increased or decreased over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.frequency.dslide">self.frequency.dslide</a></td>
<td class="summary">Delta slide:
2016-03-05 19:17:58 +00:00
Amount by which the slide is increased or decreased over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersVibrato">ParametersVibrato</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.vibrato">self.vibrato</a></td>
<td class="summary"><strong>A <a href="https://en.wikipedia.org/wiki/Vibrato">vibrato</a>-like amplitude
modulation effect</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.vibrato.depth">self.vibrato.depth</a></td>
<td class="summary">Vibrato depth:
2016-03-05 19:17:58 +00:00
Amount of amplitude modulation
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.vibrato.speed">self.vibrato.speed</a></td>
<td class="summary">Vibrato speed:
Oscillation speed of the vibrato
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.vibrato.delay">self.vibrato.delay</a></td>
<td class="summary">Vibrato delay:
Unused and unimplemented
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersChange">ParametersChange</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.change">self.change</a></td>
<td class="summary"><strong>Changes the frequency mid-sound to create a characteristic
"coin"-effect</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.change.amount">self.change.amount</a></td>
<td class="summary">Change amount:
Amount by which the frequency is changed mid-sound
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.change.speed">self.change.speed</a></td>
<td class="summary">Change speed:
Time before the frequency change happens
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersDuty">ParametersDuty</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.duty">self.duty</a></td>
<td class="summary"><strong>The <a href="https://en.wikipedia.org/wiki/Duty_cycle">duty</a> of the square
waveform</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.duty.ratio">self.duty.ratio</a></td>
<td class="summary">Square duty:
Width of the square wave pulse cycle (doesn't affect other waveforms)
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.duty.sweep">self.duty.sweep</a></td>
<td class="summary">Duty sweep:
2016-03-05 19:17:58 +00:00
Amount by which the square duty is increased or decreased over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersPhaser">ParametersPhaser</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.phaser">self.phaser</a></td>
<td class="summary"><strong>A simple <a href="https://en.wikipedia.org/wiki/Phaser_(effect">phaser</a>
effect</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.phaser.offset">self.phaser.offset</a></td>
<td class="summary">Phaser offset:
Amount by which the phaser signal is offset from the sound
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.phaser.sweep">self.phaser.sweep</a></td>
<td class="summary">Phaser sweep:
2016-03-05 19:17:58 +00:00
Amount by which the phaser offset is increased or decreased over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersLowpass">ParametersLowpass</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.lowpass">self.lowpass</a></td>
<td class="summary"><strong>A <a href="https://en.wikipedia.org/wiki/Low-pass_filter">lowpass filter</a>
effect</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.lowpass.cutoff">self.lowpass.cutoff</a></td>
<td class="summary">Lowpass filter cutoff:
Lower bound for frequencies allowed to pass through this filter
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.lowpass.sweep">self.lowpass.sweep</a></td>
<td class="summary">Lowpass filter cutoff sweep:
Amount by which the LP filter cutoff is increased or decreased
2016-03-05 19:17:58 +00:00
over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.lowpass.resonance">self.lowpass.resonance</a></td>
<td class="summary">Lowpass filter resonance:
Amount by which certain resonant frequencies near the cutoff are
increased
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersHighpass">ParametersHighpass</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#self.highpass">self.highpass</a></td>
<td class="summary"><strong>A <a href="https://en.wikipedia.org/wiki/High-pass_filter">highpass filter</a>
effect</strong></td>
</tr>
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.highpass.cutoff">self.highpass.cutoff</a></td>
<td class="summary">Highpass filter cutoff:
Upper bound for frequencies allowed to pass through this filter
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#self.highpass.sweep">self.highpass.sweep</a></td>
<td class="summary">Highpass filter cutoff sweep:
Amount by which the HP filter cutoff is increased or decreased
2016-03-05 19:17:58 +00:00
over time
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#ParametersVolume">ParametersVolume</a></h2>
<table class="function_list">
2016-03-01 23:40:31 +00:00
<tr>
<td class="name" nowrap><a href="#self.volume.master">self.volume.master</a></td>
<td class="summary">Master volume (<em>default</em> 0.5)</td>
2016-03-01 23:40:31 +00:00
</tr>
<tr>
<td class="name" nowrap><a href="#self.volume.sound">self.volume.sound</a></td>
<td class="summary">Additional gain (<em>default</em> 0.5)</td>
2016-03-01 23:40:31 +00:00
</tr>
</table>
2016-03-05 20:03:04 +00:00
<h2><a href="#Randomization">Randomization</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomize">sfxr.Sound:randomize ([seed])</a></td>
<td class="summary">Randomize all sound parameters</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:mutate">sfxr.Sound:mutate ([amount=1][, seed], changefreq)</a></td>
<td class="summary">Mutate all sound parameters</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomPickup">sfxr.Sound:randomPickup ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a "pick up" sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomLaser">sfxr.Sound:randomLaser ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a laser sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomExplosion">sfxr.Sound:randomExplosion ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate an explosion sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomPowerup">sfxr.Sound:randomPowerup ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a "power up" sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomHit">sfxr.Sound:randomHit ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a hit sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomJump">sfxr.Sound:randomJump ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a jump sound</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:randomBlip">sfxr.Sound:randomBlip ([seed])</a></td>
<td class="summary">Randomize all sound parameters to generate a "blip" sound</td>
</tr>
</table>
2016-03-05 20:41:25 +00:00
<h2><a href="#SavingAndLoading">SavingAndLoading</a></h2>
2016-03-05 20:03:04 +00:00
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:exportWAV">sfxr.Sound:exportWAV (f[, rate=44100[, depth=0]])</a></td>
<td class="summary">Generate and export the audio data to a PCM WAVE file.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:save">sfxr.Sound:save (f[, minify=true])</a></td>
<td class="summary">Save the sound parameters to a file as a Lua table</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:load">sfxr.Sound:load (f)</a></td>
<td class="summary">Load the sound parameters from a file containing a Lua table</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:saveBinary">sfxr.Sound:saveBinary (f)</a></td>
<td class="summary">Save the sound parameters to a file in the sfxr binary format (version 102)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#sfxr.Sound:loadBinary">sfxr.Sound:loadBinary (f)</a></td>
<td class="summary">Load the sound parameters from a file in the sfxr binary format
(version 100-102)</td>
</tr>
</table>
2016-03-01 23:40:31 +00:00
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "newSound"></a>
<strong>newSound (...)</strong>
</dt>
<dd>
2016-03-05 19:27:09 +00:00
Construct and return a new <a href="index.html#Sound">Sound</a> instance.
2016-03-01 23:40:31 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="index.html#Sound">Sound</a></span>
a Sound instance
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Constants"></a>Constants</h2>
2016-03-01 23:40:31 +00:00
<dl class="function">
<dt>
<a name = "VERSION"></a>
<strong>VERSION</strong>
</dt>
<dd>
The module version (SemVer format)
</dd>
2016-03-01 23:40:31 +00:00
<dt>
<a name = "WAVEFORM"></a>
<strong>WAVEFORM</strong>
</dt>
<dd>
2016-03-05 19:17:58 +00:00
<a href="https://en.wikipedia.org/wiki/Waveform">Waveform</a> constants
2016-03-01 23:40:31 +00:00
<h3>Fields:</h3>
<ul>
<li><span class="parameter">SQUARE</span>
2016-03-05 19:27:09 +00:00
<a href="https://en.wikipedia.org/wiki/Square_wave">square wave</a> (<code>= 0</code>)
2016-03-01 23:40:31 +00:00
</li>
<li><span class="parameter">SAW</span>
2016-03-05 19:27:09 +00:00
<a href="https://en.wikipedia.org/wiki/Sawtooth_wave">saw wave</a> (<code>= 1</code>)
2016-03-01 23:40:31 +00:00
</li>
<li><span class="parameter">SINE</span>
2016-03-05 19:27:09 +00:00
<a href="https://en.wikipedia.org/wiki/Sine_wave">sine wave</a> (<code>= 2</code>)
2016-03-01 23:40:31 +00:00
</li>
<li><span class="parameter">NOISE</span>
2016-03-05 19:27:09 +00:00
<a href="https://en.wikipedia.org/wiki/White_noise">white noise</a> (<code>= 3</code>)
2016-03-01 23:40:31 +00:00
</li>
</ul>
</dd>
<dt>
<a name = "SAMPLERATE"></a>
<strong>SAMPLERATE</strong>
</dt>
<dd>
2016-03-05 19:17:58 +00:00
<a href="https://en.wikipedia.org/wiki/Sampling_(signal_processing">Sampling rate</a> constants
2016-03-01 23:40:31 +00:00
(use the number values directly, these are just for lookup)
<h3>Fields:</h3>
<ul>
<li><span class="parameter">22050</span>
22.05 kHz (<code>= 22050</code>)
</li>
<li><span class="parameter">44100</span>
44.1 kHz (<code>= 44100</code>)
</li>
</ul>
</dd>
<dt>
<a name = "BITDEPTH"></a>
<strong>BITDEPTH</strong>
</dt>
<dd>
2016-03-05 19:17:58 +00:00
<a href="https://en.wikipedia.org/wiki/Audio_bit_depth">Bit depth</a> constants
2016-03-01 23:40:31 +00:00
(use the number values directly, these are just for lookup)
<h3>Fields:</h3>
<ul>
<li><span class="parameter">0</span>
floating point bit depth, -1 to 1 (<code>= 0</code>)
</li>
<li><span class="parameter">8</span>
unsigned 8 bit, 0x00 to 0xFF (<code>= 8</code>)
</li>
<li><span class="parameter">16</span>
unsigned 16 bit, 0x0000 to 0xFFFF (<code>= 16</code>)
</li>
</ul>
</dd>
<dt>
<a name = "ENDIANNESS"></a>
<strong>ENDIANNESS</strong>
</dt>
<dd>
2016-03-05 19:17:58 +00:00
<a href="https://en.wikipedia.org/wiki/Endianness">Endianness</a> constants
2016-03-01 23:40:31 +00:00
<h3>Fields:</h3>
<ul>
<li><span class="parameter">LITTLE</span>
little endian (<code>= 0</code>)
</li>
<li><span class="parameter">BIG</span>
big endian (<code>= 1</code>)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Class_Sound"></a>Class Sound </h2>
<div class="section-description">
The main Sound class.
</div>
<dl class="function">
<dt>
<a name = "sfxr.Sound:__init"></a>
<strong>sfxr.Sound:__init ()</strong>
</dt>
<dd>
Initialize the Sound instance.
Called by <a href="index.html#newSound">the constructor</a>.
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:resetParameters"></a>
<strong>sfxr.Sound:resetParameters ()</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Set all parameters to their default values. Does not affect
2016-03-05 20:03:04 +00:00
<a href="index.html#self.supersampling">supersampling</a> and <a href="index.html#self.volume">volume</a>.
Called by <a href="index.html#sfxr.Sound:__init">the initializer</a>.
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:sanitizeParameters"></a>
<strong>sfxr.Sound:sanitizeParameters ()</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Clamp all parameters within their sane ranges.
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:generate"></a>
<strong>sfxr.Sound:generate ([rate=44100[, depth=0]])</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Generate the sound and yield the sample data.
2016-03-05 19:17:58 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
<li><span class="parameter">depth</span>
<span class="types"><a class="type" href="index.html#BITDEPTH">BITDEPTH</a></span>
the bit depth
(<em>default</em> 0)
</li>
</ul>
2016-03-05 19:17:58 +00:00
<h3>Returns:</h3>
<ol>
2016-03-05 19:17:58 +00:00
<span class="types"><span class="type">function()</span></span>
a generator that yields the next sample when called
</ol>
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x"
2016-03-05 19:17:58 +00:00
<h3>Usage:</h3>
<ul>
<pre class="example"> <span class="keyword">for</span> s <span class="keyword">in</span> sound:generate(<span class="number">44100</span>, <span class="number">0</span>) <span class="keyword">do</span>
<span class="comment">-- do something with s
</span> <span class="keyword">end</span></pre>
</ul>
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:getEnvelopeLimit"></a>
<strong>sfxr.Sound:getEnvelopeLimit ([rate=44100])</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Get the maximum sample limit allowed by the current envelope.
Does not take any other limits into account, so the returned count might be
higher than samples actually generated. Still useful though.
2016-03-05 19:17:58 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
</ul>
2016-03-05 19:17:58 +00:00
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x"
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:generateTable"></a>
<strong>sfxr.Sound:generateTable ([rate=44100[, depth=0[, tab]]])</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Generate the sound into a table.
2016-03-05 19:17:58 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
<li><span class="parameter">depth</span>
<span class="types"><a class="type" href="index.html#BITDEPTH">BITDEPTH</a></span>
the bit depth
(<em>default</em> 0)
</li>
<li><span class="parameter">tab</span>
<span class="types"><span class="type">{}</span></span>
the table to synthesize into
(<em>optional</em>)
</li>
</ul>
2016-03-05 19:17:58 +00:00
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">{number,...}</span></span>
the table filled with sample data</li>
<li>
<span class="types"><span class="type">int</span></span>
the number of written samples (== #tab)</li>
</ol>
2016-03-05 19:17:58 +00:00
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x"
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:generateString"></a>
<strong>sfxr.Sound:generateString ([rate=44100[, depth=16[, endianness=0]]])</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Generate the sound to a binary string.
2016-03-05 19:17:58 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
<li><span class="parameter">depth</span>
<span class="types"><a class="type" href="index.html#BITDEPTH">BITDEPTH</a></span>
the bit depth (may not be <a href="index.html#BITDEPTH">0</a>)
(<em>default</em> 16)
</li>
<li><span class="parameter">endianness</span>
<span class="types"><a class="type" href="index.html#ENDIANNESS">ENDIANNESS</a></span>
the endianness (ignored when depth == 8)
(<em>default</em> 0)
</li>
</ul>
2016-03-05 19:17:58 +00:00
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
a binary string of sample data</li>
<li>
<span class="types"><span class="type">int</span></span>
the number of written samples</li>
</ol>
2016-03-05 19:17:58 +00:00
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x", "invalid endianness: x"
2016-03-05 19:17:58 +00:00
</dd>
<dt>
<a name = "sfxr.Sound:generateSoundData"></a>
<strong>sfxr.Sound:generateSoundData ([rate=44100[, depth=0[, sounddata]]])</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
Synthesize the sound to a LÖVE SoundData instance.
2016-03-05 19:17:58 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
<li><span class="parameter">depth</span>
<span class="types"><a class="type" href="index.html#BITDEPTH">BITDEPTH</a></span>
the bit depth
(<em>default</em> 0)
</li>
<li><span class="parameter">sounddata</span>
<span class="types"><span class="type">love.sound.SoundData</span></span>
a SoundData instance (will be
created if not passed)
(<em>optional</em>)
</li>
</ul>
2016-03-05 19:17:58 +00:00
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">love.sound.SoundData</span></span>
a SoundData instance</li>
<li>
<span class="types"><span class="type">int</span></span>
the number of written samples</li>
</ol>
2016-03-05 19:17:58 +00:00
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x"
2016-03-05 19:17:58 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
<h2 class="section-header "><a name="Parameters"></a>Parameters</h2>
<dl class="function">
2016-03-05 19:17:58 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.volume"></a>
<strong>self.volume</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>The sound volume and gain all samples are multiplied with</strong>
2016-03-05 19:17:58 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.supersampling"></a>
<strong>self.supersampling</strong>
2016-03-05 19:17:58 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Number of supersampling passes to perform (<em>default</em> 8)
2016-03-05 19:17:58 +00:00
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.repeatspeed"></a>
<strong>self.repeatspeed</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Repeat speed:
Times to repeat the frequency slide over the course of the envelope
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.waveform"></a>
<strong>self.waveform</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
The base <a href="index.html#WAVEFORM">waveform</a> (<em>default</em> <a href="index.html#WAVEFORM">SQUARE</a>)
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersEnvelope"></a>ParametersEnvelope</h2>
2016-03-05 20:03:04 +00:00
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.envelope"></a>
<strong>self.envelope</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>The <a href="https://en.wikipedia.org/wiki/Synthesizer#Attack_
Decay_Sustain_Release_.28ADSR.29_envelope">ASD envelope</a> that controls the sound
amplitude (volume) over time</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.envelope.attack"></a>
<strong>self.envelope.attack</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Attack time:
Time the sound takes to reach its peak amplitude
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.envelope.sustain"></a>
<strong>self.envelope.sustain</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Sustain time:
Time the sound stays on its peak amplitude
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.envelope.punch"></a>
<strong>self.envelope.punch</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Sustain punch:
Amount by which the sound peak amplitude is increased at the start of the
sustain time
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.envelope.decay"></a>
<strong>self.envelope.decay</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Decay time:
Time the sound takes to decay after its sustain time
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersFrequency"></a>ParametersFrequency</h2>
2016-03-05 20:03:04 +00:00
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.frequency"></a>
<strong>self.frequency</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>The base and minimum frequencies of the tone generator and their
slides</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.frequency.start"></a>
<strong>self.frequency.start</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Start frequency:
Base tone of the sound, before sliding
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.frequency.min"></a>
<strong>self.frequency.min</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Min frequency:
Tone below which the sound will get cut off
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.frequency.slide"></a>
<strong>self.frequency.slide</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Slide:
Amount by which the frequency is increased or decreased over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.frequency.dslide"></a>
<strong>self.frequency.dslide</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Delta slide:
Amount by which the slide is increased or decreased over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersVibrato"></a>ParametersVibrato</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.vibrato"></a>
<strong>self.vibrato</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>A <a href="https://en.wikipedia.org/wiki/Vibrato">vibrato</a>-like amplitude
modulation effect</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.vibrato.depth"></a>
<strong>self.vibrato.depth</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Vibrato depth:
Amount of amplitude modulation
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.vibrato.speed"></a>
<strong>self.vibrato.speed</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Vibrato speed:
Oscillation speed of the vibrato
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.vibrato.delay"></a>
<strong>self.vibrato.delay</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Vibrato delay:
Unused and unimplemented
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersChange"></a>ParametersChange</h2>
2016-03-05 20:03:04 +00:00
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.change"></a>
<strong>self.change</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>Changes the frequency mid-sound to create a characteristic
"coin"-effect</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.change.amount"></a>
<strong>self.change.amount</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Change amount:
Amount by which the frequency is changed mid-sound
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.change.speed"></a>
<strong>self.change.speed</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Change speed:
Time before the frequency change happens
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
</dd>
2016-03-05 20:03:04 +00:00
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersDuty"></a>ParametersDuty</h2>
2016-03-05 20:03:04 +00:00
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.duty"></a>
<strong>self.duty</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>The <a href="https://en.wikipedia.org/wiki/Duty_cycle">duty</a> of the square
waveform</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.duty.ratio"></a>
<strong>self.duty.ratio</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Square duty:
Width of the square wave pulse cycle (doesn't affect other waveforms)
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.duty.sweep"></a>
<strong>self.duty.sweep</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Duty sweep:
Amount by which the square duty is increased or decreased over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersPhaser"></a>ParametersPhaser</h2>
2016-03-05 20:03:04 +00:00
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.phaser"></a>
<strong>self.phaser</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>A simple <a href="https://en.wikipedia.org/wiki/Phaser_(effect">phaser</a>
effect</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.phaser.offset"></a>
<strong>self.phaser.offset</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Phaser offset:
Amount by which the phaser signal is offset from the sound
2016-03-01 23:40:31 +00:00
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.phaser.sweep"></a>
<strong>self.phaser.sweep</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Phaser sweep:
Amount by which the phaser offset is increased or decreased over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersLowpass"></a>ParametersLowpass</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.lowpass"></a>
<strong>self.lowpass</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>A <a href="https://en.wikipedia.org/wiki/Low-pass_filter">lowpass filter</a>
effect</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.lowpass.cutoff"></a>
<strong>self.lowpass.cutoff</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Lowpass filter cutoff:
Lower bound for frequencies allowed to pass through this filter
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.lowpass.sweep"></a>
<strong>self.lowpass.sweep</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Lowpass filter cutoff sweep:
Amount by which the LP filter cutoff is increased or decreased
over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.lowpass.resonance"></a>
<strong>self.lowpass.resonance</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Lowpass filter resonance:
Amount by which certain resonant frequencies near the cutoff are
increased
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersHighpass"></a>ParametersHighpass</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.highpass"></a>
<strong>self.highpass</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
<strong>A <a href="https://en.wikipedia.org/wiki/High-pass_filter">highpass filter</a>
effect</strong>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.highpass.cutoff"></a>
<strong>self.highpass.cutoff</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Highpass filter cutoff:
Upper bound for frequencies allowed to pass through this filter
(<em>default</em> 0.0, <em>min</em> 0.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.highpass.sweep"></a>
<strong>self.highpass.sweep</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Highpass filter cutoff sweep:
Amount by which the HP filter cutoff is increased or decreased
over time
(<em>default</em> 0.0, <em>min</em> -1.0, <em>max</em> 1.0)
2016-03-01 23:40:31 +00:00
</dd>
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="ParametersVolume"></a>ParametersVolume</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.volume.master"></a>
<strong>self.volume.master</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Master volume (<em>default</em> 0.5)
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "self.volume.sound"></a>
<strong>self.volume.sound</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Additional gain (<em>default</em> 0.5)
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
</dl>
<h2 class="section-header "><a name="Randomization"></a>Randomization</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomize"></a>
<strong>sfxr.Sound:randomize ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:mutate"></a>
<strong>sfxr.Sound:mutate ([amount=1][, seed], changefreq)</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Mutate all sound parameters
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">amount</span>
<span class="types"><span class="type">number</span></span>
by how much to mutate the parameters
(<em>default</em> 1)
</li>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
<li><span class="parameter">changefreq</span>
<span class="types"><span class="type">bool</span></span>
whether to change the frequency parameters
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomPickup"></a>
<strong>sfxr.Sound:randomPickup ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a "pick up" sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomLaser"></a>
<strong>sfxr.Sound:randomLaser ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a laser sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
2016-03-05 20:03:04 +00:00
<dt>
<a name = "sfxr.Sound:randomExplosion"></a>
<strong>sfxr.Sound:randomExplosion ([seed])</strong>
</dt>
<dd>
Randomize all sound parameters to generate an explosion sound
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
</dd>
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomPowerup"></a>
<strong>sfxr.Sound:randomPowerup ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a "power up" sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomHit"></a>
<strong>sfxr.Sound:randomHit ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a hit sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomJump"></a>
<strong>sfxr.Sound:randomJump ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a jump sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:randomBlip"></a>
<strong>sfxr.Sound:randomBlip ([seed])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Randomize all sound parameters to generate a "blip" sound
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">seed</span>
<span class="types"><span class="type">number</span></span>
a random seed
(<em>optional</em>)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
</dl>
2016-03-05 20:41:25 +00:00
<h2 class="section-header "><a name="SavingAndLoading"></a>SavingAndLoading</h2>
<dl class="function">
2016-03-01 23:40:31 +00:00
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:exportWAV"></a>
<strong>sfxr.Sound:exportWAV (f[, rate=44100[, depth=0]])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Generate and export the audio data to a PCM WAVE file.
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">file</span> or <span class="type">love.filesystem.File</span></span>
a path or file in <code>wb</code>-mode
(passed files will not be closed)
</li>
<li><span class="parameter">rate</span>
<span class="types"><a class="type" href="index.html#SAMPLERATE">SAMPLERATE</a></span>
the sampling rate
(<em>default</em> 44100)
</li>
<li><span class="parameter">depth</span>
<span class="types"><a class="type" href="index.html#BITDEPTH">BITDEPTH</a></span>
the bit depth
(<em>default</em> 0)
</li>
</ul>
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Raises:</h3>
"invalid sampling rate: x", "invalid bit depth: x"
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:save"></a>
<strong>sfxr.Sound:save (f[, minify=true])</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Save the sound parameters to a file as a Lua table
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">file</span> or <span class="type">love.filesystem.File</span></span>
a path or file in <code>w</code>-mode
(passed files will not be closed)
</li>
<li><span class="parameter">minify</span>
<span class="types"><span class="type">bool</span></span>
whether to minify the output or not
(<em>default</em> true)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:load"></a>
<strong>sfxr.Sound:load (f)</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Load the sound parameters from a file containing a Lua table
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">file</span> or <span class="type">love.filesystem.File</span></span>
a path or file in <code>r</code>-mode
(passed files will not be closed)
</li>
</ul>
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Raises:</h3>
"incompatible version: x.x.x"
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:saveBinary"></a>
<strong>sfxr.Sound:saveBinary (f)</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Save the sound parameters to a file in the sfxr binary format (version 102)
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">file</span> or <span class="type">love.filesystem.File</span></span>
a path or file in <code>wb</code>-mode
(passed files will not be closed)
</li>
</ul>
2016-03-01 23:40:31 +00:00
</dd>
<dt>
2016-03-05 20:03:04 +00:00
<a name = "sfxr.Sound:loadBinary"></a>
<strong>sfxr.Sound:loadBinary (f)</strong>
2016-03-01 23:40:31 +00:00
</dt>
<dd>
2016-03-05 20:03:04 +00:00
Load the sound parameters from a file in the sfxr binary format
(version 100-102)
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">f</span>
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">file</span> or <span class="type">love.filesystem.File</span></span>
a path or file in <code>rb</code>-mode
(passed files will not be closed)
</li>
</ul>
2016-03-01 23:40:31 +00:00
2016-03-05 20:03:04 +00:00
<h3>Raises:</h3>
"incompatible version: x", "unexpected file length"
2016-03-01 23:40:31 +00:00
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
2016-03-05 20:41:25 +00:00
<i style="float:right;">Last updated 2016-03-05 21:40:35 </i>
2016-03-01 23:40:31 +00:00
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>