Skip to content

Commit

Permalink
Improved documentation of Wave-Table-Based Oscillators.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Mar 14, 2024
1 parent c47b42f commit a416853
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,5 @@ <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>

<!--
MkDocs version : 1.4.3
Build Date UTC : 2024-03-14 10:06:11.788104+00:00
Build Date UTC : 2024-03-14 12:57:31.831763+00:00
-->
10 changes: 8 additions & 2 deletions docs/libs/oscillators/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ <h2 id="wave-table-based-oscillators">Wave-Table-Based Oscillators</h2>
<p>Note that there is a numerical problem with several phasor functions built using the internal
<code>phasor_imp</code>. The reason is that the incremental step is smaller than <code>ma.EPSILON</code>, so it will
have no effect when summed to 1, but it will be enough to make the fractional function wrap
around when summed to 0.</p>
around when summed to 0. An example of this problem can be observed when running the following code:</p>
<p><code>process = os.phasor(1.0, -.001);</code></p>
<p>The output of this program is the sequence 1, 0, 1, 0, 1... This happens because the negative incremental
step is greater than <code>-ma.EPSILON</code>, which will have no effect when summed to 1, but it will be significant
enough to make the fractional function wrap around when summed to 0.</p>
<p>You may want to consider clipping the incremental step to guarantee that the phasor will
always run correctly for its full cycle. Otherwise, for increments smaller than <code>ma.EPSILON</code>,
phasor would initially run but it'd eventually get stuck once the output gets big enough.</p>
Expand Down Expand Up @@ -615,6 +619,8 @@ <h4 id="usage_2">Usage</h4>
<li><code>tablesize</code>: the table size</li>
<li><code>freq</code>: the frequency in Hz</li>
</ul>
<p>Note that <code>tablesize</code> is just a multiplier for the output of a unit-amp phasor
so <code>phasor(1.0, freq)</code> can be used to generate a phasor output in the range [0, 1[.</p>
<hr />
<h3 id="oshs_phasor"><code>(os.)hs_phasor</code></h3>
<p>Hardsyncing phasor to be used with a <code>rdtable</code>.</p>
Expand Down Expand Up @@ -727,7 +733,7 @@ <h4 id="usage_12">Usage</h4>
</ul>
<hr />
<h3 id="osm_osccos"><code>(os.)m_osccos</code></h3>
<p>Sine wave oscillator based on the <code>sin</code> mathematical function.</p>
<p>Sine wave oscillator based on the <code>cos</code> mathematical function.</p>
<h4 id="usage_13">Usage</h4>
<pre><code>m_osccos(freq) : _
</code></pre>
Expand Down
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

Binary file modified docs/sitemap.xml.gz
Binary file not shown.
12 changes: 10 additions & 2 deletions oscillators.lib
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ pl = library("platform.lib");
// Note that there is a numerical problem with several phasor functions built using the internal
// `phasor_imp`. The reason is that the incremental step is smaller than `ma.EPSILON`, so it will
// have no effect when summed to 1, but it will be enough to make the fractional function wrap
// around when summed to 0.
// around when summed to 0. An example of this problem can be observed when running the following code:
//
// `process = os.phasor(1.0, -.001);`
//
// The output of this program is the sequence 1, 0, 1, 0, 1... This happens because the negative incremental
// step is greater than `-ma.EPSILON`, which will have no effect when summed to 1, but it will be significant
// enough to make the fractional function wrap around when summed to 0.
//
// You may want to consider clipping the incremental step to guarantee that the phasor will
// always run correctly for its full cycle. Otherwise, for increments smaller than `ma.EPSILON`,
Expand Down Expand Up @@ -179,6 +185,8 @@ phasor_table(tablesize, freq, reset, phase) = phasor_imp(freq, reset, phase) : *
// * `tablesize`: the table size
// * `freq`: the frequency in Hz
//
// Note that `tablesize` is just a multiplier for the output of a unit-amp phasor
// so `phasor(1.0, freq)` can be used to generate a phasor output in the range [0, 1[.
//------------------------------------------------------------
phasor(tablesize, freq) = phasor_table(tablesize, freq, 0, 0);

Expand Down Expand Up @@ -381,7 +389,7 @@ m_oscsin(freq) = lf_sawpos(freq) : *(2*ma.PI) : sin;


//-----------------------`(os.)m_osccos`------------------------
// Sine wave oscillator based on the `sin` mathematical function.
// Sine wave oscillator based on the `cos` mathematical function.
//
// #### Usage
//
Expand Down

0 comments on commit a416853

Please sign in to comment.