mha startup in Mahalia

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

mha startup in Mahalia

Post by dpoznan » Thu Aug 12, 2021 7:50 pm

When Mahalia starts, mha is started in daemon mode I assume. Where is it started? I cannot find any script
in init.d or any of the usual places.

I want to be able to run the example cfgs on the device, and therefore must initiate mha in interactive mode.
Trying to start mha in a terminal window results in:

Error: bind: Address already in use

I am hesitant to kill the running mha process. My thought is to be able to prevent mha from starting at boot time
while I am experimenting. Then re-enable its startup when done. However, I cannot find where it get started.

Any suggestions are welcome.

Dan.

hendrikkayser
Posts: 38
Joined: Fri May 10, 2019 7:58 am

Re: mha startup in Mahalia

Post by hendrikkayser » Thu Aug 12, 2021 8:32 pm

Hi Dan,
the mha process is started by a system service called "mahalia".
Excecuting

Code: Select all

sudo systemctl stop mahalia
will stop the service and the mha process accordingly. I recommend to let the service start once at boot time as it also sets some important sound device parameters.

Code: Select all

sudo systemctl start mahalia
starts the service again.

Another option would be removing the mha start options provided in
/etc/mahalia/config

with OPENMHA_OPTS="" the mahalia service will start and "empty" mha process that you can use interactively through netcat:

Code: Select all

nc localhost 33337
on the PHL or

Code: Select all

nc 10.0.0.1 33337
from another computer that is connected to the PHL via wifi.

Best,
Hendrik

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

Re: mha startup in Mahalia

Post by dpoznan » Thu Aug 12, 2021 10:13 pm

Thanks for the info...

Now next... where does Jack get started?

When I try to run the following... I get an error due to JACK server not being available...

mha [2] ?read:gain_live_getting_started.cfg
(MHA:success)
mha [3] cmd=start
(mhafw_lib) IO error: (mhajack) Unable to connect to JACK server 'default' as client 'MHA'.
(MHA:failure)

When trying to use jack_control to start Jack, I also get an error due to the lack of X11 on this Mahalia install

Dan..

hendrikkayser
Posts: 38
Joined: Fri May 10, 2019 7:58 am

Re: mha startup in Mahalia

Post by hendrikkayser » Fri Aug 13, 2021 6:07 am

JACK is also started by the mahalia system service.

You can do that manually with the following lines:

Code: Select all

export JACK_NO_AUDIO_RESERVATION=1
jackd -S -R -P90 -dalsa -dhw:boneaudioext -r<SRATE> -p<FRAGSIZE> -n2 
Make sure that SRATE and FRAGSIZE match the values used in your openMHA configuration.

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

Re: mha startup in Mahalia

Post by dpoznan » Fri Aug 13, 2021 6:30 pm

Thanks for the info.

However, since the io lib that is now being used in Mahalia is MHAIOalsa, I think that the examples should be written to
use alsa rather than Jack. All of the example cfg files use iolib = MHAIOFile or iolib = MHAIOJackdb or iolib = MHAIOJack.

The examples need to be updated rather than manually starting jack.

hendrikkayser
Posts: 38
Joined: Fri May 10, 2019 7:58 am

Re: mha startup in Mahalia

Post by hendrikkayser » Sat Aug 14, 2021 3:01 pm

Please note that the examples provided with the openMHA software package are meant to be useful for all platforms that are supported by openMHA, i.e., computers that run Linux, Mac OS, and Windows operating systems. The latter two need to use JACK or audio files for sound in- and output with openMHA. JACK being also a good option for Linux systems makes JACK and audio files the common denominator for all supported systems.
Mahalia is just one special use case and it makes sense to use MHAIOAlsa to spare a little bit of CPU on the PHL. Nevertheless you can use JACK under Mahalia and have it automatically started by the mahalia system service by removing the entry "NOJACK=1" in your /etc/mahalia/config file. The JACK parameters are also set up in that file.

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

Re: mha startup in Mahalia

Post by dpoznan » Sun Aug 15, 2021 8:15 pm

So I turned on Jack by commenting out the "NOJACK=1"
I get the following error when trying to run 00-gain example.

mha [1] ?read:gain_live.cfg
(MHA:success)
mha [2] cmd=start
(mhafw_lib) IO error: (mhajack) Unable to connect to JACK server 'default' as client 'MHA'.


Something else need changing in order to run with Jack?

Dan..

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

Re: mha startup in Mahalia

Post by dpoznan » Sun Aug 15, 2021 8:42 pm

I noticed that after I stopped mahalia, so that I could run mha interactively, jack daemon disappeared, but alsactl remained.

Last login: Tue Aug 3 15:47:13 2021 from 10.0.0.132
mha@mahalia:~$ ps -el|grep alsa
4 S 0 210 1 0 99 19 - 773 - ? 00:00:00 alsactl
mha@mahalia:~$ ps -el|grep jack
0 S 1000 494 305 14 80 0 - 24196 SyS_rt ? 00:00:05 jackd
mha@mahalia:~$ cat StopMHA

sudo systemctl stop mahalia
mha@mahalia:~$ sudo systemctl stop mahalia

mha@mahalia:~$
mha@mahalia:~$ ps -el|grep jack
mha@mahalia:~$ ps -el|grep alsa
4 S 0 210 1 0 99 19 - 773 - ? 00:00:00 alsactl
mha@mahalia:~$

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

Re: mha startup in Mahalia

Post by dpoznan » Sun Aug 15, 2021 9:06 pm

So if I start jackd with
mha@mahalia:~$ export JACK_NO_AUDIO_RESERVATION=1
mha@mahalia:~$ jackd -S -R -P90 -dalsa -r44100 -p64 -n2

jackdmp 1.9.12
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2017 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 90
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:0|hw:0|64|2|44100|0|0|nomon|swmeter|-|32bit
configuring for 44100Hz, period = 64 frames (1.5 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback



and then run mha and the 00-gain example

mha [1] ?read:poz_gain_live.cfg
(MHA:success)
mha [2] cmd=start
(mhafw_lib) IO error: (MHAIOJack) Mismatching sample rate:
JACK is running with 32 kHz, the framework requires 44.1 kHz.
(MHA:failure)
mha [3] cmd=quit
(MHA:success)


I get complaint about the sample rate being 32kHz, even though I started the daemon with -r44100

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

Re: mha startup in Mahalia

Post by tobiasherzke » Sun Aug 29, 2021 10:19 am

It may be that the sound card that you are using does not support 44100Hz sampling rate.

Post Reply