Browse Source

New physicalmodel.dsp example, cleanup.

faust
Stephane Letz Andrew Belt 4 years ago
parent
commit
411845dad9
3 changed files with 56 additions and 9 deletions
  1. +44
    -0
      examples/physicalmodel.dsp
  2. +3
    -3
      examples/synth.dsp
  3. +9
    -6
      src/FaustEngine.cpp

+ 44
- 0
examples/physicalmodel.dsp View File

@@ -0,0 +1,44 @@
import("stdfaust.lib");
import("rack.lib");

frenchBell_ui = pm.frenchBell(strikePosition,strikeCutoff,strikeSharpness,gain,gate)
with {
strikePosition = nentry("v:frenchBell/[0]strikePosition", 0,0,4,1);
strikeCutoff = hslider("v:frenchBell/[1]strikeCutOff", 6500,20,20000,1);
strikeSharpness = hslider("v:frenchBell/[2]strikeSharpness", 0.5,0.01,5,0.01);
// Connection with VCV knob and switch
gain = hslider("v:frenchBell/[3]gain [knob:1]",1,0,1,0.01);
gate = button("v:frenchBell/[4]gate [switch:1]");
};

freeverb_demo = _,_ <: (*(g)*fixedgain,*(g)*fixedgain :
re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)),
*(1-g), *(1-g) :> _,_
with{
scaleroom = 0.28;
offsetroom = 0.7;
allpassfeed = 0.5;
scaledamp = 0.4;
fixedgain = 0.1;
origSR = 44100;

parameters(x) = hgroup("Freeverb",x);
knobGroup(x) = parameters(vgroup("[0]",x));
// Connection with VCV knobs
damping = knobGroup(vslider("[0] Damp [knob:2] [style: knob] [tooltip: Somehow control the
density of the reverb.]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR);
combfeed = knobGroup(vslider("[1] RoomSize [knob:3] [style: knob] [tooltip: The room size
between 0 and 1 with 1 for the largest room.]", 0.5, 0, 1, 0.025)*scaleroom*
origSR/ma.SR + offsetroom);
spatSpread = knobGroup(vslider("[2] Stereo Spread [knob:4] [style: knob] [tooltip: Spatial
spread between 0 and 1 with 1 for maximum spread.]",0.5,0,1,0.01)*46*ma.SR/origSR
: int);
g = parameters(vslider("[1] Wet [knob:5] [tooltip: The amount of reverb applied to the signal
between 0 and 1 with 1 for the maximum amount of reverb.]", 0.3333, 0, 1, 0.025));
};

process = frenchBell_ui <: freeverb_demo;

examples/test1.dsp → examples/synth.dsp View File

@@ -13,7 +13,7 @@ freq1 = hslider("freq1 [knob:2] [unit:Hz] [scale:lin]", 300, 200, 300, 1);
vol2 = hslider("volume2 [knob:3]", 0.1, 0, 1, 0.01);
freq2 = hslider("freq2 [knob:4] [unit:Hz] ", 300, 200, 300, 1);

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

gate = button("gate [switch:1]");

@@ -21,13 +21,13 @@ gate = button("gate [switch:1]");

check = checkbox("check [switch:2]");

// 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|green|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);

// 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|green|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);

+ 9
- 6
src/FaustEngine.cpp View File

@@ -63,7 +63,6 @@ struct RackUI : public GenericUI
return -1;
}
} catch (invalid_argument& e) {
cerr << "ERROR : " << e.what() << endl;
return -1;
}
}
@@ -96,14 +95,14 @@ struct RackUI : public GenericUI
float state = block->switches[index-1];
// Detect upfront
if (state == 1.0 && (state != fCheckBoxes[zone].fLast)) {
// Swich button state
// Switch button state
*zone = !*zone;
// And set the color
block->switchLights[index-1][0] = *zone;
block->switchLights[index-1][1] = *zone;
block->switchLights[index-1][2] = *zone;
}
// Always keep previous button state
// Keep previous button state
fCheckBoxes[zone].fLast = state;
});
}
@@ -205,10 +204,14 @@ class FaustEngine : public ScriptEngine {
int run(const string& path, const string& script) override
{
#if defined ARCH_MAC
#if defined ARCH_LIN
string temp_cache = "/var/tmp/VCV_" + generateSHA1(script);
#elif defined ARCH_MAC
string temp_cache = "/private/var/tmp/VCV_" + generateSHA1(script);
#else
string temp_cache = "" + generateSHA1(script);
#elif defined ARCH_WIN
char buf[MAX_PATH+1] = {0};
GetTempPath(sizeof(buf), buf);
string temp_cache = string(buf) + "/VCV_" + generateSHA1(script);
#endif
string error_msg;


Loading…
Cancel
Save