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

MIDI assignments don't distinguish between different MIDI controllers #256

Closed
TimPietrusky opened this issue Oct 5, 2018 · 14 comments
Closed
Assignees
Labels
bug Something isn't working enhancement Feature requests

Comments

@TimPietrusky
Copy link
Member

When using more than one MIDI controller at the same time and both have the same note defined for one control, triggering one of them will result in triggering an "action" in modV.

Steps to reproduce

  • Add the Ball module into an layer
  • Add MIDI controller A & B via USB to your computer
  • Right click on the "activate module" checkbox in the layer view
  • Use MIDI controller A and press button A (with note 0)
  • Now use MIDI controller B and press button A (also with note 0)

-> The module gets activated even when the controller was not used to define the assignment.

@TimPietrusky TimPietrusky added bug Something isn't working enhancement Feature requests labels Oct 5, 2018
@2xAA
Copy link
Member

2xAA commented Oct 10, 2018

Yes, per-device mapping isn't currently supported.

Essentially there needs to be another key added to an assignment with the MIDI Device ID and then a check on the input event listener to see if it matches.

https://github.com/m-o-d-v/modV/tree/2.0/src/extra/midi-assignment

@TimPietrusky
Copy link
Member Author

TimPietrusky commented Oct 19, 2018

@2xAA Isn't the device ID system specific? So when I use the device on another computer, the ID will change? Which would mean that moving configs to another computer wouldn't work anymore.

Need to test this.

@TimPietrusky TimPietrusky reopened this Oct 19, 2018
@2xAA
Copy link
Member

2xAA commented Oct 19, 2018

@TimPietrusky The spec doesn't mention. It should be unique and specific to the device and port.

https://webaudio.github.io/web-midi-api/#MIDIPort

@2xAA
Copy link
Member

2xAA commented Oct 19, 2018

If testing discovers the ID to be non-unique per system then a dialog/modal should be presented to the user to select a new MIDI device to map to.

The MIDI plugin is rather dumb as it will just accept any data as long as it's in the correct format. Currently there are no checks on present MIDI devices.

@TimPietrusky
Copy link
Member Author

According to WebAudio/web-midi-api#48 the ID for the same device on the same origin might change if the underlying storage is cleared, so it might also happen that the ID is changing even when you are not changing origins.

Especially this one: WebAudio/web-midi-api#48 (comment)

I think I was encountering something like this in the past when you added MIDI support in the first place. But we didn't looked into it.

One way of handling this in luminave is that I only check for the name of the specific MIDI Input / Output, but that would mean that we can't have the same MIDI controller more than once.

@TimPietrusky
Copy link
Member Author

TimPietrusky commented Oct 20, 2018

Test

Setup

  • Generated a preset on MacOS using Chrome 70
  • Added two different MIDI controllers
  • Assigned a button to enable a module for each controller

Test on Windows 10

  • Loading the preset generated for MacOS is working, but the MIDI assignments not
  • I created a new preset and added the same MIDI controllers as above
  • Assigned a button to enable a module for each controller

Result

I was using the same MIDI controller.

The ID on Windows looks like this:

{
  "deviceId": "input-1",
  "variable": "Ball,enable,internal",
  "value": null
}

On MacOS, it looks like this:

{
  "deviceId": "138192998391",
  "variable": "Ball,enable,internal",
  "value": null
}

@2xAA
Copy link
Member

2xAA commented Oct 20, 2018

One way of handling this in luminave is that I only check for the name of the specific MIDI Input / Output, but that would mean that we can't have the same MIDI controller more than once.

Well this is less than ideal - thanks for confirming.

Maybe we go with the Modal idea?

If [...] the ID [is] non-unique per system then a dialog/modal should be presented to the user to select a new MIDI device to map to.

To make this easier for the user we can store the device name with the assignment data and present that when re-mapping devices.

@TimPietrusky
Copy link
Member Author

TimPietrusky commented Oct 20, 2018

Still the question what we use to identify a device! We should try the SysEx thing mentioned by @halfbyte in the LiveJS slack:

One thing that may work: many MIDI devices respond to a “universal device inquiry” SysEx, giving you the manufacturer and device ids. But: for that you need SysEx privileges, which is something you may not want, probably.

Or just use the name of the controller itself as a workaround to have cross origin capabilities.

Device Name. Now, these still vary very much between different OSs, but at least that’s internally consistent.

We have to test if installing the driver for a specific system is telling the OS to use the same Name for the same controller.

@TimPietrusky
Copy link
Member Author

TimPietrusky commented Oct 21, 2018

To make this easier for the user we can store the device name with the assignment data and present that when re-mapping devices.

Totally forgot to read this... So you mean that when we load a preset and if we can't find the MIDI device in the assignments (in we can't find the device name), then we ask the user to select a device? Because if we do this all the time then the user might go nuts.

Maybe the modal should be on user action? So that the user goes into the MIDI assignments plugin and triggers the modal if they think it's wrong?

@2xAA
Copy link
Member

2xAA commented Oct 21, 2018

MIDI devices per system seem to keep their IDs, even on Windows - so this as a short term solution is viable.

Moving these assignments between systems is broken however.

Or just use the name of the controller itself as a workaround to have cross origin capabilities.

This limits the user to only one of the same controller, it's not robust enough.

“universal device inquiry” SysEx

This isn't guaranteed to work with all devices still though, probably good enough for our needs but if somebody has a custom device or just a device which doesn't support this SysEx message then it's not gonna work.

So you mean that when we load a preset and if we can't find the MIDI device in the assignments (in we can't find the device name), then we ask the user to select a device? Because if we do this all the time then the user might go nuts.

Well that's only if the MIDI device isn't present based on the name which I think wouldn't be that often if the user specifically made that preset - but I can imagine scenarios where that would be fairly annoying.

Maybe the modal should be on user action? So that the user goes into the MIDI assignments plugin and triggers the modal if they think it's wrong?

Yes this seems to fit the needs better. I think an alternate solution would be to re-design the MIDI plugin panel in the "Plugins" tab to allow the user to manage the assignments manually - this mechanism doesn't need to be exactly just for this "missing device" scenario but could be a general assignment panel for the user to manage assignments at any point.

This is a little more work, but it would add a lot of flexibility.

I feel this functionality should be moved into a new issue.

@TimPietrusky
Copy link
Member Author

This limits the user to only one of the same controller, it's not robust enough.

According to @halfbyte the OS is incrementing the device name if you add more than one. I don't have any device to test this behaviour. But even if that would be the case, it would be worth than using the ID.

re-design the MIDI plugin panel in the "Plugins" tab to allow the user to manage the assignments manually

You mean having the assignments per ID, so that we don't have to change this for every assignment? I would go with this idea.

I feel this functionality should be moved into a new issue.

Yes, I will move this into a new issue.

@TimPietrusky
Copy link
Member Author

Maybe we should even allow adding multiple IDs to a group of assignments! That way you can move the same preset between different origins and it always works!

@TimPietrusky
Copy link
Member Author

This ticket is done, because the new things around MIDI will be done in #296

@TimPietrusky
Copy link
Member Author

@2xAA Can you please check #296 if it's complete or is there still something missing to overcome the problems of this ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Feature requests
Projects
None yet
Development

No branches or pull requests

2 participants