Browse Source

Correct examples.

faust
Stephane Letz 4 years ago
parent
commit
f03b6fd993
3 changed files with 22 additions and 33 deletions
  1. +5
    -8
      examples/gain.dsp
  2. +15
    -16
      examples/synth.dsp
  3. +2
    -9
      src/FaustEngine.cpp

+ 5
- 8
examples/gain.dsp View File

@@ -2,14 +2,11 @@

import("stdfaust.lib");

// Switch button
switch(i) = button("switch%i [switch:%i]");
// Switch button, highlight in red
switch(i) = button("switch%i [switch:%i]") : hbargraph("[switchlight_red:%i]", 0, 1);

// Highlight in red
light_red(i) = hbargraph("[light_red:%i]", 0, 1);
// Gain slider, highlight in red
gain(i) = hslider("gain%i [knob:%i]", 0.1, 0, 1, 0.01) : hbargraph("[light_red:%i]", 0, 1);

// Gain slider
gain(i) = hslider("gain%i [knob:%i]", 0.1, 0, 1, 0.01);

process(x) = par(i, 6, x * gain(i+1) * (1-switch(i+1)) : light_red(i+1));
process(x) = par(i, 6, x * gain(i+1) * (1-switch(i+1)));


+ 15
- 16
examples/synth.dsp View File

@@ -15,26 +15,25 @@ freq2 = hslider("freq2 [knob:4] [unit:Hz] ", 300, 200, 300, 1);

// Using switches ([switch:N] metadata with N from 1 to 6)

gate = button("gate [switch:1]");
gate = button("gate [switch:1]") : vbargraph("[switchlight_red:1]", 0, 1);

// Checkbox can be used, the switch button will go be white when checked
// Checkbox can be used, the switch button will be white when checked

check = checkbox("check [switch:2]");
check = checkbox("check [switch:2]")
: vbargraph("[switchlight_red:2]", 0, 1)
: vbargraph("[switchlight_green:2]", 0, 1)
: vbargraph("[switchlight_blue:2]", 0, 1);

// Using bargraph to control lights ([light_red|green|blue:N] metadata with N from 1 to 6, to control 3 colors)
// Using bargraph to control lights ([light_red:N|light_green:N|light_blue:N] metadata with N from 1 to 6, to control 3 colors)

light_1_r = vbargraph("[light_red:1]", 0, 1);
light_1_g = vbargraph("[light_green:1]", 0, 1);
light_1_b = vbargraph("[light_blue:1]", 0, 1);
l_red(i) = vbargraph("[light_red:%i]", 0, 1);
l_green(i) = vbargraph("[light_green:%i]", 0, 1);
l_blue(i) = vbargraph("[light_blue:%i]", 0, 1);

// Using bargraph to control switchlights ([switchlight_red|green|blue:N] metadata with N from 1 to 6, to control 3 colors)
// Using bargraph to control switchlights ([switchlight_red:N|switchlight_green:N|switchlight_blue:N] metadata with N from 1 to 6, to control 3 colors)

swl_2_r = vbargraph("[switchlight_red:3]", 0, 1);
swl_2_g = vbargraph("[switchlight_green:3]", 0, 1);
swl_2_b = vbargraph("[switchlight_blue:3]", 0, 1);
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,
(os.osc(1):light_1_r + os.osc(1.4):light_1_g + os.osc(1.7):light_1_b),
(os.osc(1):swl_2_r + os.osc(1.2):swl_2_g + os.osc(1.7):swl_2_b);
process = os.osc(freq1) * vol1, os.sawtooth(freq2) * vol2 * gate, os.square(freq2) * vol2 * check;

+ 2
- 9
src/FaustEngine.cpp View File

@@ -94,10 +94,7 @@ struct RackUI : public GenericUI {
if (fKey == "switch" && (index != -1)) {
fUpdateFunIn.push_back([ = ](ProcessBlock * block) {
*zone = block->switches[index - 1];

// And set the color to red when ON
block->switchLights[index - 1][0] = *zone;
});
});
}
fKey = fValue = "";
}
@@ -114,11 +111,7 @@ struct RackUI : public GenericUI {
if (button == 1.0 && (button != fCheckBoxes[zone].fLastButton)) {
// Switch button state
*zone = !*zone;
// And set the color to white when ON
block->switchLights[index - 1][0] = *zone;
block->switchLights[index - 1][1] = *zone;
block->switchLights[index - 1][2] = *zone;
}
}
// Keep previous button state
fCheckBoxes[zone].fLastButton = button;
});


Loading…
Cancel
Save