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

feature request: several midi ports #1750

Open
tjingboem opened this issue Oct 2, 2023 · 11 comments
Open

feature request: several midi ports #1750

tjingboem opened this issue Oct 2, 2023 · 11 comments

Comments

@tjingboem
Copy link
Member

I have 4 physical midi ports ( 1x M-Audio and 3 Edirol UM). A DAW like Reaper has access to all of these ports, so i can send midi data to all of my synths easily.

Csound is lacking such a feature; only one midi out (or in) can be specified. This means re-cabling of my synths as well as only one port available for 16 midi channels. Not practical.

Since i am on Linux, I have tried working with the Jacko opcodes, but these are not transparent and i did not succeed in getting them to work. Also, Jack is (mostly) Linux only.

Some sort of midi detection system for Windows, Mac and Linux and all their different drivers, and the option to set more than one midi in/out from the command line would be something to have?
And if one instrument wants to send midi data to one port, and another instrument to a second midi port, an opcode making this possible could be part of this system. This opcode could be put in the instrument. Some sort of MidiPortAssign.

@tjingboem
Copy link
Member Author

tjingboem commented Oct 2, 2023

Addendum from Victor:
with portmidi you can. Each port is mapped to successivel groups of channels > 16.

From the manual

"With PortMIDI, DEVICE is either a number for single port input, 'a' for listening to all input ports, or 'm' for mapping ports to MIDI channels above 16. In this case, device 0 uses 1-16, device 1 uses 17-32, ... device N uses (N+1)*channel. The options 'a' and 'm' are also convenient when you don't have devices as they will not generate an error."

@vlazzarini
Copy link
Member

Multi-port midi in exists with portmidi.

Output needs to be looked. FWIW, midi output has never been implemented very completely and it has always been low priority.

@tjingboem
Copy link
Member Author

tjingboem commented Oct 2, 2023

yes i understand this issue is low priority- but still it is a priority although low. I think not many Csound users have been missing such a feature, but it happens to be on my path and stumble on it. (And i expected Csound to have this implemented.)

Narrowing my request:

  • PortMidi, being a multiplatform midi driver for Mac, Windows and Linux, to be multi-port (ins and outs).
    In the command line, something like -+rtmidi=PortMIDI -M 2 3 -Q 2 3 or -+rtmidi=PortMIDI -M 3 -M 2 -Q 2 -Q 3 would open 2 midi inputs and outputs, that is 2 and 3.
    This would make accessible for midi inputs and outputs (in my case) 1: M Audio Delta 1010 MIDI (PortMIDI) AND 2: UM-3 MIDI 1 (PortMIDI)
  • an opcode that assigns the particular instrument to a certain midi-port and channel, so that in one csd different instruments can send and receive midi data to different midi-ports

@vlazzarini
Copy link
Member

vlazzarini commented Oct 2, 2023

probably the way to go is to do like the inputs, map successive groups of channels > 16 to each port. It may be achievable.

@tjingboem
Copy link
Member Author

tjingboem commented Oct 2, 2023

I have success with playing 2 keyboards that are attached to different midi input ports. They both play the csd
I am using -+rtmidi=PortMIDI -M a to address all input ports.

<CsoundSynthesizer>
<CsOptions>
-+rtmidi=PortMIDI -M a --midi-velocity=p5 --midi-key=p4
</CsOptions>
<CsInstruments>
sr=48000
ksmps=128
nchnls=2
0dbfs=1

	instr 1	

icps  cpsmidi		; convert midi note to pitch
kenv  madsr   0.1, 0, 0.8, 0.3
asig  pluck   kenv*.15, icps, icps, 1, 1 ;low volume	 
      outs    asig, asig
      print icps
	endin

</CsInstruments>
<CsScore>
f 0 120		;stay active for 120 seconds
f 1 0 4096 10 1	;sine
e
</CsScore>
</CsoundSynthesizer>

Not sure how to use the m option in -+rtmidi=PortMIDI -M m??
When giving m whatever number, the keyboards still get through and notes are heard...
mmm, seems like -Mm flag & ctrl7 midi channels - out of range errors #1734

@tjingboem
Copy link
Member Author

I still think that Csound as a sound and music computing system should be able to drive several midiports and audioports at the same time. Programs like Reaper run on Msc, Windows and Linux and are able to do this (ASIO, Portmidi, Jack etc). So it is possible.
Isn't there existing GPL code that we could copypaste into Csound?

@vlazzarini
Copy link
Member

as far as I can remember -Mm was there before. It merges data from all ports.

We have multiport in, we can add multiport out. I don't think it will be difficult.

As far as multiple audio ports, my experience with reaper is that you can't (at least on Mac OS). You have to select the device. Using multiple ports is complicated because of clocking. I don't see this needs to be implemented in Csound.

@tjingboem
Copy link
Member Author

I'm running Linux and Jack, and i assumed that one can create as many midi and audio ports as one wanted in Reaper on all systems.

For example, I told Reaper and Jack to create 20 audio output ports. Catia shows this visually

Screenshot from 2023-11-05 15-22-27

For Midi, i can add a lot of Midi Ports as well:

Screenshot from 2023-11-05 15-17-05

@kunstmusik
Copy link
Member

Wondering if this couldn't be implemented outside of core in a plugin.

@vlazzarini
Copy link
Member

That looks like Jack not reaper. At least on mac, you can only open a single device. MacOs then allows for aggregate devices, but that's outside the audio software.

@kunstmusik yes that's basically implemented outside Csound in the pmidi plugin. The only thing we need from Csound is the possibility of accessing channels > 16, which we already have.

@tjingboem
Copy link
Member Author

That looks like Jack not reaper. At least on mac, you can only open a single device. MacOs then allows for aggregate devices, but that's outside the audio software.

i stopped Jack and still am able to run Reaper using ALSA and could send midi data to all midi ports (4) independently.
Screenshot from 2023-11-08 10-36-45

My feature request is that Csound can do the same.
In that case, i guess, an opcode from an instrument should assign which midi port it wants to send the midi data send to.

I was hoping that a robust and complete Midi system (+ sysex opcode + support for the upcoming Midi 2.0 https://www.korg.com/us/products/computergear/keystage/) could be considered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants