2013-05-28 12 views
0

MIDlet에서 작업 중이며 어떤 악기 MIDI 채널도 변경할 수 없다고 말합니다. .shortMidiEvent(0xC0 + channel, program, 0);setProgram(channel, -1, program)을 시도했지만 결과가 없습니다. 휴대 전화의 은 Nokia X3-02 기기 변경이 작동하지 않으며, Midlet의 에뮬레이터 만 작동합니다. 여기JSR-135에서 MIDI 채널 프로그램을 변경할 수 없습니다.

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의 배열을 사용하여 이해 한대로 기기를 변경할 수있는 코드 조각을이다. 나는 노력하고 일하지 않았다. saludos

답변

0

미디어 플레이어는 JavaME에서 항상 까다 롭습니다. 일부 기기에서는 프리 페치()를해야하지만 그렇지 않은 경우 다른 기기에서 충돌이 발생합니다. 어떤 사람들은 깨닫지 만() 다른 사람들은 깨닫지 못합니다. 따라서 prefetch() 및 realize() 등을 사용하여 여러 try/catch 블록을 사용하는 것이 가장 좋습니다. prefetch()로 인해 try 블록이 실패했을 수 있습니다. 그래서이 시도 :

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

+0

프리 페치()'와 전화 충돌;' – kapodamy