为什么java midi synth在mac上停止播放笔记 [英] Why java midi synth on mac stop playing notes

查看:128
本文介绍了为什么java midi synth在mac上停止播放笔记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的应用程序,从midi端口(硬件)读取并将事件转发到软件合成器。它主要起作用,只是软合成器不时停止播放。我可以在日志中看到midi消息被转发,我可以在调试中跟踪并看到事件到达合成器接收器中的本机代码但由于某种原因,合成器不播放音符。如果你等待然后声音再次播放,然后停止,然后再次播放...

I am trying to make a simple app that read from a midi port (hardware) and forward events to the software synth. It mostly work except that the soft synth stop playing from time to time. I can see midi messages being forwarded in the logs, I can trace in debug and see that the event reach the native code in the synth receiver but for some reason, the synth does not play the note. If you wait then the sound play again, then stop, then play again...

这是一个演示应用程序,显示问题。如果您在控制台中按住回车按钮,您将反复听到一个音符。一段时间后(可能不到一分钟),声音会停止(按下按钮时会发生声音),然后它会回来。

Here is a demo app that shows the problem. If you hold the enter button in the console, you will hear a note repeatedly. After some time (likely less than a minute), the sound will stop (event if you keep the button pressed), and then it will come back.

import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.sound.midi.MidiSystem;
import javax.sound.midi.Synthesizer;

public class TestMidi2 {

    public static void main( String[] args ) throws Exception {
        Synthesizer synth = MidiSystem.getSynthesizer();
        synth.open();

        BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
        boolean on = true;
        while ( in.readLine() != null ) {
            if ( on ) {
                synth.getChannels()[0].noteOn( 45, 127 );
            } else {
                synth.getChannels()[0].noteOff( 45 );
            }
            on = !on;
        }
    }

}

我是在MacOS X Lion上如果这有所不同(我猜它确实如此)。

I am on MacOS X lion if this make a difference (which I guess it does).

有什么想法吗?解决方法?我想尝试其他软件合成器,但找不到任何。我也愿意尝试硬件midi合成器,只要他们可以演奏基本的钢琴,长笛和吉他(我不需要任何专业,只是不错的声音)。

Any idea? Workaround? I would like to try other software synth but could not find any. I am also willing to try hardware midi synth as long as they can play basic piano, flute and guitar (I don't need anything pro, just decent sound).

谢谢!

推荐答案

这是一个狮子问题。我正在开发一种工具,它将MIDI发送到不同的端口并在许多平台上进行测试。 Java声音合成器适用于所有OS X - 除Lion之外的版本。似乎合成器的缓冲区溢出。在几个音符后它停止播放,如果我发送一个音符,它再次开始工作并再次停止,...

It's a Lion Problem. I'm developing a tool which sends MIDI to different ports and tested it on many platforms. Java Sound Synthesiser works well for all OS X - Versions except Lion. There it seems like the buffer of the Synthesiser overflows. After a few notes it stops playing, if I send a punch of notes it starts working again and stops again,..

然而,遗憾的是Java声音合成器是一个旧的似乎没有人支持它的事情。

However, sadly the Java Sound Synthesiser is an old thing where it seems nobody supports it any more.

除了将它发送到第三方音序器之外,有没有人知道通过Java播放MIDI Sounds的其他可能性?如果会有像另一个通用MIDI库那样的话会很好。

Does anyone know other possibilities to play MIDI Sounds via Java except sending it to an third party sequencer? Would be nice if there would be something like just another General MIDI Library.

谢谢和格力!

这篇关于为什么java midi synth在mac上停止播放笔记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆