Can mplayer (JACK) connect to more than one client?

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

I'd like to be able to connect mplayer, using its -ao jack:port= syntax to connect to more than one listen-client. I've tried a few ways, such as

Code: Select all

mplayer -ao jack:port="client_1","client_2"

But it only connects its output to "client_1"

In Raysession I can wire up the two listen-clients to mplayer but I'd like to make mplayer do it when it loads. Thank you!

-- Jack Elliott
They'll never take me alive

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Can mplayer (JACK) connect to more than one client?

Post by bluebell »

ThatJackElliott wrote: Sat Oct 28, 2023 10:06 pm

I'd like to be able to connect mplayer, using its -ao jack:port= syntax to connect to more than one listen-client. I've tried a few ways, such as

Code: Select all

mplayer -ao jack:port="client_1","client_2"

But it only connects its output to "client_1"

In Raysession I can wire up the two listen-clients to mplayer but I'd like to make mplayer do it when it loads. Thank you!

I solve such problems with jack-plumbing. It can handle regular expressions, too, so I can have it connect ports with changing names, e.g. with Audacity:

Code: Select all

(connect    "PortAudio:out_.*[13579]" "main:input_2")
(connect    "PortAudio:out_.*[02468]" "main:input_1")
(disconnect "PortAudio:out_.*" "system:playback_.*")

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

Jack-plumbing sounds ideal. I am not finding example syntax, whether it reads in a config file or how one gets it running with all the rules loaded and enforcing them. I find only the man page, and it doesn't clearly (to me) explain how a user uses it. Thank you!

-- Jack Elliott
They'll never take me alive

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Can mplayer (JACK) connect to more than one client?

Post by bluebell »

Write your rules into ~/.jack-plumbing then start jack-plumbing e.g. in a terminal.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

@bluebell -- thank you, that's enough to get me running.

-- Jack Elliott
They'll never take me alive

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

I spoke too soon. Jack-plumbing's syntax has me baffled.

I have everything running the way I want. My source-client is mplayer and I want to use jack-plumbing it to connect to the two listen-clients. According to aj-snapshot, here is how things are:

Code: Select all

<client name="MPlayer [24001]">
    <port name="out_0">
      <connection port="ST_FM_jack:in_1" />
      <connection port="ST_Stream_jack:in_1" />
    </port>
    <port name="out_1">
      <connection port="ST_FM_jack:in_2" />
      <connection port="ST_Stream_jack:in_2" />
    </port>
  </client>

How do I write my (connect ....) statements so jack-plumbing will force these connections?

mplayer likes to connect to the System Playback client when launched so I'll need to force a disconnect.

Thank you!

-- Jack Elliott
They'll never take me alive

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Can mplayer (JACK) connect to more than one client?

Post by bluebell »

ThatJackElliott wrote: Sun Oct 29, 2023 11:14 pm

I spoke too soon. Jack-plumbing's syntax has me baffled.

I have everything running the way I want. My source-client is mplayer and I want to use jack-plumbing it to connect to the two listen-clients. According to aj-snapshot, here is how things are:

Code: Select all

<client name="MPlayer [24001]">
    <port name="out_0">
      <connection port="ST_FM_jack:in_1" />
      <connection port="ST_Stream_jack:in_1" />
    </port>
    <port name="out_1">
      <connection port="ST_FM_jack:in_2" />
      <connection port="ST_Stream_jack:in_2" />
    </port>
  </client>

How do I write my (connect ....) statements so jack-plumbing will force these connections?

mplayer likes to connect to the System Playback client when launched so I'll need to force a disconnect.

Thank you!

Look with qjackctl or with jack_lsp how mplayer's ports and your destination ports are called exactly, then I can write jack-plumbing rules for you. Probably it will be like:

Code: Select all

(connect "MPlayer:out_0"  "ST_FM_jack:in_1")
(connect "MPlayer:out_1"  "ST_FM_jack:in_2")

(connect "MPlayer:out_0"  "ST_Stream_jack:in_1")
(connect "MPlayer:out_1"  "ST_Stream_jack:in_2")

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

Very kind of you, @bluebell! jack_lsp reveals

Code: Select all

MPlayer [24001]:out_0
MPlayer [24001]:out_1

What has been hanging me is knowing that mplayer picks up a different PID every time and the example syntax ("PortAudio:out.[13579]") has that ".[#####]" stuff which stumped me. It looks to force a pre-existing PID so somewhere in the "_.*" part the new PID somehow gets inserted.

A note: Before asking for help here, I did some googling and didn't find anything to help with syntax other than the man page and that's too bare-bones for my few remaining brain cells.

Thank you!

-- Jack Elliott
They'll never take me alive

tseaver
Established Member
Posts: 408
Joined: Mon Mar 13, 2017 6:07 am
Has thanked: 12 times
Been thanked: 102 times

Re: Can mplayer (JACK) connect to more than one client?

Post by tseaver »

@ThatJackElliott

You should be able to rename the mplayer JACK client using jack:name=mplayer or some such.

Also, per your original post: did you try repeating the jack:port option, rather than passing multiple values to a single one?

Ubuntu, Mixbus32C; acoustic blues / country / jazz
User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Can mplayer (JACK) connect to more than one client?

Post by bluebell »

ThatJackElliott wrote: Mon Oct 30, 2023 5:57 pm

Very kind of you, @bluebell! jack_lsp reveals

Code: Select all

MPlayer [24001]:out_0
MPlayer [24001]:out_1

What has been hanging me is knowing that mplayer picks up a different PID every time and the example syntax ("PortAudio:out.[13579]") has that ".[#####]" stuff which stumped me. It looks to force a pre-existing PID so somewhere in the "_.*" part the new PID somehow gets inserted.

A note: Before asking for help here, I did some googling and didn't find anything to help with syntax other than the man page and that's too bare-bones for my few remaining brain cells.

Thank you!

jack-plumbing can use regular expressions. That's its big advantage. Try

Code: Select all

(connect "MPlayer.*:out_0"  "ST_FM_jack:in_1")
(connect "MPlayer.*:out_1"  "ST_FM_jack:in_2")

(connect "MPlayer.*:out_0"  "ST_Stream_jack:in_1")
(connect "MPlayer.*:out_1"  "ST_Stream_jack:in_2")

The regular expression [02468] means 0 or 2 or 4 or 6 or 8.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

Thank you, @bluebell

[ EDIT: Never mind my question about /etc/jack-plumbing ]

jack-plumbing is throwing off this message:

Code: Select all

Rule file does not exist: '/etc/jack-plumbing'.

I will be using an @reboot script to start jackd and load the various clients. Where would you suggest I put in the /usr/bin/jack-plumbing command?

I need the system to hit the ground running.

Last edited by ThatJackElliott on Fri Nov 03, 2023 6:17 pm, edited 1 time in total.

-- Jack Elliott
They'll never take me alive

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

I mean, load the jack clients then run jack-plumbing, or load jack-plumbing first followed by the clients? Thank you!

-- Jack Elliott
They'll never take me alive

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Can mplayer (JACK) connect to more than one client?

Post by bluebell »

ThatJackElliott wrote: Fri Nov 03, 2023 5:23 pm

Thank you, @bluebell

[ EDIT: Never mind my question about /etc/jack-plumbing ]

jack-plumbing is throwing off this message:

Code: Select all

Rule file does not exist: '/etc/jack-plumbing'.

I will be using an @reboot script to start jackd and load the various clients. Where would you suggest I put in the /usr/bin/jack-plumbing command?

I need the system to hit the ground running.

jack-plumbing checks for /etc/jack-plumbing and ~/.jack-plumbing

A missing /etc/jack-plumbing is no problem if there is a ~/.jack-plumbing. But when run system-wide you should use /etc/jack-plumbing

A @reboot script runs as root. I don't recommend that. I start my scrips when logging in.

Anyway, my script is like:

Code: Select all

/usr/bin/jackd -P${PRIO} -p512 -t2000 -dalsa \
  -r$FREQ -p$PERIODS -n$BUFFERS -dhw:$HW $JMIDI \
/tmp/jackd.log 2>&1 &
jack_wait -w

sleep 1

while true
do
  jack-plumbing -u 90000
  sleep 1
done

I've forgotten why I restart jack-plumbing when it stops. :mrgreen:

The greater sign (>) before /tmp/jackd.log 2>&1 & is not correctly displayed.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

ThatJackElliott
Established Member
Posts: 57
Joined: Thu Jul 27, 2023 4:06 pm
Been thanked: 3 times

Re: Can mplayer (JACK) connect to more than one client?

Post by ThatJackElliott »

A @reboot script runs as root. I don't recommend that. I start my scrips when logging in.

The machine is meant to hit the ground running when restarted, unattended, without anyone needing to log in. If there's another way to run the script I don't know what it is.

I've forgotten why I restart jack-plumbing when it stops.

Sometimes I forget why I went into a room. :lol:

Thank you for the help!

-- Jack Elliott
They'll never take me alive

tseaver
Established Member
Posts: 408
Joined: Mon Mar 13, 2017 6:07 am
Has thanked: 12 times
Been thanked: 102 times

Re: Can mplayer (JACK) connect to more than one client?

Post by tseaver »

@ThatJackElliott

The machine is meant to hit the ground running when restarted, unattended, without anyone needing to log in. If there's another way to run the script I don't know what it is.

Hmm, I'm not sure I understand here: is your machine running "headless" (no X / Wayland session running)?

My recording machine is set to log me in without a password on boot, which means that processes launced at X / desktop manager startup are similar to @root jobs, except that they run as me, rather than as root, which I find an overall win.

Ubuntu, Mixbus32C; acoustic blues / country / jazz
Post Reply