Page 1 of 1

Conditionals in Configuration

Posted: Fri Aug 20, 2021 3:59 pm
by dpoznan
I would like to have the equivalent of

#if (expression with $EnvVar)
# Some cfg statements
#else
# some more cfg statement
#end


or something equivalent.

I would like to be able to make a single cfg file that would work for Alsa and Jack
In particular I want to be able to run the example codes on my Mac as well as on my BeagleBone Black Portable Hearing Laboratory and select the environment with environment variable and have a single source example file.

Is there already a method to do this?

Re: Conditionals in Configuration

Posted: Fri Aug 27, 2021 4:35 pm
by tobiasherzke
The MHA configuration language does not support conditionals. I do not think it is possible to achieve what you want while restricting yourself to a single configuration file.

If you would allow splitting your configuration into multiple files, then it would be possible to have

Code: Select all

# main.cfg: Main cfg file

# fragsize, srate and nchannels_in need to be set before loading IO library
fragsize = ...
srate = ...
nchannels_in = ...

# Load system-specific IO library, config file name is stored in environment variable
?read:${EnvVar}

# MHA configuration common to both systems
...

Code: Select all

# ioMac.cfg: configuration file loading IO library on Mac
iolib = MHAIOJackdb
io.con_in = ...
...

Code: Select all

# ioPHL.cfg: configuration file loading IO library on PHL
iolib = MHAIOalsa
io.in.device = ...
...

Re: Conditionals in Configuration

Posted: Fri Aug 27, 2021 9:00 pm
by dpoznan
Yes!

I think that this would work.

I would like to update the examples to run on PHL as well as other devices.
I think this approach is workable.

Thanks.