2012-12-06 2 views
1

나는 미디 넘버, 듀레이션, 그리고 벨로 시티가있는 몇 개의 노트를 가지고있다. 나는 현재 음을 연주하는 신디사이저를 사용하고간단한 MIDI 파일을 출력하는 가장 간단한 방법은 무엇입니까?

:

Synthesizer synthesizer = MidiSystem.getSynthesizer(); 
synthesizer.open(); 

MidiChannel[] channels = synthesizer.getChannels(); 

for(Note n: song) 
{ 
    n.playNote(channels[0]); 
} 

synthesizer.close(); 

Note.playNote()

public void playNote(MidiChannel c) throws InterruptedException 
{ 
    if (type == 'n') 
    c.noteOn(noteNumber, 60); 
    Thread.sleep(getLength()); 
    if (type == 'n') 
    c.noteOff(noteNumber); 
} 

그러나, 지금은 미디 파일이 저장하고 싶습니다. 이 작업을 수행하는 가장 간단한 방법은 무엇입니까? 다음과 같이

+2

http://www.automatic-pilot.com/midifile.html 이 도움이 될 수 있습니다. – diegoperini

답변

2

하나 개의 간단한 절차는 본질적으로 :

  • 는 시퀀스 객체를 생성;
  • 하나 개 이상의 트랙을 만들 (sequence.createTrack을()) 각 주에 대한
  • ,
  • 전화 MidiSystem.write을 (에 메모를 나타내는 관련 MidiMessages를 만들고 메시지를 기록하고 트랙에 추가)를 쓰기 populated 시퀀스 파일.
관련 문제