开发者

How do I send Midi events to Software Synth in C++

开发者 https://www.devze.com 2023-04-01 21:54 出处:网络
Hi looking for some advice. I am writing some music composition software. I have cobbled together tools to read write and send midi data, they work fine. However I stumped on the following: I\'m tryin

Hi looking for some advice. I am writing some music composition software. I have cobbled together tools to read write and send midi data, they work fine. However I stumped on the following: I'm trying to send midi events to a SW synthesizer on the computer.

So I can control the sw synth from an external keyboard. I can control the keyboard from my own sw in the computer. But how do I get my sw to send midi to the sw synth in the same computer.

Also I'm trying to do this in a platform independent way if possible.

Thanks!

VMan


My question wasn't clear.

So I'm currently running on Win7. Cross platform 开发者_如何学运维is a priority but not for the first prototype.

Specifically my problem is with accessing kontakt player (v2) it works within it's own environment and with midi IO. But I can't access it from within my own software.

midiOutGetNumDevs returns just one device and it's the Microsoft GS Wavetable Synth.

I'm confused that I can send midi to the kontakt player via a midi/usb cable but that it doesn't show up as a midi device.

What am I missing?

Thx


Which API/OS are you using? Which SoftSynth?

Short answer: you might try "PortMidi".

http://portmedia.sourceforge.net/

Long(er) answer:

I haven't found any cross-platform MIDI lib able to speak to any kind of MIDI sink. In fact it depends on what the softsynth use for receiving MIDI events.

1) On Linux, you can use ALSA to speak to the ALSA synths. A softsynth can register itself as an ALSA sink. You can either: * use the ALSA lib to connect to send MIDI events to this sink ; * or you can register your application as a ALSA MIDI source and use another program (aconnectgui, qjackctl, patchage) to connect it to any sink.

http://www.alsa-project.org/alsa-doc/alsa-lib/rawmidi.html

http://www.alsa-project.org/alsa-doc/alsa-lib/seq.html

Downside: Linux specific

2) You can use JACK for MIDI. As in ALSA MIDI, an application can register MIDI sources and sinks. Yhe softsynth can register as a JACK MIDI sink. Then you need to make you app a JACK MIDI source and connect them with another program (qjackctl, patchage).

http://jackaudio.org/files/docs/html/index.html

Downside: need installation, configuration, launching of JACK

You have two solutions to move the ALSA sink/sources as JACK sink/sources :

  • either use the built-in functionality of JACK (commandline -Xseq) ;

  • or using "a2jmidi"

4) On MacOS you can do MIDI with CoreAudio. I don't know anything about it though.

5) On windows, I guess you use the midi* functions in

6) Use OSS on some other OSes

7) Communicate with the synth using socket/protocols

You could make your software send MIDI events using MIDI/RTP or MIDI/UDP so you don't care about the driver/OS. Most softsynth don't speak any of those directly so you need a program to do the bridging (qmidinet or others).

8) PortMidi is a cross platform lib for MIDI. However it doesn't seem to be able to use JACK as a backend directly (you can however make the ALSA devices available in JACK as explained above).

http://portmedia.sourceforge.net/

For example, on Linux, Fluidsynth can use ALSA, OSS and JACK for MIDI input. Timidity++ can use ALSA and the Windows API.


OK the answer to this problem is to use a virtual midi driver. I found a free one here: http://nerds.de/en/loopbe1.html

This creates a midi output device that shows up with midiOutGetNumDevs that I can stream my midi notes too and other Midi software on the same computer can use it as a midi input device.

Works on Win7 and apprently also has mac support. My problem is solved.

"LoopBe1 is an internal MIDI device for transferring MIDI data between computer programs. Basically LoopBe1 is an "invisible cable" to connect a MIDI outport of an application to any other application´s MIDI inport."


Agreed that a Virtual MIDI Driver is the easiest solution.

Another one that used to be very popular (not sure how it performs on Win7 though) is MIDI Yoke. http://www.midiox.com/

If you are looking to do something commercial, you may consider writing your own virtual MIDI driver to make your software controller(sender) a virtual MIDI source. Only on Windows will this be a lot of work.

On Mac and Linux your job is much easier. As @ysdx said, Mac using CoreMIDI and Linux using ALSA/Jack, this is very easy to do in your application by creating a Virtual MIDI port and connecting to destinations.

0

精彩评论

暂无评论...
验证码 换一张
取 消