Skip to content

Commit

Permalink
Add 'Semantic of bargraphs' item in FAQ.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Dec 9, 2024
1 parent c9bea9a commit 397bc67
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,5 @@ <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>

<!--
MkDocs version : 1.5.3
Build Date UTC : 2024-11-29 09:58:26.634211+00:00
Build Date UTC : 2024-12-09 14:05:10.309696+00:00
-->
32 changes: 31 additions & 1 deletion docs/manual/faq/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
<li class="nav-item" data-level="2"><a href="#displaying-labels-with-numbers" class="nav-link">Displaying labels with numbers</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#semantic-of-bargraphs" class="nav-link">Semantic of bargraphs</a>
<ul class="nav flex-column">
</ul>
</li>
</ul>
</li>
Expand Down Expand Up @@ -540,7 +544,33 @@ <h2 id="control-rate-versus-audio-rate">Control rate versus audio rate</h2>
<p>Answer: the <a href="https://faustlibraries.grame.fr/libs/basics/#bakr2ar">ba.kr2ar</a> function can be used for that purpose.</p>
<h2 id="displaying-labels-with-numbers">Displaying labels with numbers</h2>
<p>Question: <em>Is there a way to force the sliders to show in numerical order respecting tens?</em> </p>
<p>Answer: Labels can contain variable parts. These are indicated with the sign % followed by the name of a variable. For a detailed explanation of how to use this feature, refer to the <a href="../syntax/#variable-parts-of-a-label">comprehensive documentation</a>.</p></div>
<p>Answer: Labels can contain variable parts. These are indicated with the sign % followed by the name of a variable. For a detailed explanation of how to use this feature, refer to the <a href="../syntax/#variable-parts-of-a-label">comprehensive documentation</a>.</p>
<h2 id="semantic-of-bargraphs">Semantic of bargraphs</h2>
<p>Question: <em>When are control rate outputs (like hbargraph/vbargraph) calculated every sample ?</em> </p>
<p>Answer: This depends on the nature of the signal entering the bargraph. If it's a control rate signal, as in <code>process = vslider("foo", 0, 0, 1, 0.01) : vbargraph("bar", 0, 1);</code>, then updating is done at control rate:</p>
<pre><code class="language-C++">virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* output0 = outputs[0];
fVbargraph0 = FAUSTFLOAT(float(fVslider0));
float fSlow0 = fVbargraph0;
for (int i0 = 0; i0 &lt; count; i0 = i0 + 1) {
output0[i0] = FAUSTFLOAT(fSlow0);
}
}
</code></pre>
<p>But if the signal is at sample rate, as in <code>process = vslider("foo", 0, 0, 1, 0.01) : si.smooth(0.9) : vbargraph("bar", 0, 1);</code>, the calculation must be at sample rate to be correct (that is to properly update the signal state at each sample), even if all the values are not displayed:</p>
<pre><code class="language-C++">virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = fConst0 * float(fVslider0);
for (int i0 = 0; i0 &lt; count; i0 = i0 + 1) {
fRec0[0] = fSlow0 + fConst1 * fRec0[1];
fVbargraph0 = FAUSTFLOAT(fRec0[0]);
output0[i0] = FAUSTFLOAT(fVbargraph0);
fRec0[1] = fRec0[0];
}
}
</code></pre></div>
</div>
</div>

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.
33 changes: 33 additions & 0 deletions src/manual/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,36 @@ Question: *Is there a way to force the sliders to show in numerical order respec

Answer: Labels can contain variable parts. These are indicated with the sign % followed by the name of a variable. For a detailed explanation of how to use this feature, refer to the [comprehensive documentation](syntax.md#variable-parts-of-a-label).

## Semantic of bargraphs

Question: *When are control rate outputs (like hbargraph/vbargraph) calculated every sample ?*

Answer: This depends on the nature of the signal entering the bargraph. If it's a control rate signal, as in `process = vslider("foo", 0, 0, 1, 0.01) : vbargraph("bar", 0, 1);`, then updating is done at control rate:

```C++
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* output0 = outputs[0];
fVbargraph0 = FAUSTFLOAT(float(fVslider0));
float fSlow0 = fVbargraph0;
for (int i0 = 0; i0 < count; i0 = i0 + 1) {
output0[i0] = FAUSTFLOAT(fSlow0);
}
}
```
But if the signal is at sample rate, as in `process = vslider("foo", 0, 0, 1, 0.01) : si.smooth(0.9) : vbargraph("bar", 0, 1);`, the calculation must be at sample rate to be correct (that is to properly update the signal state at each sample), even if all the values are not displayed:
```C++
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = fConst0 * float(fVslider0);
for (int i0 = 0; i0 < count; i0 = i0 + 1) {
fRec0[0] = fSlow0 + fConst1 * fRec0[1];
fVbargraph0 = FAUSTFLOAT(fRec0[0]);
output0[i0] = FAUSTFLOAT(fVbargraph0);
fRec0[1] = fRec0[0];
}
}
```

0 comments on commit 397bc67

Please sign in to comment.