Browse Source

Correct DSP examples (voltage range). Improve documentation.

faust
Stephane Letz 4 years ago
parent
commit
3496fa9925
4 changed files with 9 additions and 7 deletions
  1. +5
    -3
      Faust.md
  2. +2
    -2
      examples/organ.dsp
  3. +1
    -1
      examples/physicalmodel.dsp
  4. +1
    -1
      examples/synth.dsp

+ 5
- 3
Faust.md View File

@@ -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)


+ 2
- 2
examples/organ.dsp View File

@@ -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);
};
};

+ 1
- 1
examples/physicalmodel.dsp View File

@@ -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);

+ 1
- 1
examples/synth.dsp View File

@@ -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;

Loading…
Cancel
Save