Bug 252188 - audio/pd: Add MIDI support via PortMIDI and sndio
Summary: audio/pd: Add MIDI support via PortMIDI and sndio
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Robert Clausecker
URL:
Keywords: needs-qa
Depends on:
Blocks: 261883
  Show dependency treegraph
 
Reported: 2020-12-27 06:32 UTC by Timothy Beyer
Modified: 2023-04-18 21:59 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (brittlehaus)


Attachments
audio_pd.diff (24.69 KB, patch)
2020-12-27 06:32 UTC, Timothy Beyer
no flags Details | Diff
patch-audio_pd-umidi_and_freebsd13.diff (24.78 KB, patch)
2021-08-03 03:01 UTC, Timothy Beyer
no flags Details | Diff
[PATCH] patch pd with MIDI support, fix build on FreeBSD 13 if not (26.04 KB, patch)
2022-02-09 15:07 UTC, Timothy Beyer
no flags Details | Diff
MIDI support, fix error glist_reloadingabstraction, correct license, add NLS support (26.11 KB, patch)
2022-02-11 08:50 UTC, Timothy Beyer
fuz: maintainer-approval+
Details | Diff
audio/pd: update to 0.53-2 (22.19 KB, patch)
2023-04-17 22:32 UTC, Robert Clausecker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Beyer 2020-12-27 06:32:51 UTC
Created attachment 220980 [details]
audio_pd.diff

I added MIDI support to the current version of audio/pd using the included in-tree version of PortMIDI.  I disabled JACK support for now since I couldn't verify if it served any purpose, but I don't really mind if the maintainer wants to keep it on by default.  I must admit that I haven't had a chance to test the JACK option yet, so maybe it should be enabled as well.  I just know that the port, including PortMIDI support should fully work either with the JACK option disabled or enabled.

this patch is in a large part derived from Raphael Graf's
patches for a sndio backend on the OpenBSD audio/portmidi port, enhanced to
detect a variable number of MIDI (umidi) devices:
http://openbsd-archive.7691.n7.nabble.com/audio-portmidi-input-td363848.html
https://marc.info/?l=openbsd-ports&m=155221816900336&w=2

I was able to add support for 9999 MIDI inputs, although more work needs to be done to get MIDI outputs working.  I can submit a patch for that soon.

I have compiled and tested this port heavily on multiple FreeBSD 12.0 and 12.1 RELEASE systems, and I have used this patched version extensively with numerous MIDI input devices (see below; input only tested so far, since I haven't implemented MIDI output support in audio/pd yet).

As noted above, I've tested PortMIDI on FreeBSD with the following MIDI devices:
*  Roger Linn LinnStrument
*  Hornberg Research hb1 breath controller
*  Keith McMillen Instruments SoftStep 2 foot controller
*  Keith McMillen Instruments QuNeo
*  Roland GR-55 Guitar Synthesizer (MIDI output only on foot pedal, USB MIDI output requires a special driver)
*  Evolution U-Control UC-33e
*  Behringer FCB1010 Foot Controller
*  Yamaha PSR-280 keyboard

My apologies for sitting on this patch since July, I just haven't had enough opportunity to test it until recently...
Comment 1 Timothy Beyer 2020-12-27 07:21:12 UTC
Note that I was able to test all of these MIDI devices at once, using a few USB MIDI interfaces.  Since it was so many devices that I didn't have enough USB ports or USB MIDI interfaces for each device individually, mostly for older devices lacking a USB port, I used a Kenton MERGE-8 which in turn was associated with a single USB MIDI device to verify if it handled several devices on one UMIDI device correctly, which also works.

As far as I can tell, PureData should also work correctly in the much more common case of lacking any MIDI devices.  It currently doesn't detect devices by their name (but rather by number, which could be a bit more intuitive), which is a limitation that I intend to address at some point, but as long as it is plugged in before starting pd, then it should be correctly detected.

I have also experimented with midithru devices created by midicat (part of audio/sndio), so that works in audio/pd as well.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2020-12-27 07:29:20 UTC
Thank you for the report and patch Timothy

^Triage: [tags] in issue Titles are deprecated
Comment 3 Timothy Beyer 2021-08-03 03:01:45 UTC
Created attachment 226899 [details]
patch-audio_pd-umidi_and_freebsd13.diff

Updated patch against most recent version of audio/pd, fix build on FreeBSD 13 (which is also needed on the most recent version of audio/pd), make it closer to audio/pd without getting rid of improved features like NLS support and fixes for portlint warnings

A more conservative patch will be provided in another PR which just fixes the FreeBSD 13 build, adds proper NLS support, gets rid of portlint warnings, but without MIDI support.

This patch at present provides all of those features in addition to adding support for MIDI devices.
Comment 4 Be 2021-08-03 19:31:48 UTC
Hi, I'm a maintainer of Mixxx DJ software which also uses PortMidi. I recently forked this unmaintained old library to rewrite its really hacky old CMake build system with modern CMake and clean up the repository: https://github.com/mixxxdj/portmidi

It would be great to merge your patches for PortMidi upstream and use that rather than this vendored copy in pd. I would be happy to review pull requests for the repository I linked above.
Comment 5 Timothy Beyer 2021-08-04 03:30:26 UTC
(In reply to Be from comment #4)
I agree, as later versions use upstreamed portmidi, and a I made a PR for the official audio/portmidi, which isn't used by this version.

I want to update to the latest version of pd soonish, so when I switch to that, I'll use the upstreamed portmidi, or better yet, your version with the improved cmake build system.
Comment 6 Timothy Beyer 2021-08-04 03:33:02 UTC
If you have any suggestions, or improved patches on this port that I submitted last year, I'm open to switching it to use your repository:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252186
Comment 7 Timothy Beyer 2022-02-09 15:07:14 UTC
Created attachment 231683 [details]
[PATCH] patch pd with MIDI support, fix build on FreeBSD 13 if not

Although the prior patch worked fine as far as I know, including for FreeBSD 13, I have updated the patch again with more cleanups, and it uses git format-patch format now.

This is a superset of my other PR for audio/pd, which merely fixes the build, this also adds MIDI support.

An updated note regarding usage of embedded PortMIDI, aside from the way this old version of audio/pd works with an embedded library, at the moment, I have not been able to get ALSA RAW MIDI to work on FreeBSD without a currently un-submitted port that I have done of audio/a2jmidid that I made (long story short is that while the ALSA sequencer API does work fine with audio/alsa-seq-server, RAW ALSA MIDI on FreeBSD is a lot more trouble, and that API only worked for me when I did hacks that shouldn't work.  If Be has since added sndio support to the new portmidi, then this may not apply, as I haven't had a chance yet to verify, but otherwise, the embedded library with sndio is the tried and true method for me).

As with my other PR with fewer features, I now request to become the new maintainer of audio/pd, if the prior maintainer is okay with such a change, or if committers allow to do so, but audio/pd has been broken on FreeBSD 13 for months and months broken on FreeBSD 13, so someone needs to approve fixes to the port.

If the existing maintainer of audio/pd responds, and wishes to continue being maintainer, then that is fine with me, but multiple patches have been submitted to fix issues for a really long time, without a response from the maintainer.
Comment 8 Timothy Beyer 2022-02-09 15:12:59 UTC
Also note that I brought back JACK support by default (as is on the existing port) because it could be useful to route audio between applications, which before I didn't understand.
Comment 9 Be 2022-02-10 02:10:03 UTC
I did not end up merging sndio support into the PortMidi fork because there were questions about whether the build system should allow building multiple backends which I didn't get an answer to: https://github.com/mixxxdj/portmidi/pull/6#issuecomment-898032326

Since then, the original author of PortMidi resumed working on it, moved it to GitHub at https://github.com/PortMidi/portmidi and made the first release in 12 years. My rewrite of the build system was not merged because I didn't want to keep dealing with the maintainer pushing conflicting changes while I was actively working on it, however, at least the build system works without requiring Java.
https://github.com/PortMidi/portmidi/pull/3

If you're up for it, I'd suggest making a pull request for the new upstream repository to add sndio support.
Comment 10 Timothy Beyer 2022-02-10 02:36:52 UTC
(In reply to Be from comment #9)
Thanks, good to know, and thanks for the link to the thread, that sounds useful.  If I send Roger Dannenberg a patch, I'll implement MIDI output, which I think my patch was missing.  I hope he incorporates your improvements to the project, but thanks for maintaining it in his absence.
Comment 11 Timothy Beyer 2022-02-11 08:50:41 UTC
Created attachment 231746 [details]
MIDI support, fix error glist_reloadingabstraction, correct license, add NLS support

Same as previous patch, but bump PORTREVISION, and correct license

Notes on license:

  *  expr~ was no longer LGPL as of 2016-03-20, months before this release of pd

  *  the author also re-licensed the standalone library to BSD on their own website: http://yadegari.org/expr/expr.html
Comment 12 Robert Clausecker freebsd_committer freebsd_triage 2023-04-17 22:31:41 UTC
Comment on attachment 231746 [details]
MIDI support, fix error glist_reloadingabstraction, correct license, add NLS support

Maintainer timeout
Comment 13 Robert Clausecker freebsd_committer freebsd_triage 2023-04-17 22:32:36 UTC
Created attachment 241550 [details]
audio/pd: update to 0.53-2

Maintainer timeout.

Please also see the attached patch which updates audio/pd to 0.53-2, the current version.
Comment 14 Robert Clausecker freebsd_committer freebsd_triage 2023-04-17 22:41:18 UTC
@acm, are you still interested in this one?  Otherwise I would commit with my next batch.
Comment 15 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2023-04-17 23:17:24 UTC
(In reply to Robert Clausecker from comment #14)
Hello Robert, please take it :)
Comment 16 Robert Clausecker freebsd_committer freebsd_triage 2023-04-17 23:20:35 UTC
Will commit this one (i.e. attachment #231746 [details]) with my next batch.  Feel free to update to 0.53-2 or whatever the current version is in a new PR at your own leisure.

Thank you for stepping up to maintain this port!
Comment 17 commit-hook freebsd_committer freebsd_triage 2023-04-18 21:56:19 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6fbe3e61eebe76d7cc5a7c4cc8442002e7da6e59

commit 6fbe3e61eebe76d7cc5a7c4cc8442002e7da6e59
Author:     Timothy Beyer <beyert_freebsd@fastmail.net>
AuthorDate: 2022-02-11 08:36:31 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-04-18 21:55:30 +0000

    audio/pd: Add MIDI support via PortMIDI and sndio

    Also unbreak port on FreeBSD 13+.
    Submitter becomes maintainer.

    PR:             252188
    Approved by:    brittlehaus@gmail.com (maintainer timeout)

 audio/pd/Makefile                                  |  58 +++-
 audio/pd/files/extra-patch-configure.ac (new)      |  10 +
 .../files/extra-patch-portmidi_Makefile.am (new)   |  27 ++
 ...-patch-portmidi_pm__common_CMakeLists.txt (new) |  54 +++
 .../extra-patch-portmidi_porttime_ptlinux.c (new)  |  46 +++
 audio/pd/files/extra-patch-src_Makefile.am (new)   |  11 +
 .../files/extra-patch-src_s__midi__oss__pm.c (new) | 147 ++++++++
 audio/pd/files/portmidi/pm_sndio/pmsndio.c (new)   | 382 +++++++++++++++++++++
 audio/pd/files/portmidi/pm_sndio/pmsndio.h (new)   |   5 +
 audio/pd/pkg-descr                                 |   7 +
 10 files changed, 730 insertions(+), 17 deletions(-)
Comment 18 Robert Clausecker freebsd_committer freebsd_triage 2023-04-18 21:59:05 UTC
Thank you for your contribution.