Bug 252188 - audio/pd: Add MIDI support via PortMIDI and sndio
Summary: audio/pd: Add MIDI support via PortMIDI and sndio
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jose Alonso Cardenas Marquez
Keywords: needs-qa
Depends on:
Reported: 2020-12-27 06:32 UTC by Timothy Beyer
Modified: 2021-08-05 07:00 UTC (History)
4 users (show)

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

audio_pd.diff (24.69 KB, patch)
2020-12-27 06:32 UTC, Timothy Beyer
koobs: maintainer-approval? (brittlehaus)
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

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]

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:

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]

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: