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
extend implementation of "midi.autoconnect" #414
Comments
I don't quite understand this "autoconnect" need. Please does anyone could explain anymore what is expected ? |
Pls. review PR #266 and let me know if this clarifies it.
|
Thanks, now it is clear. As far i know i dont think that "autoconnect" can be implemented for Windows (i mean without a dependency taking account of multiple MIDI input devices). |
Excuse me, I was wondering if you could clarify few things that are not clear to me.
|
The autoconnect feature only says that suitable MIDI devices should be automatically connected to. Whether this makes it necessary to maintain a list of devices or get a callback are details of the implementation. However, I currently don't see a need to keep that list up to date when autoconnect is disabled.
I'm not familiar with winmidi. The autoconnect feature originated from alsa, where fluidsynth connects to ports. Whenever a new port appears, fluidsynth gets a callback and connects to it. I hoped that smth. similar to this is available for winmidi as well. If not, the autoconnect feature could either be dropped for winmidi or, as compromise like you said, connect to every readable port that is available when fluidsynth starts up.
I think this treatment highly depends on the audio driver used. At least on windows, my experience is that the OS switches automatically to any plugged in speakers. |
I wanted to use the "midi.autoconnect" setting in Windows today, and was disappointed. Then, while looking at #677 it seemed to be easy to implement it in winmidi, but there is a hardcoded policy about mapping MIDI channels that didn't match well my own use case (but is probably useful for others). Then, I've realized that another setting: "synth.midi-channels" was not taken into account when implementing autoconnect (for instance in ALSA, Jack, CoreMIDI drivers) neither in #677. So let's look to the possible use cases first.
Both settings are not incompatible. You may imagine combining them in the use case 2, to avoid the manual connection of the multiple MIDI IN ports to the external controllers. But this is not implemented, for instance in alsa_seq only the last created MIDI IN port gets connected to everything. A windows user with #677 has something similar to the use case 2, but "synth.midi-channels" is ignored, even if he wants a maximum of 16 MIDI channels. What do you think? Am I understood? |
Sry, it's not quite clear to me what you're asking for or trying to achieve. So, all I can comment on are the two use-cases you described. UC1 is the one why midi.autoconnect was invented. But I don't see how UC2 can be compatible with autoconnect. As you said, the ports must be connect to the right controller by hand, and I'm skeptical that more magic to midi.autoconnect helps to circumvent that. Not sure, why synth.midi-channels is ignored by the winmidi driver. To me it seems like the driver is simply optimistic that the synth will not ignore the 17-32 channels: fluidsynth/src/drivers/fluid_winmidi.c Lines 148 to 165 in 015c6af
|
You are right. I've not made a proposal yet. But I have something in mind...
fluidsynth/src/drivers/fluid_winmidi.c Lines 516 to 522 in 015c6af
My proposal for the winmidi driver is to limit the maximum number of channels to the value provided in the setting "synth.midi-channels", and then if "midi.autoconnect" is requested, instead of parsing the value of "midi.winmidi.device", open all the suitable devices that are already enumerated here: fluidsynth/src/drivers/fluid_winmidi.c Lines 261 to 296 in 015c6af
The ALSA Sequencer driver creates already several ports when "synth.midi-channels" is specified. My proposal is to assign the channel mappings to each input port distributed incrementally (the first port to the channels 1-16, the second port to the channels 17-32, and so on). And If "midi.autoconnect" is also provided, subscribe sequentially each readable device to the available input ports (using a counter with return to zero). Something similar may be implemented in the CoreMIDI driver. |
Why not parsing winmidi.device? If the user takes the effort to set it, it should be respected. You could still connect to all readable devices if winmidi.device is the default value. The rest sounds good to me. |
Well, then "midi.autoconnect" is ignored when "midi.winmidi.device" value is not "default". The winmidi driver still needs to be updated to limit the number of MIDI channels to the same value used by the synthesizer. |
Ok |
Context: ticket FluidSynth#414 The alsa_seq driver creates multiple ports (N/16) for N="synth.midi-channels", each mapped to synth channels: port*16+channel. This is already implemented. When the "midi.autoconnect" is specified, instead of subscribing only the last created port, all ports are sequencially subscribed to each available external MIDI inputs. When the last port has been subscribed, the next subscription starts again from port 0.
Yes and no. Please some clarifications about #677: 1)The synth.midi-channels winmidi independence of #677 was an important design choice. This makes the MIDI driver straightforward and predictable for musician as it keeps MIDI channels intact without doing magic (and incomprehensible) MIDI channels mapping transformation. Accidental MIDI channels conflicts is impossible inside #677 winmidi driver. 2)with #677, having more than one MIDI controller and one synth instance with only 16 MIDI channels is still a valid use case. |
If i understand, that will break the initial #677 design. As said "midi.autoconnect" seems incompatibe with UC2. I think the correct way to add autoconnect in #677 is: if(midi-connect is set to "on" and "midi.winmidi.device" is set to "default") |
The synthesizer instance (the object that transforms MIDI events into audio) has only 16 MIDI channels by default. When you send MIDI events to the synth with a channel value above the maximum, the event has no effect on the synth, it produces no change on the sound. That is why the synth.midi-channels setting is important: because you can set another limit (with an absolute maximum of 256). When I've tried the following test in windows, it was quite clear for me that someting is wrong in the winmidi driver: This test needs the following Windows software:
First, disconnect any other MIDI device from the system, and configure LoopMIDI with more than 1 port, for instance 4 ports like this: Second, in Qsynth configure the winmidi driver to connect to all loopMIDI devices: Third, in VMPK connect the "Windows MM" MIDI output to the first LoopMIDI device: With your mouse, or your keyboard, you can trigger sounds in Qsynth using any MIDI channel. OK for now. Now change the connection to the second loopMIDI device: The events generated by VMPK now are ignored by Qsynth, because they are mapped to the MIDI channels 17-31, and the synth does not have those channels. To fix this situation you can change the settings in Qsynth like this, to set "synth.midi-channels" to 64 (for instance): Now, all loopMIDI devices can be connected in VMPK, and they always trigger sounds. Looking to the "channels" window in Qsynth, you can see the 64 channels (program setting and activity). What is my proposal?The winmidi driver first reads the "synth.midi-channels" setting, and uses it as a limit for the channels mapping value. For instance, when "synth.midi-channels" has the default value (16), there will be no mapping. All connected devices will send the received events to the synth using the same original MIDI channel. If the "synth.midi-channels" setting value is 32, then the first device won't have channel mapping, and the second will have a 17-32 mapping. The next device will have again a 1-16 channel mapping, the next will be 17-32 again, and so on. |
The usual use case of FluidSynth for a normal musician is to execute the command line client, "fluidsynth.exe" or a GUI client like Qsynth, and use these programs to produce sound from MIDI events. Right now, using any of these programs in windows, while connecting several input devices without changing the value of synth.midi-channels has the effect that some connected MIDI devices don't produce any sound at all. That is not acceptable, in my opinion. |
I understand what you explained so far Pedro, but having a magic MIDI channel mapping (modulo "synth.midi-channels") incorporated inside the MIDI driver could produce MIDI channels conflicts. In your example, when a musician plays a noteon on the device 1, this note could will be stopped by an other musician playing a note off on device 3. This is not acceptable as well, and the only way to avoid this issue is to augment "synth.midi-channels" which is workaround. My proposal can produce no sound from some device if the user don't augment "synth.midi-channels" or he doesn't set the MIDI channels mapping according to its needs. Note that the fluidsynth console application offers a router that allows the user to do MIDI channels mapping Your proposal can produce incomprehensible MIDI channels conflicts that can only be fixed by rising "synth.midi-channels". |
Your proposal is to avoid implementing midi.autoconnect at all in winmidi. What I am proposing is... Quoting myself:
And for this kind of user, that simply wants to have sound without worrying about connections, you can't seriously propose to muddle with the MIDI router! |
Please, note that my previous message is only relevant for auto-connect set to off. |
This issue is about extend implementation of "midi.autoconnect" |
No at all Pedro. Adding midi.autoconnect is a nice idea, please reread my previous message: if(midi-connect is set to "on" and "midi.winmidi.device" is set to "default") |
Implement "midi.autoconnect" for alsa_raw, jack and potentially other midi drivers.
The text was updated successfully, but these errors were encountered: