简体   繁体   English

如何将Midi从Java程序发送到OSX上的IAC总线

[英]How to send midi from a java program to an IAC bus on OSX

I'm trying to write a program that will send MIDI messages to external synthesizers. 我正在尝试编写一个程序,该程序将MIDI消息发送到外部合成器。 It does work when using the default synth in Java (1.8 on a mac) and makes a nice ping sound every second when connected to the default synthesizer in Java. 在Java中使用默认的合成器(在Mac上为1.8)时,它确实可以工作,并且在连接至Java中的默认合成器时,每秒都能发出很好的ping声音。 As expected this is a boring sound, but it does verify that I'm able to make short midi sequences that are interpreted as sounds by a synth. 正如预期的那样,这是一种无聊的声音,但它确实验证了我是否能够制作出短的Midi序列,这些合成器将其解释为声音。

I then try to route that signal to an IAC device, so that it can be picked up by other programs (including synthesizers) that can make interesting sounds. 然后,我尝试将信号路由到IAC设备,以便可以被其他程序(包括合成器)拾取,从而发出有趣的声音。 However, it seems that none of the events I produce are actually picked up by the IAC device. 但是,似乎我产生的所有事件实际上都没有被IAC设备接收。 It doesn't seem like they are sent outside of the JVM, or if they are they are somehow dropped. 似乎它们不是在JVM之外发送的,或者如果它们是某种方式被丢弃的。

My question is simply: Has anyone done this, and can they tell me what they did? 我的问题很简单:有人做过吗,他们能告诉我他们做了什么吗?

In essence my code does this: 本质上,我的代码这样做:

final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < infos.length; i++) {
       final MidiDevice device = MidiSystem.getMidiDevice(infos[i]);

       final String  deviceInfo = device.getDeviceInfo().getName();

       // My IAC device is called "Bus 1"
       if ("Bus 1".equals(deviceInfo)) {

          Receiver rcvr = device.getReceiver()
          ShortMessage myMsg = new ShortMessage();
          // Start playing the note Middle C (60),
          // moderately loud (velocity = 93).
         myMsg.setMessage(ShortMessage.NOTE_ON, 0, 60, 93);
         rcvr.send(myMsg, timeStamp);
       }
  }

I the test this by connecting the IAC device to an MS-20 soft synth, no sounds are produced. 通过将IAC设备连接到MS-20软合成器进行测试,不会产生声音。 I then connect a "MockMidi" keyboard up to the "Bus 1" IAC device, and I can then play the MS-20 bus. 然后,我将“ MockMidi”键盘连接到“ Bus 1” IAC设备,然后可以播放MS-20总线。 I then try to hook the MockMidi keyboard up to the Bus 1 as an input device, but I don't see any events. 然后,我尝试将MockMidi键盘挂接到Bus 1作为输入设备,但没有看到任何事件。

Looks straightforward, but as far as I can tell, no midi messages are ever received at the IAC device when sent from Java, yet the mechanism seems to be working fine both inside java, and outside Java. 看起来很简单,但是据我所知,从Java发送时,IAC设备上从未收到过Midi消息,但是该机制在Java内部和Java外部似乎都可以正常工作。

I'm stuck, all help will be highly appreciated (and source code will be shared on github when it works (sending to IAC would count as working)). 我被困住了,所有帮助将受到高度赞赏(源代码在工作时将在github上共享(发送到IAC将视为工作))。 :-) :-)

The documentation for getReceiver() says: getReceiver()文档说:

Obtaining a Receiver with this method does not open the device. 使用此方法获取Receiver不会打开设备。 To be able to use the device, it has to be opened explicitly by calling open() . 为了能够使用该设备,必须通过调用open()显式open()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM