1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
CLASS:: Getenv
summary:: Read (numeric) shell environment variables into a synth
categories:: UGens
DESCRIPTION::
Tries to grab a shell environment variable (with name key) and convert it to a floating-point value, which is output.
If the environment variable is not set, defaultval is output.
If the environment variable cannot be converted to a floating-point value, the output is zero.
NOTE: the shell context is that of the server, not the client.
EXAMPLES::
code::
Server.local.quit; // If server running, need to stop it for this example
// We'll modify the server boot procedure to set our env var...
~realserverprogram = Server.program;
Server.program = "export PANCREAS=220;" + Server.program
s.boot;
(
x = {
// Env var specifies frequency.
// If you change the env var name to one that isn't set, 440 is used.
SinOsc.ar(Getenv(\PANCREAS, 440), 0, 0.1);
}.play(Server.local);
)
x.free;
// This should restore the variable to what it was
Server.program = ~realserverprogram;
::
|