HoerTech-gGmbH / openMHA

The open Master Hearing Aid (openMHA)
http://www.openmha.org
GNU Affero General Public License v3.0
252 stars 74 forks source link

Is it possible to access a monitor variable for an external bash script? #20

Closed JohnAbarro closed 5 years ago

JohnAbarro commented 5 years ago

I'm working with a system that's supposed to automatically optimize the configuration after a long silent period. It would mean that I have to check the presence of a signal and run a different cfg file. I was wondering if it were possible to compare a monitor variable that has the average amplitude of an audio block to a threshold value that I defined. I would want this to happen at a bashrc loop so that I could freely switch between the two configurations, well of course I would naturally have to stop the current cfg file to give way to the other. But I want to know how it would be possible to read monitor variables from the bash script, because I might have misinterpreted the manual to be limited by plugin-to-plugin case only. Thank you.

Pardon my insufficient knowledge, if ever this was a no-brainer for someone who has read the manual.

HoerTech commented 5 years ago

In bash: echo "nchannels_out?val" | nc -w 1 localhost 33337 | head -1

Replace nchannels_out with the full path of the variable that you want to read. Install netcat if command nc is not found. To assign the current result to a bash variable:

nchannels_out=$(echo "nchannels_out?val" | nc -w 1 localhost 33337 | head -1)

You need to repeat the assignment to update the value.