【问题标题】:I can not change the midi channel program on JSR-135我无法更改 JSR-135 上的 MIDI 频道程序
【发布时间】:2013-05-28 01:27:29
【问题描述】:

我告诉他们我正在使用 MIDlet,但我无法更改任何乐器的 midi 通道。 我尝试使用.shortMidiEvent(0xC0 + channel, program, 0);setProgram(channel, -1, program) 没有结果。 在我的手机上是诺基亚X3-02 仪器换了不行,只有midlet 的模拟器。 这是代码片段

public final class Dmgcpu implements Runnable {
private Player player;
private static MIDIControl synth;

private void initSound() {
    try {

        player = Manager.createPlayer(Manager.MIDI_DEVICE_LOCATOR);
        player.prefetch();
        synth = (MIDIControl) player.getControl("javax.microedition.media.control.MIDIControl");
    } catch (Exception ex) {
    }

    synth.setProgram(0, -1, instSound_a);
    //synth.shortMidiEvent(0xC0, instSound_a, 0);

   //sound test
   synth.shortMidiEvent(0x90 + channel, note[i], volume * MASTER_VOLUME);

   thread_sleep(300);

   synth.shortMidiEvent(0x80 + channel, note[i], 0);

}

是您可以更改仪器,据我了解,您在此类情况下使用player 数组。我尝试并没有奏效。 祝你好运

【问题讨论】:

    标签: java-me midi midlet midi-instrument midi-interface


    【解决方案1】:

    媒体播放器对于 JavaME 来说总是很棘手。有些设备需要你 prefetch() ,而如果你这样做,其他设备会崩溃。有些人喜欢realize(),而另一些人则不喜欢。所以最好使用多个 try/catch 块与 prefetch() 和 implementation() 等。 您的 try 块可能由于 prefetch() 而失败。所以试试这个:

    public final class Dmgcpu implements Runnable {
    private Player player = null;
    private static MIDIControl synth = null;
    
    private void initSound() {
      try {
        player = Manager.createPlayer(Manager.MIDI_DEVICE_LOCATOR);
      } catch (Exception e) {}
      try {
        player.realize();
      } catch (Exception e) {}
      try {
        player.prefetch();
      } catch (Exception e) {}
      try {
        synth = (MIDIControl) player.getControl("javax.microedition.media.control.MIDIControl");
      } catch (Exception ex) {}
    
        if (synth!=null) {
        synth.setProgram(0, -1, instSound_a);
    
        //synth.shortMidiEvent(0xC0, instSound_a, 0);
    
        //sound test
        synth.shortMidiEvent(0x90 + channel, note[i], volume * MASTER_VOLUME);
    
        thread_sleep(300);
    
        synth.shortMidiEvent(0x80 + channel, note[i], 0);
      }
    }
    

    有关媒体播放器的更多信息: http://indiegamemusic.com/help.php?id=1

    【讨论】:

    • prefetch();手机崩溃
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 2016-04-05
    • 1970-01-01
    • 2019-11-30
    • 1970-01-01
    相关资源
    最近更新 更多