如何将 Java MIDI 与其他应用程序连接

发布于 2024-12-18 04:04:17 字数 1414 浏览 6 评论 0原文

您好,我正在 Windows 上进行 Java 编程,对于使用 MIDI 接口非常陌生。

我已经设法让java通过Synthesizer对象播放midi声音,本机通过计算机扬声器,但是我希望将midi消息即时发送到一个单独的合成应用程序,即FLStudio。我想我必须让java界面看起来像一个硬件midi设备,但我不知道如何做到这一点。我还认为这可能与发射器或 MidiDevice 有关,但我不确定。

有谁知道我将如何开始做这件事。我已经在谷歌上搜索过这个问题,但总是得到相同的两个文档,

http://www.jsresources .org/faq_midi.htmlhttp://www.ibm.com/developerworks/library/it/it- 0801art38/

抱歉,如果以前有人问过这个问题,但我找不到它。

这是我到目前为止所拥有的。任何帮助将不胜感激。

import javax.sound.midi.*;

public class Midi
{
    public static final void main(String args[]) throws Exception
    {
        //create and open synthesizer
        Synthesizer syn = MidiSystem.getSynthesizer();
        syn.open();

        //open midi channels (we'll use channel 5)
        final MidiChannel[] mc = syn.getChannels();

        //set instruments
        Instrument[] instr = syn.getDefaultSoundbank().getInstruments();

        //Possible ways to send midi to FLStudio, rather than inbuilt
        //javax.sound.midi.Transmitter?
        //javax.sound.midi.MidiDevice?

        // change instrument, using midi codes
        mc[5].programChange(instr[0].getPatch().getProgram());

        // Play note
        mc[5].noteOn(50,1000); //(noteNumber, velocity)
    }
}

Hi I am programming Java on Windows and am very new to working with MIDI interfaces.

I have managed to get java to play midi sounds through Synthesizer objects, natively through the computers speaker however I wish to send midi messages on the fly to a separate synthesis application, namely FLStudio. I think I have to make the java interface look like a hardware midi device but I have no idea how to do this. I also think it may have something to do with Transmitter or MidiDevice but i'm not sure.

Does anyone know how I would begin to go about this. I have looked all over Google about this but always end up at the same 2 documents,

http://www.jsresources.org/faq_midi.html
and
http://www.ibm.com/developerworks/library/it/it-0801art38/

Sorry if this question has been asked before but i couldn't find it.

Here's what I have so far. Any help would be greatly appreciated.

import javax.sound.midi.*;

public class Midi
{
    public static final void main(String args[]) throws Exception
    {
        //create and open synthesizer
        Synthesizer syn = MidiSystem.getSynthesizer();
        syn.open();

        //open midi channels (we'll use channel 5)
        final MidiChannel[] mc = syn.getChannels();

        //set instruments
        Instrument[] instr = syn.getDefaultSoundbank().getInstruments();

        //Possible ways to send midi to FLStudio, rather than inbuilt
        //javax.sound.midi.Transmitter?
        //javax.sound.midi.MidiDevice?

        // change instrument, using midi codes
        mc[5].programChange(instr[0].getPatch().getProgram());

        // Play note
        mc[5].noteOn(50,1000); //(noteNumber, velocity)
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2024-12-25 04:04:17

您可以使用 MidiOx 之类的程序来创建一个可以向其发送 MIDI 消息的虚拟 MIDI 端点。然后,在您的音序器中,您只需告诉它接受来自该设备输出的 MIDI 消息,您就可以将其用作直通管道。

You can use a program like MidiOx to create a virtual MIDI endpoint which you can send MIDI messages to. Then, in your sequencer, you just tell it to accept MIDI messages from the output of that device, and you can use it as a passthru pipe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文