mimium
mimium copied to clipboard
Add Environment Variable
Add environment variable for getting execution-engine/audio-driver/commandline-option specific value, e.g. sample-rate.
For an example of sample-rate, the audio driver is launched after the global context is evaluated because if no dsp
function and @
operator are used, no need to launch the audio driver. However, the sample-rate will be typically acquired in the global context. Thus the sample-rate should be treated as a runtime-defined value somehow.
The proposed solution is as follows.
- Each runtime and the audio driver must implement an interface method to register environment variables, which is called before mimium's global context is evaluated.
- runtime can take optional environment variables from the constructor's argument.
- environment variables will be a pair of string and float to keep the simplicity of implementation for now.
- To get a specific environment variable, use special function
getEnv("hoge")
is used.
More extended features will be...
- Introduce a syntax sugar like
#SAMPLERATE
instead ofgetEnv("SAMPLERATE")
. - User can specify a requirement of the environment variables. If no sample rate is specified when a file backend is used, there will be no default value. This may cause unsafe behavior such as division by zero. Sometimes it is useful that backends can provide default values but sometimes it is useful that raising an error when specified values are not present in the environment-variables table.
For example, #SAMPLERATE
or getEnv("SAMPLERATE")
returns zero, on the other hand, !#SAMPLERATE
or getEnvRequired("SAMPLERATE")
raise error if no Environment Variable "SAMPLERATE" is provided.