1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../img/favicon.ico">
<title> Contributing - Faust Libraries</title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/font-awesome.min.css" rel="stylesheet">
<link href="../css/base.css" rel="stylesheet">
<link rel="stylesheet" href="/usr/share/javascript/highlight.js/styles/github.css">
<link href="../css/extra.css" rel="stylesheet">
<script src="../js/jquery-3.6.0.min.js" defer></script>
<script src="../js/bootstrap.min.js" defer></script>
<script src="/usr/share/javascript/highlight.js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href=".."><img src="../img/faustText.svg" width="150px"> </a>
<!-- Expander button -->
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Expanded navigation -->
<div id="navbar-collapse" class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li class="dropdown active">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">Overview <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="../organization/" class="dropdown-item"> Organization </a>
</li>
<li>
<a href="../standardFunctions/" class="dropdown-item"> Standard Functions </a>
</li>
<li>
<a href="./" class="dropdown-item active"> Contributing </a>
</li>
<li>
<a href="../community/" class="dropdown-item"> Community </a>
</li>
<li>
<a href="../about/" class="dropdown-item"> Copyright/License </a>
</li>
</ul>
</li>
<li class="navitem">
<a href="../libs/" class="nav-link">Index</a>
</li>
<li class="dropdown">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">Libraries <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="../libs/aanl/" class="dropdown-item"> antialiased </a>
</li>
<li>
<a href="../libs/analyzers/" class="dropdown-item"> analyzers </a>
</li>
<li>
<a href="../libs/basics/" class="dropdown-item"> basics </a>
</li>
<li>
<a href="../libs/compressors/" class="dropdown-item"> compressors </a>
</li>
<li>
<a href="../libs/delays/" class="dropdown-item"> delays </a>
</li>
<li>
<a href="../libs/demos/" class="dropdown-item"> demos </a>
</li>
<li>
<a href="../libs/dx7/dx7/" class="dropdown-item"> dx7/dx7 </a>
</li>
<li>
<a href="../libs/dx7/env/" class="dropdown-item"> dx7/env </a>
</li>
<li>
<a href="../libs/dx7/lfo/" class="dropdown-item"> dx7/lfo </a>
</li>
<li>
<a href="../libs/dx7/operator/" class="dropdown-item"> dx7/operator </a>
</li>
<li>
<a href="../libs/dx7/pitchenv/" class="dropdown-item"> dx7/pitchenv </a>
</li>
<li>
<a href="../libs/envelopes/" class="dropdown-item"> envelopes </a>
</li>
<li>
<a href="../libs/fds/" class="dropdown-item"> fds </a>
</li>
<li>
<a href="../libs/filters/" class="dropdown-item"> filters </a>
</li>
<li>
<a href="../libs/hoa/" class="dropdown-item"> hoa </a>
</li>
<li>
<a href="../libs/interpolators/" class="dropdown-item"> interpolators </a>
</li>
<li>
<a href="../libs/linearalgebra/" class="dropdown-item"> linearalgebra </a>
</li>
<li>
<a href="../libs/maths/" class="dropdown-item"> maths </a>
</li>
<li>
<a href="../libs/mi/" class="dropdown-item"> mi </a>
</li>
<li>
<a href="../libs/misceffects/" class="dropdown-item"> misceffects </a>
</li>
<li>
<a href="../libs/noises/" class="dropdown-item"> noises </a>
</li>
<li>
<a href="../libs/oscillators/" class="dropdown-item"> oscillators </a>
</li>
<li>
<a href="../libs/phaflangers/" class="dropdown-item"> phaflangers </a>
</li>
<li>
<a href="../libs/physmodels/" class="dropdown-item"> physmodels </a>
</li>
<li>
<a href="../libs/quantizers/" class="dropdown-item"> quantizers </a>
</li>
<li>
<a href="../libs/reducemaps/" class="dropdown-item"> reducemaps </a>
</li>
<li>
<a href="../libs/reverbs/" class="dropdown-item"> reverbs </a>
</li>
<li>
<a href="../libs/routes/" class="dropdown-item"> routes </a>
</li>
<li>
<a href="../libs/signals/" class="dropdown-item"> signals </a>
</li>
<li>
<a href="../libs/soundfiles/" class="dropdown-item"> soundfiles </a>
</li>
<li>
<a href="../libs/spats/" class="dropdown-item"> spats </a>
</li>
<li>
<a href="../libs/synths/" class="dropdown-item"> synths </a>
</li>
<li>
<a href="../libs/vaeffects/" class="dropdown-item"> vaeffects </a>
</li>
<li>
<a href="../libs/version/" class="dropdown-item"> version </a>
</li>
<li>
<a href="../libs/wdmodels/" class="dropdown-item"> wdmodels </a>
</li>
<li>
<a href="../libs/webaudio/" class="dropdown-item"> webaudio </a>
</li>
</ul>
</li>
<li class="navitem">
<a href="../about/" class="nav-link">About</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a href="#" class="nav-link" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="row"><div class="col-md-3"><div class="navbar-light navbar-expand-md bs-sidebar hidden-print affix" role="complementary">
<div class="navbar-header">
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#toc-collapse" title="Table of Contents">
<span class="fa fa-angle-down"></span>
</button>
</div>
<div id="toc-collapse" class="navbar-collapse collapse card bg-secondary">
<ul class="nav flex-column">
<li class="nav-item" data-level="1"><a href="#contributing" class="nav-link">Contributing</a>
<ul class="nav flex-column">
<li class="nav-item" data-level="2"><a href="#new-functions" class="nav-link">New Functions</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#new-libraries" class="nav-link">New Libraries</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#coding-conventions" class="nav-link">Coding Conventions</a>
<ul class="nav flex-column">
<li class="nav-item" data-level="3"><a href="#function-naming" class="nav-link">Function Naming</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="3"><a href="#variable-argument-list" class="nav-link">Variable Argument List</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="3"><a href="#documentation" class="nav-link">Documentation</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="3"><a href="#library-import" class="nav-link">Library Import</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="3"><a href="#demo-functions" class="nav-link">"Demo" Functions</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="3"><a href="#standard-functions" class="nav-link">"Standard" Functions</a>
<ul class="nav flex-column">
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#testing-the-library" class="nav-link">Testing the library</a>
<ul class="nav flex-column">
</ul>
</li>
<li class="nav-item" data-level="2"><a href="#library-deployment" class="nav-link">Library deployment</a>
<ul class="nav flex-column">
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div></div>
<div class="col-md-9 main-container" role="main">
<h1 id="contributing">Contributing</h1>
<p>In general, libraries are organised in a <em>stacked manner</em>: the base ones define functions or constants without any dependancies, and additional ones are gradually built on top of simpler ones, layer by layer. <strong>Dependency loops must be avoided as much as possible</strong>. The <em>resources</em> folder contains tools to build and visualise the libraries dependencies graphs.</p>
<p>If you wish to add a function to any of these libraries or if you plan to add a new library, make sure that you observe the following conventions:</p>
<h2 id="new-functions">New Functions</h2>
<ul>
<li>All functions must be preceded by a markdown documentation header respecting the following format (open the source code of any of the libraries for an example):</li>
</ul>
<pre><code>//-----------------functionName--------------------
// Description
//
// #### Usage
//
// ```
// Usage Example
// ```
//
// Where:
//
// * argument1: argument 1 description
//-------------------------------------------------
</code></pre>
<ul>
<li>Every time a new function is added, the documentation should be updated simply by running <code>make doclib</code>. <!-- TODO --></li>
<li>The environment system (e.g. <code>os.osc</code>) should be used when calling a function declared in another library (see the section on <a href="#library-import">Library Import</a>).</li>
<li>Try to reuse existing functions as much as possible.</li>
<li>The <code>Usage</code> line must show the <em>input/output shape</em> (the number of inputs and outputs) of the function, like <code>gen: _</code> for a mono generator, <code>_ : filter : _</code> for a mono effect, etc.</li>
<li>Some functions use parameters that are <a href="https://faustdoc.grame.fr/manual/syntax/#constant-numerical-expressions">constant numerical expressions</a>. The convention is to label them in <em>capital letters</em> and document them preferably to be <em>constant numerical expressions</em> (or <em>known at compile time</em> in existing libraries).</li>
<li>Functions with several parameters should better be written by putting the <em>more constant parameters</em> (like control, setup...) at the beginning of the parameter list, and <em>audio signals to be processed</em> at the end. This allows to do partial-application. So prefer the following <code>clip(low, high, x) = min(max(x, low), high);</code> form where <code>clip(-1, 1)</code> partially applied version can be used later on in different contexts, better than <code>clip(x, low, high) = min(max(x, low), high);</code> version.</li>
</ul>
<h2 id="new-libraries">New Libraries</h2>
<ul>
<li>Any new "standard" library should be declared in <code>stdfaust.lib</code> with its own environment (2 letters - see <code>stdfaust.lib</code>).</li>
<li>Any new "standard" library must be added to <code>generateDoc</code>.</li>
<li>Functions must be organized by sections.</li>
<li>Any new library should at least <code>declare</code> a <code>name</code> and a <code>version</code>.</li>
<li>Any new library has to use a prefix declared in the header section with the following kind of syntax: <code>Its official prefix is 'qu'</code> (look at an existing library to follow the exact syntax).</li>
<li>Be sure to add the appropriate kind of <code>ma = library("maths.lib");</code> import library line, for each external library function used in the new library (for instance <code>ma.foo</code> that would be used somewhre in the code).</li>
<li>The comment based markdown documentation of each library must respect the following format (open the source code of any of the libraries for an example):</li>
</ul>
<pre><code>//############### libraryName ##################
// Description
//
// * Section Name 1
// * Section Name 2
// * ...
//
// It should be used using the `[...]` environment:
//
// ```
// [...] = library("libraryName");
// process = [...].functionCall;
// ```
//
// Another option is to import `stdfaust.lib` which already contains the `[...]`
// environment:
//
// ```
// import("stdfaust.lib");
// process = [...].functionCall;
// ```
//##############################################
//================= Section Name ===============
// Description
//==============================================
</code></pre>
<h2 id="coding-conventions">Coding Conventions</h2>
<p>In order to have a uniformized library system, we established the following conventions (that hopefully will be followed by others when making modifications to them).</p>
<h3 id="function-naming">Function Naming</h3>
<p>[WIP]</p>
<p>JOS proposal: using terms used in the field of digital signal processing, as follows:</p>
<ul>
<li><code>impulse</code>: ...,0,1,0,...</li>
<li><code>pulse</code>: ...,0,1,1,0,... or longer</li>
<li><code>impulse_train</code></li>
<li><code>pulse_train</code></li>
<li><code>gate</code> = pulse controlled externally (e.g., by NoteOn,NoteOff)</li>
<li><code>trigger</code> = impulse controlled externally (gate - gate' > 0) == gate rising edge</li>
</ul>
<p>[/WIP]</p>
<h3 id="variable-argument-list">Variable Argument List</h3>
<p>Strictly speaking, there are no lists in Faust. But list operations <a href="https://faustdoc.grame.fr/manual/faq/#pattern-matching-and-lists">can be simulated</a> (in part) using the parallel binary composition operation <code>,</code> and pattern matching.</p>
<p>Thus functions expecting a variable number of arguments can use this mechanism, like a <code>foo</code> function that would be used this way: <code>foo((a,b,c,d))</code>. See <a href="https://faustlibraries.grame.fr/libs/filters/#fiiir">fi.iir</a> and <a href="https://faustlibraries.grame.fr/libs/filters/#fifir">fi.fir</a> examples.</p>
<h3 id="documentation">Documentation</h3>
<ul>
<li>All the functions that we want to be "public" are documented.</li>
<li>We used the <code>faust2md</code> "standards" for each library: <code>//###</code> for main title (library name - equivalent to <code>#</code> in markdown), <code>//===</code> for section declarations (equivalent to <code>##</code> in markdown) and <code>//---</code> for function declarations (equivalent to <code>####</code> in markdown - see <code>basics.lib</code> for an example).</li>
<li>Sections in function documentation should be declared as <code>####</code> markdown title.</li>
<li>Each function documentation provides a "Usage" section (see <code>basics.lib</code>). </li>
<li>The full documentation can be generated using the doc/Makefile script. Use <code>make help</code> to see all possible commands. If you plan to create a pull-request, <em>do not commit the full generated code</em> but only the modified .lib files.</li>
<li>Each function can have <code>declare author "name";</code>, <code>declare copyright "XXX";</code> and <code>declare licence "YYY";</code> declarations.</li>
<li>Each library has a <code>declare version "xx.yy.zz";</code> <a href="https://semver.org">semantic version</a> number to be raised each time a modification is done. The global <code>version</code> number in <code>version.lib</code> also has to be adapted according to the change. </li>
</ul>
<h3 id="library-import">Library Import</h3>
<p>To prevent cross-references between libraries, we generalized the use of the <code>library("")</code> system for function calls in all the libraries. This means that everytime a function declared in another library is called, the environment corresponding to this library needs to be called too. To make things easier, a <code>stdfaust.lib</code> library was created and is imported by all the libraries:</p>
<pre><code>aa = library("aanl.lib");
sf = library("all.lib");
an = library("analyzers.lib");
ba = library("basics.lib");
co = library("compressors.lib");
de = library("delays.lib");
dm = library("demos.lib");
dx = library("dx7.lib");
en = library("envelopes.lib");
fd = library("fds.lib");
fi = library("filters.lib");
ho = library("hoa.lib");
it = library("interpolators.lib");
la = library("linearalgebra.lib");
ma = library("maths.lib");
mi = library("mi.lib");
ef = library("misceffects.lib");
os = library("oscillators.lib");
no = library("noises.lib");
pf = library("phaflangers.lib");
pm = library("physmodels.lib");
qu = library("quantizers.lib");
rm = library("reducemaps.lib");
re = library("reverbs.lib");
ro = library("routes.lib");
si = library("signals.lib");
so = library("soundfiles.lib");
sp = library("spats.lib");
sy = library("synths.lib");
ve = library("vaeffects.lib");
vl = library("version.lib");
wa = library("webaudio.lib");
wd = library("wdmodels.lib");
</code></pre>
<p>For example, if we wanted to use the <code>smooth</code> function which is now declared in <code>signals.lib</code>, we would do the following:</p>
<pre><code>import("stdfaust.lib");
process = si.smooth(0.999);
</code></pre>
<p>This standard is only used within the libraries: nothing prevents coders to still import <code>signals.lib</code> directly and call <code>smooth</code> without <code>ro.</code>, etc. It means symbols and function names defined within a library <strong>have to be unique to not collide with symbols of any other libraries</strong>. </p>
<h3 id="demo-functions">"Demo" Functions</h3>
<p>"Demo" functions are placed in <code>demos.lib</code> and have a built-in user interface (UI). Their name ends with the <code>_demo</code> suffix. Each of these function have a <code>.dsp</code> file associated to them in the <code>/examples</code> folder.</p>
<p>Any function containing UI elements should be placed in this library and respect these standards.</p>
<h3 id="standard-functions">"Standard" Functions</h3>
<p>"Standard" functions are here to simplify the life of new (or not so new) Faust coders. They are declared in <code>/libraries/doc/standardFunctions.md</code> and allow to point programmers to preferred functions to carry out a specific task. For example, there are many different types of lowpass filters declared in <code>filters.lib</code> and only one of them is considered to be standard, etc.</p>
<h2 id="testing-the-library">Testing the library</h2>
<p>Before preparing a pull-request, the new library must be carefully tested:</p>
<ul>
<li>all functions defined in the library must be tested by preparing a DSP test program</li>
<li>the compatibility library <code>all.lib</code> imports all libraries in a same namespace, so check functions names collisions using the following test program:</li>
</ul>
<pre><code>import("all.lib");
process = _;
</code></pre>
<h2 id="library-deployment">Library deployment</h2>
<p>For GRAME maintainers:</p>
<ul>
<li>regenerate the PDF documentation using <code>make pdf</code> target in the <code>doc</code> folder</li>
<li>update the library submodule in <a href="https://github.com/grame-cncm/faust">faust</a>, recompile and deploy WebAssembly libfaust in <a href="https://github.com/grame-cncm/fausteditor">fausteditor</a>, <a href="https://github.com/grame-cncm/faustplayground">faustplayground</a> and <a href="https://github.com/grame-cncm/faustide">faustide</a></li>
<li>update the library submodule in <a href="https://github.com/grame-cncm/faustlive">faustlive</a> </li>
<li>update the library list in this <a href="https://github.com/grame-cncm/fausteditor/blob/master/src/faustlive.js">fausteditor</a> page as well as the <a href="https://github.com/grame-cncm/fausteditor/blob/master/src/codemirror/mode/faust/faustsnippets.js">snippets</a> (using the <code>faust2atomsnippets</code> tool).</li>
<li>update the library list in this <a href="https://github.com/grame-cncm/faustide/blob/master/src/documentation.ts">faustide</a> page.</li>
<li>update the library list in the <a href="https://github.com/grame-cncm/faust/blob/master-dev/embedded/faustgen/src/faustgen%7E.cpp">faustgen~</a> code</li>
<li>update the <a href="https://github.com/grame-cncm/faust/tree/master-dev/syntax-highlighting">Faust Syntax Highlighting Files</a></li>
<li>make an update PR for <a href="https://github.com/hellbent/vscode-faust">vscode-faust</a> project</li>
</ul></div>
</div>
</div>
<footer class="col-md-12">
<hr>
<p>Copyright © 2019-2025 <a href="https://www.grame.fr">Grame-CNCM</a></p>
</footer>
<script>
var base_url = "..",
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
</script>
<script src="../js/base.js" defer></script>
<script src="/usr/share/javascript/mathjax/MathJax.js" defer></script>
<script src="../search/main.js" defer></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="searchModalLabel">Search</h4>
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
</div>
<div class="modal-body">
<p>From here you can search these documents. Enter your search terms below.</p>
<form>
<div class="form-group">
<input type="search" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
</div>
</form>
<div id="mkdocs-search-results" data-no-results-text="No results found"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="keyboardModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th style="width: 20%;">Keys</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="help shortcut"><kbd>?</kbd></td>
<td>Open this help</td>
</tr>
<tr>
<td class="next shortcut"><kbd>n</kbd></td>
<td>Next page</td>
</tr>
<tr>
<td class="prev shortcut"><kbd>p</kbd></td>
<td>Previous page</td>
</tr>
<tr>
<td class="search shortcut"><kbd>s</kbd></td>
<td>Search</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
|