Skip to content

Commit

Permalink
Correct use of OPTIMIZE.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Mar 14, 2024
1 parent 8f9da91 commit c47b42f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 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 09:46:06.368593+00:00
Build Date UTC : 2024-03-14 10:06:11.788104+00:00
-->
2 changes: 1 addition & 1 deletion docs/libs/oscillators/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ <h2 id="wave-table-based-oscillators">Wave-Table-Based Oscillators</h2>
<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>
<p>The internal <code>phasor_imp</code> function has to be modified setting <code>OPTIMIZE</code> to 1 to use the
<p>The internal <code>phasor_imp</code> function has to be modified setting <code>OPTIMIZE</code> to 0 to use the
slower but more accurate version of the phasor.</p>
<hr />
<h3 id="ossinwaveform"><code>(os.)sinwaveform</code></h3>
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.
10 changes: 5 additions & 5 deletions oscillators.lib
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pl = library("platform.lib");
// always run correctly for its full cycle. Otherwise, for increments smaller than `ma.EPSILON`,
// phasor would initially run but it'd eventually get stuck once the output gets big enough.
//
// The internal `phasor_imp` function has to be modified setting `OPTIMIZE` to 1 to use the
// The internal `phasor_imp` function has to be modified setting `OPTIMIZE` to 0 to use the
// slower but more accurate version of the phasor.
//========================================================================================

Expand Down Expand Up @@ -145,13 +145,13 @@ with {
// Change this to 1 to use the slower but more accurate version
OPTIMIZE = 0;

// Faster but less accurate version
incr(0) = incr_aux;

// To make sure that the incremental step is greater or equal to EPSILON or
// less than or equal to -EPSILON to avoid numerical problems.
// A frequency of 0Hz can still be used to freeze the phasor.
incr(1)= (freq != 0) * ba.if(freq < 0, min(-1.0 * ma.EPSILON, incr_aux), max(ma.EPSILON, incr_aux));
incr(0)= (freq != 0) * ba.if(freq < 0, min(-1.0 * ma.EPSILON, incr_aux), max(ma.EPSILON, incr_aux));

// Faster but less accurate version
incr(1) = incr_aux;

// To correctly start at `phase` at the first sample
hard_reset = (1-1')|reset;
Expand Down

0 comments on commit c47b42f

Please sign in to comment.