Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows native MIDI support #3431

Merged
merged 9 commits into from
Dec 6, 2024

Conversation

softins
Copy link
Member

@softins softins commented Nov 28, 2024

Short description of changes

Add native support for MIDI devices to the ASIO (non-Jack) build for Windows. This will allow users to use
a MIDI fader bank (such as the Korg nanoKontrol2) without having to set up the Jack version of Jamulus.

CHANGELOG: Client: Added native MIDI support to the ASIO (non-Jack) Windows build

Context: Fixes an issue?

Until now, only Mac CoreAudio and Jack (for Windows or Linux) had support for MIDI fader banks.

Does this change need documentation? What needs to be documented and how?

Yes. The web page detailing how to use a fader bank needs to mention that Windows users no longer need the Jack version
to get MIDI support. It also needs to describe the d option for --ctrlmidich.

Status of this Pull Request

Working and ready for testing.

What is missing until this pull request can be merged?

Need to consider how to support systems with more than one MIDI device. Either add an option to --ctrlmidich to
specify the Windows MIDI Input device number (defaults to 0), or else enumerate all connected MIDI devices
and listen to them all (I think the Mac version does the latter).

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@softins softins marked this pull request as draft November 28, 2024 17:15
@softins softins self-assigned this Nov 28, 2024
@softins softins added the Windows Windows runtime issue label Nov 28, 2024
@softins
Copy link
Member Author

softins commented Dec 1, 2024

Checked the original Mac version with multiple MIDI devices connected, and it does listen to them all. Updated this PR to do the same.

@softins softins marked this pull request as ready for review December 1, 2024 17:36
@softins softins requested review from pljones and ann0see December 1, 2024 17:38
src/sound/asio/sound.cpp Outdated Show resolved Hide resolved
src/sound/asio/sound.h Outdated Show resolved Hide resolved
@pljones
Copy link
Collaborator

pljones commented Dec 1, 2024

Would it be better not to put this in asio -- using MIDI with JACK isn't that nice, to be honest, and I'd take a better alternative if it were offered... (You don't get to configure which ports it opens, unlike it Reaper.)

So I'd like something like --winmidi available on both Jack and ASIO Windows builds that allowed specifying behaviour. On the JACK build, it would allow jack as an argument, to defer to the existing Jack implementation (which would be the default on that build). On both builds, it would allow list to list available port names (and exit, like --help or --version). Both builds would also take one (or more?) of these names, which would then be used to filter the available ports in this implementation (rather than greedily open all ports).

src/sound/asio/sound.cpp Outdated Show resolved Hide resolved
@softins
Copy link
Member Author

softins commented Dec 2, 2024

Would it be better not to put this in asio -- using MIDI with JACK isn't that nice, to be honest, and I'd take a better alternative if it were offered... (You don't get to configure which ports it opens, unlike it Reaper.)

I did wonder about that, but since the coreaudio and jack implementations of MIDI input were just part of CSound, I followed the same principle for the non-jack Windows port in the asio directory.

My focus and scope here was basically to fill the omission of MIDI support in the regular non-jack Windows build.

So I'd like something like --winmidi available on both Jack and ASIO Windows builds that allowed specifying behaviour. On the JACK build, it would allow jack as an argument, to defer to the existing Jack implementation (which would be the default on that build). On both builds, it would allow list to list available port names (and exit, like --help or --version). Both builds would also take one (or more?) of these names, which would then be used to filter the available ports in this implementation (rather than greedily open all ports).

These are all good ideas, but I would see them as a follow-up Issue/PR rather than holding up this one, as they do add quite a bit of complexity, which I'd like to defer or delegate!

@softins
Copy link
Member Author

softins commented Dec 4, 2024

@pljones please see the latest commits, which hopefully address most or all of your concerns.

  • Moved the MIDI code into a separate class and directory, so it could be reused in the future, such as for the Jack build.
  • Added output to list the found MIDI devices and their names (only happens when --ctrlmidich is specified).
  • Added a d option to --ctrlmidich to specify which MIDI device should be used, ignoring all the others. It takes a string argument that must match the devicename of the desired device. If the d option is not specified, then all found MIDI devices will be opened.
  • Removed the arbitrary limit on the number of MIDI devices, by using a QVector for the list of opened handles (only used for closing them again).

I found adding the d option above to be much more straightforward to implement than adding a completely new command-line option.

Here is the output from testing with different d options while two MIDI devices were connected:

C:\Users\Tony\Git\jamulus>jamulus-midi.bat

C:\Users\Tony\Git\jamulus>release\Jamulus --ctrlmidich "1;f0*8;p16*8;s32*8;m48*8"
- MIDI controller settings: 1;f0*8;p16*8;s32*8;m48*8
- allocated port number: 22134
- MIDI devices found: 2
  0: nanoKONTROL2
  1: Keystation Mini 32

C:\Users\Tony\Git\jamulus>jamulus-nano.bat

C:\Users\Tony\Git\jamulus>release\Jamulus --ctrlmidich "1;f0*8;p16*8;s32*8;m48*8;dnanoKONTROL2"
- MIDI controller settings: 1;f0*8;p16*8;s32*8;m48*8;dnanoKONTROL2
- allocated port number: 22134
- MIDI devices found: 2
  0: nanoKONTROL2
  1: Keystation Mini 32 (ignored)

C:\Users\Tony\Git\jamulus>jamulus-maudio.bat

C:\Users\Tony\Git\jamulus>release\Jamulus --ctrlmidich "1;f0*8;p16*8;s32*8;m48*8;dKeystation Mini 32"
- MIDI controller settings: 1;f0*8;p16*8;s32*8;m48*8;dKeystation Mini 32
- allocated port number: 22134
- MIDI devices found: 2
  0: nanoKONTROL2 (ignored)
  1: Keystation Mini 32

C:\Users\Tony\Git\jamulus>jamulus-other.bat

C:\Users\Tony\Git\jamulus>release\Jamulus --ctrlmidich "1;f0*8;p16*8;s32*8;m48*8;dSomething else"
- MIDI controller settings: 1;f0*8;p16*8;s32*8;m48*8;dSomething else
- allocated port number: 22134
- MIDI devices found: 2
  0: nanoKONTROL2 (ignored)
  1: Keystation Mini 32 (ignored)

@pljones
Copy link
Collaborator

pljones commented Dec 4, 2024

OK, that worked here. (ASIO build)

Jamulus.pro Outdated Show resolved Hide resolved
src/sound/midi-win/midi.cpp Outdated Show resolved Hide resolved
@softins softins requested a review from ann0see December 4, 2024 17:47
@softins softins added the needs documentation PRs requiring documentation changes or additions label Dec 4, 2024
@softins softins changed the title Added Windows native MIDI support Add Windows native MIDI support Dec 4, 2024
@pljones
Copy link
Collaborator

pljones commented Dec 4, 2024

Also checked starting Reaper first and on a populated server and it works as expected. I'll grab the Win-Jack build now (as I've not tested the controller bits in that properly, yet - should be just the same).

@pljones
Copy link
Collaborator

pljones commented Dec 4, 2024

Yep, that worked. Of course, it's a bit of a hunt to find the System MIDI In in QJackCtl -- sometimes they're labelled capture_X -- but sometimes it uses a port name it's got from somewhere...
image
(There's only one MIDI In on my AudioFire4, it's not listed the USB Ins, and I'm pretty sure you can't squeeze MIDI from the MS GS Synth...)
It's another reason I'd like not to use the -X WinMME on Jack ☹️... Separate change for that, though.

@pljones pljones added this to the Release 3.12.0 milestone Dec 4, 2024
@ann0see
Copy link
Member

ann0see commented Dec 4, 2024

I'll have a look in the next few days.

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't own a midi device, but it seems good.

@softins softins merged commit 3905234 into jamulussoftware:main Dec 6, 2024
13 of 15 checks passed
@softins softins deleted the windows-native-midi branch December 6, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation PRs requiring documentation changes or additions Windows Windows runtime issue
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants