자바코드 질문좀 드립니다.ㅠ.ㅠ
사라
import java.awt.*;
import javax.swing.*;
import javax.sound.midi.*;
import java.util.*;
import java.awt.event.*;
public class beatbox {
jpanel mainpanel;
arraylistjcheckbox checkboxlist;
sequencer sequencer;
sequence sequence;
track track;
jframe theframe;
string[] instrumentnames = {bass drum,closed hi-hat,open hi-hat,acoustic snare,crash cymbal,
hand clap,high tom,hi bongo,maracas,whistle,low conga,cowbell,vibraslap,low-mid tom,
high agogo,open hi conga};
int[] instruments = {35,42,46,38,49,39,50,60,70,72,64,56,58,47,67,62};
public static void main(string[] args){
new beatbox().buildgui();
}
public void buildgui(){
theframe = new jframe(cyber beatbox);
theframe.setdefaultcloseoperation(jframe.exit_on_close);
borderlayout layout = new borderlayout();
jpanel background = new jpanel(layout);
background.setborder(borderfactory.createemptyborder(10,10,10,10));
//비어있는 경계선을 사용하여 패널 둘레와 구성요소가 들어가는 자리 사이에 빈공간을 만들수 있습니다.
checkboxlist = new arraylistjcheckbox();
box buttonbox = new box(boxlayout.y_axis);
jbutton start = new jbutton(start);
start.addactionlistener(new mystartlistener());
buttonbox.add(start);
jbutton stop = new jbutton(stop);
stop.addactionlistener(new mystoplistener());
buttonbox.add(stop);
jbutton uptempo = new jbutton(tempo up);
uptempo.addactionlistener(new myuptempotlistener());
buttonbox.add(uptempo);
jbutton downtempo = new jbutton(tempo down);
downtempo.addactionlistener(new mydowntempolistener());
buttonbox.add(downtempo);
box namebox = new box(boxlayout.y_axis);
for(int i = 0; i 16; i++){
namebox.add(new label(instrumentnames[i]));
}
background.add(borderlayout.east,buttonbox);
background.add(borderlayout.west,namebox);
theframe.getcontentpane().add(background);
gridlayout grid = new gridlayout(16,16);
grid.setvgap(1);
grid.sethgap(2);
mainpanel = new jpanel(grid);
background.add(borderlayout.center,mainpanel);
for(int i = 0; i 256;i++){
jcheckbox c = new jcheckbox();
c.setselected(false);
checkboxlist.add(c);
mainpanel.add(c);
}
setupmidi();
theframe.setbounds(50,50,300,300);
theframe.pack();
theframe.setvisible(true);
}
public void setupmidi(){
try{
sequencer = midisystem.getsequencer();
sequencer.open();
sequence = new sequence(sequence.ppq,4);
track = sequence.createtrack();
sequencer.settempoinbpm(120);
}catch(exception e){e.printstacktrace();}
}
public void buildtrackandstart(){
int[] tracklist = null;
sequence.deletetrack(track);
track = sequence.createtrack();
for(int i = 0; i 16;i++){
tracklist = new int[16];
int key = instruments[i];
for(int j = 0; j 16; j++){
jcheckbox jc = (jcheckbox)checkboxlist.get(j + (16*i));
if(jc.isselected()){
tracklist[j] = key;
} else {
tracklist[j] = 0;
}
}
maketracks(tracklist);
track.add(makeevent(176,1,127,0,16));
}
track.add(makeevent(192,9,1,0,15));
try{
sequencer.setsequence(sequence);
sequencer.setloopcount(sequencer.loop_continuously);
sequencer.start();
sequencer.settempoinbpm(120);
}catch(exception e){e.printstacktrace();}
}//buildtrackandstrat 메소드끝
public class mystartlistener implements actionlistener{
public void actionperformed(actionevent a){
buildtrackandstart();
}
}
public class mystoplistener implements actionlistener{
public void actionperformed(actionevent a){
sequencer.stop();
}
}
public class myuptempotlistener implements actionlistener{
public void actionperformed(actionevent a){
float tempofactor = sequencer.gettempofactor();
sequencer.settempofactor((float)(tempofactor * 1.03));
}
}
public class mydowntempolistener implements actionlistener{
public void actionperformed(actionevent a){
float tempofactor = sequencer.gettempofactor();
sequencer.settempofactor((float)(tempofactor* .97));
}
}
public void maketracks(int[] list){
for (int i=0; i16; i++){
int key = list[i];
if(key != 0){
track.add(makeevent(144,9,key,100,i));
track.add(makeevent(128,9,key,100,i+1));
}}}
public midievent makeevent(int comd,int chan,int one,int two,int tick){
midievent event = null;
try{
shortmessage a = new shortmessage();
a.setmessage(comd,chan,one,two);
event = new midievent(a,tick);
}catch(exception e){e.printstacktrace();}
return event;
}
}
음악소리 실행하는 파일입니다. 빨간줄 친 midievent부분 이 좀 이해가 안갑니다. shortmessage()가 어떤역할을 하는지..
그리고 여기서 생성한 int comd,int chan,int one,int two,int tick 이변수들..어디에서 활용이 되는 건지 모르겠습니다.
답변해주시면 정말 감사합니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700452 | c언어에서... 자료형 구분.... (3) | 시내 | 2025-07-05 |
2700422 | 버전에 관해 질문 | 라온제나 | 2025-07-04 |
2700393 | mysql이 갑자기!!!!!!!!!!!!!!!에러가;; (2) | 소미 | 2025-07-04 |
2700359 | 3.0 ) SimpleButton 상태 강제 변경 (3) | 희선 | 2025-07-04 |
2700304 | ie8 전용핵 문의 (3) | 여자 | 2025-07-03 |
2700281 | 이런경우 어떻게 코딩해야 표준에 따르는건가요? (6) | 늘솜 | 2025-07-03 |
2700230 | 질문이여 ! | 뿡뿡몬 | 2025-07-03 |
2700205 | 액션스크립트책 좀 추천해주세요. (10) | 화이트캣 | 2025-07-02 |
2700173 | 자바 소스인데 어떤게 에러인지..? (1) | 호빵녀 | 2025-07-02 |
2700142 | 하단이 붙어있는 가변 레이아웃구조 질문드립니다. | 이플 | 2025-07-02 |
2700089 | 이미지를 사다리꼴로 비틀게 하는 액션코드가 있나요? (4) | 여름 | 2025-07-01 |
2700033 | 배경에 그라데이션을 넣으려고 하는데요.. (4) | 화이티 | 2025-07-01 |
2700005 | [질문] TextField 객체의 실제 높이 알아오는 방법 ? | 천사의눈물 | 2025-07-01 |
2699978 | FileReferenceList를 이용하여 업로드시 자꾸 실행속도가 느리다는 팝업이... (10) | 데이비드 | 2025-06-30 |
2699944 | 자바스크립트가 많은 사이트는... (6) | 희나리 | 2025-06-30 |
2699918 | 브라우저마다 다른 input과 텍스트 정렬 (3) | 늘봄 | 2025-06-30 |
2699887 | 동적텍스트를 그래픽으로?? (2) | 족장 | 2025-06-30 |
2699862 | scope넣기 (1) | 아인 | 2025-06-29 |
2699835 | exe로 만드는 방법을....알려주세요.. (5) | 방방 | 2025-06-29 |
2699809 | 롤오버할때 백그라운드 이미지로할때 alt설명은 어떻게해야하죠?..ㅠ (4) | 반혈 | 2025-06-29 |