Skip to content

Commit

Permalink
Merge branch 'patch-double' into faustfft
Browse files Browse the repository at this point in the history
  • Loading branch information
Fr0stbyteR committed Dec 11, 2024
2 parents 0355324 + a38d90a commit 861e0ca
Show file tree
Hide file tree
Showing 66 changed files with 5,962 additions and 3,437 deletions.
520 changes: 520 additions & 0 deletions COPYING.txt

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ To test, put the directory in a local server, then open page: `./dist/index.html

If you need to update the editor's version using `git pull`, as the repository has other dependencies hosted on Github, you may run `npm update` to make sure everything is up to date.

Note that the `src/static/examples` folder is a manually copied subset of the `faust/examples` that will have to be updated from time to time.

## Launching the local editor

A local HTTP server has to be started with `npm run serve` (or something similar), then use `http://127.0.0.1:8000/dist/` to launch the local editor.
Expand Down
3,219 changes: 1,777 additions & 1,442 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fausteditorweb",
"version": "1.4.1",
"description": "Faust Editor",
"version": "1.5.15",
"description": "Faust IDE",
"main": "src/index.ts",
"private": true,
"scripts": {
Expand All @@ -26,7 +26,7 @@
"WebAssembly"
],
"author": "Grame-CNCM",
"license": "GPL-3.0-or-later",
"license": "LGPL-2.1",
"bugs": {
"url": "https://github.com/grame-cncm/faustide/issues"
},
Expand All @@ -39,20 +39,20 @@
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@fortawesome/fontawesome-free": "^5.15.3",
"@grame/faustwasm": "^0.3.1",
"@shren/faust-ui": "^1.1.11",
"@grame/faustwasm": "^0.7.6",
"@shren/faust-ui": "^1.1.13",
"@shren/kissfft-js": "^0.1.10",
"@types/bootstrap": "^4.6.0",
"@types/jquery": "^3.5.5",
"@types/qrcode": "^1.4.0",
"@types/wavesurfer.js": "^3.3.2",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@zenfs/core": "^0.12.10",
"@zenfs/dom": "^0.2.13",
"@zenfs/core": "^1.2.9",
"@zenfs/dom": "^1.0.3",
"ali-oss": "^6.18.1",
"babel-loader": "^9.1.0",
"bootstrap": "^4.6.0",
"bootstrap": "^4.6.2",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
Expand Down
1 change: 1 addition & 0 deletions src/Scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class Scope {
const l = d.length;
ctx.strokeStyle = "#FFFFFF";
ctx.lineWidth = 2;
ctx.lineJoin = "round";
ctx.beginPath();
// Fastest way to get min and max to have: 1. max abs value for y scaling, 2. mean value for zero-crossing
let min = d[0];
Expand Down
2 changes: 2 additions & 0 deletions src/StaticScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class StaticScope {
const gridX = (w - left) / ($1 - $0 - 1);
const step = Math.max(1, Math.round(1 / gridX)); // horizontal draw step for optimization
ctx.lineWidth = 2;
ctx.lineJoin = "round";
for (let i = 0; i < t.length; i++) {
ctx.beginPath();
ctx.strokeStyle = `hsl(${i * 60}, 100%, 85%)`;
Expand Down Expand Up @@ -262,6 +263,7 @@ export class StaticScope {
const gridX = (w - left) / ($1 - $0 - 1);
const step = Math.max(1, Math.round(1 / gridX));
ctx.lineWidth = 2;
ctx.lineJoin = "round";
for (let i = 0; i < t.length; i++) {
ctx.beginPath();
ctx.strokeStyle = t.length === 1 ? "white" : `hsl(${i * 60}, 100%, 85%)`;
Expand Down
32 changes: 23 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $(async () => {
const { FFTR } = kissFFT;
const BrowserFS = await import("@zenfs/core");
const { IndexedDB } = await import("@zenfs/dom");
await BrowserFS.configure({
await BrowserFS.configureSingle({
backend: IndexedDB,
storeName: "FaustIDE" as any
});
Expand Down Expand Up @@ -297,7 +297,9 @@ $(async () => {
await initAudioCtx(audioEnv);
initAnalysersUI(uiEnv, audioEnv);
}
const { useWorklet, bufferSize, voices, args, fftDsp } = compileOptions;
const { useWorklet, bufferSize, voices, useDouble, fftDsp } = compileOptions;
const args = compileOptions.args.slice();
if (useDouble) args.push("-double");
let node: FaustScriptProcessorNode<any> | FaustAudioWorkletNode<any>;
// Recorder, show current recorded length without too many refreshes
let mediaLengthRaf: number;
Expand Down Expand Up @@ -349,7 +351,7 @@ $(async () => {
}
if (!node) throw new Error("Unknown Error in WebAudio Node.");
node.setPlotHandler(plotHandler);
node.listenSensors();
node.startSensors();
} catch (e) { /*
const uiWindow = ($("#iframe-faust-ui")[0] as HTMLIFrameElement).contentWindow;
uiWindow.postMessage(JSON.stringify({ type: "clear" }), "*");
Expand Down Expand Up @@ -508,6 +510,7 @@ $(async () => {
};
const compileOptions: FaustEditorCompileOptions = {
useWorklet: false,
useDouble: false,
bufferSize: 1024,
saveCode: true,
saveParams: false,
Expand Down Expand Up @@ -665,6 +668,11 @@ $(async () => {
if (compileOptions.realtimeCompile && audioEnv.dsp) runDsp(uiEnv.fileManager.mainCode);
});

// Double
$<HTMLInputElement>("#check-double").on("change", (e) => {
compileOptions.useDouble = e.currentTarget.checked;
saveEditorParams();
})[0].checked = compileOptions.useDouble;
// Save Code
$<HTMLInputElement>("#check-save-code").on("change", (e) => {
compileOptions.saveCode = e.currentTarget.checked;
Expand Down Expand Up @@ -732,7 +740,9 @@ $(async () => {
$("#btn-plot").on("click", async () => {
if (compileOptions.plotMode === "offline") {
const code = uiEnv.fileManager.mainCode;
const { args, plot, plotSR } = compileOptions;
const { plot, plotSR, useDouble } = compileOptions;
const args = compileOptions.args.slice();
if (useDouble) args.push("-double");
const generator = new FaustMonoDspGenerator();
await generator.compile(faustCompiler, "main", code, args.join(" "));
const soundfileList = generator.getSoundfileList();
Expand Down Expand Up @@ -993,9 +1003,11 @@ $(async () => {
$.ajax({
method: "GET",
url: `${path}/precompile`
}).done((result) => {
}).done((result, status, jqXHR) => {
if (result === "DONE") {
const href = `${path}/${plat === "android" ? "binary.apk" : "binary.zip"}`;
// faustservice MAY return Location : https://github.com/grame-cncm/faustservice/pull/10
const location = jqXHR.getResponseHeader("Location");
const href = location ? `${server}/${location}` : `${path}/${plat === "android" ? "binary.apk" : "binary.zip"}`;
$("#a-export-download").attr({ href });
$("#export-download").show();
if (download === true) {
Expand All @@ -1004,7 +1016,7 @@ $(async () => {
$("#qr-code").show();
QRCode.toCanvas(
$<HTMLCanvasElement>("#qr-code")[0],
`${path}/${plat === "android" ? "binary.apk" : "binary.zip"}`
href
);
return;
}
Expand Down Expand Up @@ -1624,9 +1636,11 @@ $(async () => {
$.ajax({
method: "GET",
url: `${path}/precompile`
}).done((result) => {
}).done((result, status, jqXHR) => {
if (result === "DONE") {
const href = `${path}/binary.zip`;
// faustservice MAY return Location : https://github.com/grame-cncm/faustservice/pull/10
const location = jqXHR.getResponseHeader("Location");
const href = location ? `${server}/${location}` : `${path}/binary.zip`;
((e.originalEvent as MessageEvent).source as WindowProxy).postMessage({ type: "exported", href }, "*");
}
}).fail((jqXHR, textStatus) => {
Expand Down
2 changes: 1 addition & 1 deletion src/static/examples.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/static/examples/LIBRARIES/aanl.lib
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
//
// #### References
// * <https://github.com/grame-cncm/faustlibraries/blob/master/aanl.lib>
// * <https://www.dafx.de/paper-archive/2016/dafxpapers/20-DAFx-16_paper_41-PN.pdf>
// * Reducing the Aliasing in Nonlinear Waveshaping Using Continuous-time Convolution,
// Julian Parker, Vadim Zavalishin, Efflam Le Bivic, DAFX, 2016
// * <http://dafx16.vutbr.cz/dafxpapers/20-DAFx-16_paper_41-PN.pdf>
//########################################################################################

ba = library("basics.lib");
ma = library("maths.lib");

declare name "Faust Antialiased Nonlinearities";
declare version "0.3";
declare version "1.3.0";

//==============================Auxiliary Functions=======================================
//========================================================================================
Expand Down
55 changes: 27 additions & 28 deletions src/static/examples/LIBRARIES/analyzers.lib
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi = library("filters.lib");
an = library("analyzers.lib"); // for compatible copy/paste out of this file

declare name "Faust Analyzer Library";
declare version "0.2";
declare version "1.2.0";

/************************************************************************
FAUST library file, jos section
Expand Down Expand Up @@ -54,8 +54,8 @@ abs_envelope_rect(period, x) = abs(x) : fi.avg_rect(period);


//------------------`(an.)abs_envelope_tau`------------------------------------
// Absolute value average with one-pole lowpass and tau response.
// (See filters.lib.)
// Absolute value average with one-pole lowpass and tau response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -76,8 +76,8 @@ abs_envelope_tau(period, x) = abs(x) : fi.avg_tau(period);


//------------------`(an.)abs_envelope_t60`------------------------------------
// Absolute value average with one-pole lowpass and t60 response.
// (See filters.lib.)
// Absolute value average with one-pole lowpass and t60 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -98,8 +98,8 @@ abs_envelope_t60(period, x) = abs(x) : fi.avg_t60(period);


//------------------`(an.)abs_envelope_t19`------------------------------------
// Absolute value average with one-pole lowpass and t19 response.
// (See filters.lib.)
// Absolute value average with one-pole lowpass and t19 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand Down Expand Up @@ -222,8 +222,8 @@ ms_envelope_rect(period, x) = x * x : fi.avg_rect(period);


//------------------`(an.)ms_envelope_tau`-------------------------------------
// Mean square average with one-pole lowpass and tau response.
// (see `filters.lib`)
// Mean square average with one-pole lowpass and tau response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -244,8 +244,8 @@ ms_envelope_tau(period, x) = x * x : fi.avg_tau(period);


//------------------`(an.)ms_envelope_t60`-------------------------------------
// Mean square with one-pole lowpass and t60 response.
// (see `filters.lib`)
// Mean square with one-pole lowpass and t60 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -266,8 +266,8 @@ ms_envelope_t60(period, x) = x * x : fi.avg_t60(period);


//------------------`(an.)ms_envelope_t19`-------------------------------------
// Mean square with one-pole lowpass and t19 response.
// (see `filters.lib`)
// Mean square with one-pole lowpass and t19 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand Down Expand Up @@ -309,8 +309,8 @@ rms_envelope_rect(period, x) = ms_envelope_rect(period, x) : sqrt;


//------------------`(an.)rms_envelope_tau`------------------------------------
// Root mean square with one-pole lowpass and tau response.
// (see `filters.lib`)
// Root mean square with one-pole lowpass and tau response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -331,8 +331,8 @@ rms_envelope_tau(period, x) = ms_envelope_tau(period, x) : sqrt;


//------------------`(an.)rms_envelope_t60`------------------------------------
// Root mean square with one-pole lowpass and t60 response.
// (see `filters.lib`)
// Root mean square with one-pole lowpass and t60 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand All @@ -353,8 +353,8 @@ rms_envelope_t60(period, x) = ms_envelope_t60(period, x) : sqrt;


//------------------`(an.)rms_envelope_t19`------------------------------------
// Root mean square with one-pole lowpass and t19 response.
// (see `filters.lib`)
// Root mean square with one-pole lowpass and t19 response
// (see [filters.lib](https://faustlibraries.grame.fr/libs/filters/)).
//
// #### Usage
//
Expand Down Expand Up @@ -400,9 +400,8 @@ declare zcr license "MIT-style STK-4.3 license";
zcr(period, x) = ma.zc(x) : fi.lptau(period);


//==============================================================================
// Adaptive Frequency Analysis
//==============================================================================
//==============================Adaptive Frequency Analysis===============================
//========================================================================================

//--------------------`(an.)pitchTracker`---------------------------------------
//
Expand All @@ -418,7 +417,7 @@ zcr(period, x) = ma.zc(x) : fi.lptau(period);
//
// Where:
//
// * `N`: compile-time constant, sets the order of the low-pass filter, which
// * `N`: a constant numerical expression, sets the order of the low-pass filter, which
// determines the sensitivity of the algorithm for signals where partials are
// stronger than the fundamental frequency.
// * `tau`: response time in seconds based on exponentially-weighted averaging with tau time-constant. See <https://ccrma.stanford.edu/~jos/st/Exponentials.html>.
Expand Down Expand Up @@ -484,9 +483,9 @@ spectralCentroid(nonlinearity, t, x) = loop ~ _
'y = (x - s) * G + s;
's = 2 * (x - s) * G + s;
}
with {
G = tan(w(cf) / 2.0) / (1.0 + tan(w(cf) / 2.0));
};
with {
G = tan(w(cf) / 2.0) / (1.0 + tan(w(cf) / 2.0));
};
highpass(cf, x) = x - lowpass(cf, x);
xRMS = an.rms_envelope_tau(t, x);
xLRMS = an.rms_envelope_tau(t, lowpass(fb, x));
Expand Down Expand Up @@ -559,7 +558,7 @@ spectralCentroid(nonlinearity, t, x) = loop ~ _
//
// Where:
//
// * `O`: order of filter used to split each frequency band into two
// * `O`: (odd) order of filter used to split each frequency band into two
// * `M`: number of band-slices per octave
// * `ftop`: highest band-split crossover frequency (e.g., 20 kHz)
// * `N`: total number of bands (including dc and Nyquist)
Expand Down Expand Up @@ -589,7 +588,7 @@ mth_octave_analyzer_default = mth_octave_analyzer6e; // default analyzer


//============================Mth-Octave Spectral Level===================================
// Spectral Level: Display (in bar graphs) the average signal level in each spectral band.
// Spectral Level: display (in bargraphs) the average signal level in each spectral band.
//========================================================================================


Expand Down
Loading

0 comments on commit 861e0ca

Please sign in to comment.