Conditionals in Configuration

Post Reply
dpoznan
Posts: 68
Joined: Wed Jun 30, 2021 10:50 pm

Conditionals in Configuration

Post by dpoznan » Fri Aug 20, 2021 3:59 pm

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?

tobiasherzke
Posts: 118
Joined: Mon Jun 24, 2019 12:51 pm

Re: Conditionals in Configuration

Post by tobiasherzke » Fri Aug 27, 2021 4:35 pm

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 = ...
...

dpoznan
Posts: 68
Joined: Wed Jun 30, 2021 10:50 pm

Re: Conditionals in Configuration

Post by dpoznan » Fri Aug 27, 2021 9:00 pm

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.

Post Reply