From 3496fa99255d6b6ac409fd68535a7abf10ac21cf Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Fri, 13 Nov 2020 22:57:24 +0100 Subject: [PATCH] Correct DSP examples (voltage range). Improve documentation. --- Faust.md | 8 +++++--- examples/organ.dsp | 4 ++-- examples/physicalmodel.dsp | 2 +- examples/synth.dsp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Faust.md b/Faust.md index 2157475..31e03bd 100644 --- a/Faust.md +++ b/Faust.md @@ -25,11 +25,11 @@ So a button or checkbox UI item can use the `[switch:N]` metadata to be associat Other metadata: - `[scale:lin|log|exp]` metadata is implemented. -The [rack.lib](https://github.com/VCVRack/VCV-Prototype/blob/faust/res/faust/rack.lib) Faust library contains usefull functions to convert VC signals, and can be enriched if needed. +The [rack.lib](https://github.com/VCVRack/VCV-Prototype/blob/faust/res/faust/rack.lib) Faust library contains usefull functions to convert CV signals, and can be enriched if needed. ## DSP examples -Here is a simple example showing how oscillators can be controlled by UI items: +Here is a simple example showing how oscillators can be controlled by GUI items, associated with metadata in the DSP code: ``` import("stdfaust.lib"); @@ -40,9 +40,11 @@ gain = hslider("gain [knob:2]", 0.5, 0, 1, 0.01); gate = button("gate [switch:1]"); // DSP processor -process = os.osc(freq) * gain, os.sawtooth(freq) * gain * gate; +process = os.osc(freq) * gain * 5, os.sawtooth(freq) * gain * gate * 5; ``` +Following the VCV Prototype model, note that audio outputs **are multipled by 5** to follow the [-5v..5v] range convention. + The standard examples ported to Faust can be seen in the examples folder: - [gain.dsp](https://github.com/VCVRack/VCV-Prototype/blob/faust/examples/gain.dsp) diff --git a/examples/organ.dsp b/examples/organ.dsp index 3763da0..acb2a88 100644 --- a/examples/organ.dsp +++ b/examples/organ.dsp @@ -18,7 +18,7 @@ Additive synth: 3 sine oscillators with adsr envelop. Use the 3 first VC inputs to control pitch, gate and velocity. */ -process(pitch, gate, vel) = voice(freq) * en.adsr(attack, decay, sustain, release, gate) * vel : *(vol) : panner(pan) +process(pitch, gate, vel) = voice(freq) * en.adsr(attack, decay, sustain, release, gate) * vel : *(vol) : panner(pan) : *(5),*(5) with { freq = cv_pitch2freq(pitch); -}; \ No newline at end of file +}; diff --git a/examples/physicalmodel.dsp b/examples/physicalmodel.dsp index 61cabf9..ee35e5b 100644 --- a/examples/physicalmodel.dsp +++ b/examples/physicalmodel.dsp @@ -43,4 +43,4 @@ with { between 0 and 1 with 1 for the maximum amount of reverb.]", 0.3333, 0, 1, 0.025)); }; -process = frenchBell_ui <: freeverb_demo; +process = frenchBell_ui <: freeverb_demo : *(5),*(5); diff --git a/examples/synth.dsp b/examples/synth.dsp index edd3e30..a6a63ec 100644 --- a/examples/synth.dsp +++ b/examples/synth.dsp @@ -31,4 +31,4 @@ swl_red(i) = vbargraph("[switchlight_red:%i]", 0, 1); swl_green(i) = vbargraph("[switchlight_green:%i]", 0, 1); swl_blue(i) = vbargraph("[switchlight_blue:%i]", 0, 1); -process = os.osc(freq1) * vol1, os.sawtooth(freq2) * vol2 * gate, os.square(freq2) * vol2 * check; +process = os.osc(freq1) * vol1 * 5, os.sawtooth(freq2) * vol2 * gate * 5, os.square(freq2) * vol2 * check * 5;