Skip to content

Commit

Permalink
double precision checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Fr0stbyteR committed Dec 11, 2024
1 parent b31aa02 commit a38d90a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ $(async () => {
await initAudioCtx(audioEnv);
initAnalysersUI(uiEnv, audioEnv);
}
const { useWorklet, bufferSize, voices, args } = compileOptions;
const { useWorklet, bufferSize, voices, useDouble } = 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 @@ -493,6 +495,7 @@ $(async () => {
};
const compileOptions: FaustEditorCompileOptions = {
useWorklet: false,
useDouble: false,
bufferSize: 1024,
saveCode: true,
saveParams: false,
Expand Down Expand Up @@ -644,6 +647,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 @@ -711,7 +719,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
6 changes: 6 additions & 0 deletions src/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
Use AudioWorklet
</label>
</div>
<div class="form form-check mb-2" data-toggle="tooltip" data-placement="right" title="Use Double Precision">
<input id="check-double" class="form-check-input" type="checkbox" value="" />
<label class="form-check-label" for="check-double">
Double Precision
</label>
</div>
<div class="form form-check mb-2" data-toggle="tooltip" data-placement="right" title="Save DSP Code">
<input id="check-save-code" class="form-check-input" type="checkbox" value="" checked />
<label class="form-check-label" for="check-save-code">
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type FaustEditorCompileOptions = {
mainFile?: string;
useWorklet: boolean;
useDouble: boolean;
bufferSize: 128 | 256 | 512 | 1024 | 2048 | 4096;
saveCode: boolean;
saveParams: boolean;
Expand Down

0 comments on commit a38d90a

Please sign in to comment.