Java me 我无法更改JSR-135上的midi频道程序
我告诉他们我正在使用MIDlet,我无法更改任何乐器的midi通道。 我尝试了Java me 我无法更改JSR-135上的midi频道程序,java-me,midi,midlet,midi-instrument,midi-interface,Java Me,Midi,Midlet,Midi Instrument,Midi Interface,我告诉他们我正在使用MIDlet,我无法更改任何乐器的midi通道。 我尝试了.shortMidiEvent(0xC0+频道,程序,0)和设置程序(通道-1,程序)无结果。 在我的手机上有一个诺基亚X3-02,仪器更换不起作用,只有midlet的模拟器。 下面是代码片段 public final class Dmgcpu implements Runnable { private Player player; private static MIDIControl synth; private
.shortMidiEvent(0xC0+频道,程序,0)代码>和设置程序(通道-1,程序)
无结果。
在我的手机上有一个诺基亚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);
}
就是你可以更换乐器,据我所知,在这样的情况下,你可以使用一组播放器
。我试着不工作。
saludos媒体播放器对JavaME总是很棘手。某些设备要求您预取(),而如果您这样做,其他设备将崩溃。有些人喜欢实现,而有些人不喜欢。因此,最好将多个try/catch块与prefetch()和realize()等一起使用。
您的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);
}
}
有关媒体播放器的更多信息:
使用prefetch()时手机崩溃代码>