Pure Data (LibPd) to JACK client

Discuss anything new and newsworthy! See http://planet.linuxaudio.org and https://libreav.org/news for more Linux Audio News!

Announcements of proprietary software may fit better in the Marketplace.


Moderators: raboof, MattKingUSA, khz

Post Reply
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Pure Data (LibPd) to JACK client

Post by GMoon »

New Repository: https://github.com/GModal/pd2jack

pd2jack is a shell application for running Pure Data patches as minimalist JACK clients, using LibPd. I.E., the patches run "headless" and without a GUI. However, parameters can be passed to the patch from the cmd line.

Up to 16 audio ports and/or 16 MIDI ports can be opened per instance. Ports are defined at startup with cmd arguments, not by the Pd patch.

Example invocation, with three parameters passed to the patch:
pd2jack -p ./pd/rev_ctrl.pd -n MyPatch -s -v 1 -a 2:2 -m 1:0 '1 90' '2 99' '3 0.7'

Currently the code only compiles in Linux (I'm sure the Makefile won't work elsewhere), but I'll try to update that over time.
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Pure Data (LibPd) to JACK client

Post by Basslint »

Wow, this is awesome!  :D
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Basslint wrote: Wed May 26, 2021 8:33 am Wow, this is awesome!  :D
Thank you! :D

If you have an opportunity to compile and test, please send feedback. It's early in the dev cycle...
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Pure Data (LibPd) to JACK client

Post by Basslint »

GMoon wrote: Wed May 26, 2021 1:49 pm If you have an opportunity to compile and test, please send feedback. It's early in the dev cycle...
If you start releasing numbered releases (e.g. 0.1.0) I can make an openSUSE package for it, so that it potentially gets some users. I will test and report back :D
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Basslint wrote: Thu May 27, 2021 7:03 am If you start releasing numbered releases (e.g. 0.1.0) I can make an openSUSE package for it, so that it potentially gets some users. I will test and report back :D
Cool - thanks!

As of today, I think I've got the project to link statically, and that was a limitation to an official release, since the LibPd dynamic library isn't part of many distro repositories (it's not in Ubuntu, for sure).

I wouldn't do something sketchy like including the libpd.so lib file; it's not mine to distribute, and could cause conflicts later (especially if they do package LibPd).
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

The pd2jack project now has an official release, v0.1.0 (!)

https://github.com/GModal/pd2jack

Issues:
- MIDI Sysex msgs larger than 512 are not sent correctly, and will probably send garbage.
- MIDI RT Song Position & Song Select are not implemented (from the encapsulated patch -> output - they should input correctly).

The project now links statically, and doesn't need the LibPd library (libpd.so) installed.

A linux executable (made with Ubuntu 20.04.2 LTS) is available on the release page/link:
https://github.com/GModal/pd2jack/releases/tag/v0.1.0

I would still recommend cloning and compiling, but that involves installing & compiling LibPd (and Pure Data) first.

I will work on these issues. :)
Thanks!!
DG
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Pure Data (LibPd) to JACK client

Post by Basslint »

OK, I am trying to get a build into openSUSE.

My feedback as a packager:
1) If you want to link libpd statically, you should provide libpd as a git submodule and then build and link that from make - having packagers do it is too complicated on virtualized build environments
2) In the Makefile, the "lib" in $(LIBPD_DIR)/lib should not be hardcoded. In openSUSE for example library directories are architecture-dependent, for the library directory for 64-bit machines (the majority) is /usr/lib64 . For this reason, better if the user can provide a LIBDIR variable to make
3) The default target should look for libpd.a in the user library directory first (e.g. /usr/lib64, then /usr/local/lib64), and then in the same directory
4) Better if you rename LIBPD_DIR to PREFIX, as it's more standardized.

I hope these changes are not too much. I am a developer too and having been a packager for almost two years now has made me realize that setting up these thing as a coder is boring but necessary if you want people to actually use the program :D
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Basslint wrote: Tue Jun 08, 2021 6:04 am OK, I am trying to get a build into openSUSE.

My feedback as a packager:

......

I hope these changes are not too much. I am a developer too and having been a packager for almost two years now has made me realize that setting up these thing as a coder is boring but necessary if you want people to actually use the program :D
Thank you -- those are great suggestions. I'll work on that asap.

I'd toyed with the idea of adding libpd as a submodule, and ultimately that's a good route (unless and until packaging the LibPd library binary is an option). I will need to invoke the Makefile in the libpd submodule with the static option, but I'll figure that out...

I'm actually a little relieved this wasn't submitted yet. I'm close to finishing a re-write of almost all the LibPd -> JACK MIDI code, and it's much simplified, and more complete. The MIDI coding, btw, is 99% of the challenge -- audio ports were easy.
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Hmmm, if libpd is a git submodule, then the libraries need not be installed. They're built in the ./libpd/libs folder, and a relative path should be a simple reference for any distro.
Basslint
Established Member
Posts: 1511
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy
Has thanked: 382 times
Been thanked: 298 times

Re: Pure Data (LibPd) to JACK client

Post by Basslint »

GMoon wrote: Wed Jun 09, 2021 9:47 pm Hmmm, if libpd is a git submodule, then the libraries need not be installed. They're built in the ./libpd/libs folder, and a relative path should be a simple reference for any distro.
Sure, paths relative to the build directory are universal. Please tag me as soon as you are finished, work at your own pace, no rush :D
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

Please donate time (even bug reports) or money to libre software 🎁

Jam on openSUSE + GeekosDAW!
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Basslint wrote: Thu Jun 10, 2021 6:17 am Sure, paths relative to the build directory are universal. Please tag me as soon as you are finished, work at your own pace, no rush :D
Thanks - will do.

I've tested this with Makefile changes and a libpd subdir, and it works well. I'll add a branch, the submodule to github, and test some more before merging...
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

A new release for pd2jack today (v0.1.6).

https://github.com/GModal/pd2jack
  • This version has improved MIDI support (all RT message supported). Nearly all of the MIDI code was rewritten (and simplified).
  • LibPd is now a submodule, and the build process streamlined.
  • A Linux binary (zipped w/docs & Pd examples) is available with the release (Building from source is still recommended).
Thanks!
GMoon
Established Member
Posts: 51
Joined: Sat Oct 03, 2020 1:10 pm
Has thanked: 11 times
Been thanked: 20 times

Re: Pure Data (LibPd) to JACK client

Post by GMoon »

Another new release for pd2jack (v0.1.9):

https://github.com/GModal/pd2jack

New with v0.1.9, enabling interactive mode (-i) interprets a "live stream" of parameter pairs (in the console), which are passed on as "param" messages to the Pd patch. These work like the startup "parameter pairs," except for:
  • No quotes are required
  • Passed in real time during run
  • Each pair is terminated with a newline
A stream of pairs might look something like this:

Code: Select all

1 89
1 88
1 87
1 86
3 2180
3 2200
3 2221
3 2241
3 2261
4 19
NOTE: this has some cool implications -- a separate GUI application can act as a front-end, and "pipe" data into pd2jack.

So ANY GUI api could be used...just convert any input to parameter pairs and print them to the console. This isn't a crazy as it sounds -- two applications connected with a pipe are separate processes, and if the numeric char strings aren't actually printed to the console (the are not, with pipe), the CPU load is pretty small.

Here's a example of how it's invoked:

./revUI | pd2jack -i -p rev_i.pd

(where revUI is the GUI, and pd2jack is running the "rev_i.pd" patch in interactive mode.)

Simple video demo:
https://www.youtube.com/watch?v=p6WiFfAxf8U

There are other options for IPC with Pd (netsend, netreceive & some custom objects) and piping the console might feel like a hack, but it is simple and quick. An additional method (sockets?) might be added to pd2jack in the future...(yeah, I'm thinking maybe a plugin interface).

It's also been suggested this mode might be useful for people with disabilities. I've also successfully piped the output of pd2jack to a speech synthesis module, sending text via Pure Data's [print] object, as well as any info output in "verbose" mode. It's likely that would work with a regular "headless" install of Pure Data, of course.

Interactive Mode Special Commands (w/ "@" prefix)

Interactive mode also includes a set of special cmds, for controlling some internal operations. Each of these cmds is preceeded with an "at" symbol (@), to differentiate the cmds from the parameter stream. Here's a list:
  • @openPatch <name> : load a different patch into the LibPd space (closes current patch first).
  • @closePatch : closes the current patch
  • @reopenPatch : reopens the last valid patch (patch can be closed or already open)
  • @im_sleepTime <int> : sleep time (ms, 5-500) between data fetches for interactive mode.
Invoking "@reopenPatch" on an already open patch will reload the patch.

I expect more cmds will be added in the future.
Post Reply