Debugging cfg files

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

Debugging cfg files

Post by dpoznan » Thu Sep 30, 2021 12:12 am

I am trying to convert the example 01-dynamic-compression to use headset and stereo mic and alsa for a PHL
device. So I have to sort the input & output. I have made changes to include sort in a list of algos. I can run mha interactively on that cfg file but I get nothing. in headset or BTEs.
I tried running with --log, but there is nothing in the log.

How does one debug a cfg file? Are there traces? I don't even know if there is a continuous path from input to output.

Is there some sort of emulator for debugging?

Dan..

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

Re: Debugging cfg files

Post by tobiasherzke » Sat Oct 02, 2021 4:06 pm

When an MHA configuration does not produce the desired output, you should first check if the MHA is currently performing signal processing:

state?

If this does not respond with "running", then fix the error (check that cmd=start is executed, check asyncerror).

When MHA runs but still does not produce the expected sound output, then I will typically insert multiple instances of the rmslevel plugin into the configuration to check if the input signal reaches these parts of the processing graph. I may also insert instances of the sine plugin to inject sound if I cannot rely on the input signal.

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

Re: Debugging cfg files

Post by dpoznan » Sun Oct 03, 2021 3:04 am

Thanks for your help. I will try it. BTW..How do you see the rmslevel output? In the log?

Dan..

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

Re: Debugging cfg files

Post by dpoznan » Sun Oct 03, 2021 4:32 pm

I wrote a python code that uses mha.get_val() via 10.0.0.1:33337 on my Mac.

Dan..

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

Re: Debugging cfg files

Post by dpoznan » Mon Oct 04, 2021 10:14 pm

I can't seem to get the python code to get a value from rmslevel as a way of debugging cfg files.

I am running the following cfg
nchannels_in = 8
srate=24000
fragsize=55
iolib=MHAIOalsa
io.in.device=hw:0
io.out.device=hw:0
io.priority=90

# MHA library name
mhalib = mhachain

mha.algos=[route:sort_input rmslevel gain route:sort_output gain:mute_dummies]

# line L, line R, rear L, rear R front L, front R
mha.sort_input.out=[:2 :6 :4 :5 :0 :1]

# left hs, right hs, left bte, right bte
mha.sort_output.out=[:2 :3 :0 :0 :0 :0 :1 :0]

mha.gain.gains = [0 0 1 0 0 1]

# Use gain plugin to mute dead channels in order to avoid cross-talk to active channels
# Mute all channels that are not exposed to the outside
mha.mute_dummies.min = -120

mha.mute_dummies.gains = [-120 -120 0 -120 -120 -120 0 -120]

cmd=start

============================================

On my mac I am running:
import time
import sys
import os
path=os.environ.get('PYTHONTOOLS')
sys.path.append(path)
from openMHA import MHAConnection

# Make an MHAConnection instance to be able to communicate with the openMHA.
# Choose your individual host and port by calling MHAConnection(host,port).
# The default is host="localhost" and port=33337.
mha = MHAConnection("10.0.0.1","33337")

count = 0
while (count < 100):
count=count+1
print("rmslevel help :", mha.get_help('mha.rmslevel')[0:])
print("rmslevel type :", mha.get_type('mha.rmslevel')[0:])
print("rmslevel val:", mha.get_val('mha.rmslevel')[0:])

time.sleep(2)

# Start the mha processing and stop it after finishing.
#mha.set_val('cmd','start')
#mha.set_val('cmd','quit')
#print("Remember to restart mha via mha --interface=10.0.0.1 --port=33337")

===================================================

I get the following error....
% python3.9 s.py
rmslevel help : This algorithm displays block based RMS level informations.
Results are stored in these AC variables (replace 'rmslevel'
by the configured plugin name):

rmslevel_level_db
rmslevel_peak_db
rmslevel_level
rmslevel_peak
The 'peak' variables are only available during waveform processing.
rmslevel type : parser
Traceback (most recent call last):
File "/Users/macbook2020/projects/Hearing-Aid-Prototype/Bat-and-Cat/Running-MHA-Interactive/s.py", line 21, in <module>
print("rmslevel val:", mha.get_val('mha.rmslevel')[0:])
File "/Users/macbook2020/projects/Hearing-Aid-Prototype/openMHA-4.16.0/mha/tools/python/openMHA/MHAConnection.py", line 70, in new_func
ret = func(*new_args, **new_kwargs)
File "/Users/macbook2020/projects/Hearing-Aid-Prototype/openMHA-4.16.0/mha/tools/python/openMHA/MHAConnection.py", line 173, in get_val
data = self.get_val_raw(path)
File "/Users/macbook2020/projects/Hearing-Aid-Prototype/openMHA-4.16.0/mha/tools/python/openMHA/MHAConnection.py", line 161, in get_val_raw
return self._send_command(path.strip() + b'?val\n')
File "/Users/macbook2020/projects/Hearing-Aid-Prototype/openMHA-4.16.0/mha/tools/python/openMHA/MHAConnection.py", line 123, in _send_command
raise ValueError(
ValueError: Error sending message b'mha.rmslevel?val\n' with error code 1:
Response: b'\n(mha_parser) Invalid query mode: "val"\n(MHA:failure)'




Any suggestions.....


Dan..

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

Re: Debugging cfg files

Post by dpoznan » Tue Oct 05, 2021 12:54 am

Changed
mha.algos=[route:sort_input rmslevel gain route:sort_output gain:mute_dummies]

to
mha.algos=[route:sort_input rmslevel:rd1 gain route:sort_output gain:mute_dummies acmon]

in the cfg file, and access the rms vac vars via

print("mha.acmon.rd1_level_db:",mha.get_val('mha.acmon.rd1_level_db'))


FINALLY!!!!!

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

Re: Debugging cfg files

Post by tobiasherzke » Tue Oct 05, 2021 7:17 pm

Good that you found a solution. With your solution, you are querying an AC variable that the rmslevel plugin publishes with the help of the acmon plugin.

rmslevel also publishes the measured levels directly as configuration variables. To find out which configuration variables the rmslevel plugin publishes, you can make use of the command line tool analysemhaplugin, included with openMHA:

Code: Select all

analysemhaplugin rmslevel
...
# RMS level in dB
# vector<float> (monitor)
level_db = [0 0]


which means for your first example, that you would be able query the value of mha.rmslevel.level_db with your Python code.

The information that rmslevel publishes the current levels in dB under this name should also be listed in the openMHA plugin manual, but I see that at least in the plugin manual for release 4.16.1, this information is missing. The plugin manual is automatically generated for each openMHA release. We will investigate why this information is missing and fix it.

Post Reply