수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

자바코드 질문좀 드립니다.ㅠ.ㅠ

사라

2023.04.01

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 이변수들..어디에서 활용이 되는 건지 모르겠습니다.
답변해주시면 정말 감사합니다.

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2694611 Flash Lite 2.1에서 BitmapData와 Matrix 지원안하나요? (3) 이플 2025-05-12
2694582 IE & 파이어폭스 (2) 흙이랑 2025-05-12
2694553 무비클립안의 duplicate 발동이 안돼네요; 딥보라 2025-05-12
2694523 자바 애플릿 질문좀 ^^ (6) 동이 2025-05-12
2694494 [질문] JAVA 또는 C++ 로 프로그램 개발시.. 레지스터리 등록 관련 의문점? (3) 우람늘 2025-05-11
2694469 익스6에서 css버그 나오는것 해결방법좀요 !!!! (6) 원술 2025-05-11
2694442 로컬에선 잘 나오는데 운영에 반영하면 이상하게 나와요. (8) 목화 2025-05-11
2694412 [질문] 이미지 로딩후 사이즈 조절할때 (1) 아담 2025-05-11
2694391 설치형 블로그 쓰시는 분들 어떤거 쓰세요?? (7) AngelsTears 2025-05-10
2694362 Microsoft SQL Server에서 서버만드는법 어둠 2025-05-10
2694333 for문으로 돌린 이름의 제어 (4) 레이 2025-05-10
2694308 이미지 css 도와주세요 ㅠㅠ (2) 애기 2025-05-10
2694223 [급질문]스크롤스파이의 offset값 진나 2025-05-09
2694195 li에 이미지 넣고 세로로 메뉴 구성하는 경우 (1) 예님 2025-05-09
2694167 canvas 질문요. (4) 찬늘봄 2025-05-08
2694136 왜 이렇게 나오는지 이해가 잘 가지 않네요. 부탁드리겠습니다... (2) 세련 2025-05-08
2694111 div , css 공부하고있는데요 잘모르겠어요.. 도와주세요 ㅠ_ㅠ (10) 모람 2025-05-08
2694035 작업관리자 창에.. CPU사용 현황처럼 만들고 싶습니다. (1) 다올 2025-05-07
2694004 Linux에서 java사용 (2) 한빛 2025-05-07
2693978 CS5.5 베타 버젼이라도 다운받을 수 있는 사이트 아세요? (4) 콩순 2025-05-07
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com