@@ -34,32 +34,20 @@ function preload() {
3434 for ( var i = 0 ; i < 3 ; i ++ ) {
3535 octaveImg [ i ] = loadImage ( `pianoImg/green${ i } .png` ) ;
3636 }
37- // 버튼들..
38- // play
39- // playImg = loadImage(`buttons/play.png`);
40- // stop
41- // stopImg = loadImage(`buttons/stop.png`);
42- // reset
43- // resetImg = loadImage("buttons/reset.png");
4437 // volume
4538 volumeImg = loadImage ( "buttons/volume.png" ) ;
4639 // bpm
4740 bpmImg = loadImage ( "buttons/bpm.png" ) ;
48- // download
49- // downloadImg = loadImage("buttons/download.png");
50- // changeMainMode - piano
51- // for (var i = 0; i < 2; i++) pianoButtonImg[i] = loadImage(`buttons/piano${i}.png`);
52- // for (var i = 0; i < 2; i++) effectButtonImg[i] = loadImage(`buttons/effect${i}.png`);
5341}
5442
5543function setup ( ) {
5644 createCanvas ( windowWidth , windowHeight ) ;
5745 background ( 220 ) ;
5846 drawPiano ( ) ;
59- f_keyboardImg ( )
47+ f_keyboardImg ( ) ;
6048 reset ( ) ;
6149
62- resetButton = createImg ( "buttons/reset.png" , "" ) ;
50+ resetButton = createImg ( "buttons/reset.png" , "" ) ;
6351 resetButton . size ( width * 0.1 , height * 0.06 ) ;
6452 resetButton . position ( width * 0.87 , height * 0.58 ) ;
6553 resetButton . mousePressed ( reset ) ;
@@ -82,21 +70,27 @@ function setup() {
8270 } ) ;
8371
8472 pianoButton = createImg ( "buttons/piano1.png" , "" ) ;
85- pianoButton . size ( width * 0.1 , height * 0.06 ) ;
73+ pianoButton . size ( width * 0.1 , height * 0.065 ) ;
8674 pianoButton . position ( width * 0.03 , height * 0.57 ) ;
8775 pianoButton . mousePressed ( function ( ) {
88- soundPlay ( mainMode = true ) ;
89- buttonChange ( change = true ) ;
76+ soundPlay ( ( mainMode = true ) ) ;
77+ buttonChange ( ( change = true ) ) ;
9078 f_keyboardImg ( ) ;
9179 } ) ;
9280 effectButton = createImg ( "buttons/effect0.png" , "" ) ;
93- effectButton . size ( width * 0.18 , height * 0.06 ) ;
81+ effectButton . size ( width * 0.18 , height * 0.065 ) ;
9482 effectButton . position ( width * 0.15 , height * 0.57 ) ;
9583 effectButton . mousePressed ( function ( ) {
96- soundPlay ( mainMode = false ) ;
97- buttonChange ( change = false ) ;
84+ soundPlay ( ( mainMode = false ) ) ;
85+ buttonChange ( ( change = false ) ) ;
9886 f_keyboardImg ( ) ;
9987 } ) ;
88+
89+ // 다운로드 버튼 추가
90+ downloadButton = createImg ( "buttons/download.png" , "" ) ;
91+ downloadButton . size ( width * 0.15 , height * 0.06 ) ;
92+ downloadButton . position ( width * 0.058 , height * 0.1 ) ;
93+ downloadButton . mousePressed ( download ) ;
10094}
10195
10296function draw ( ) { }
@@ -336,6 +330,9 @@ function reset() {
336330 musicDataTime . splice ( 0 , musicDataTime . length ) ;
337331}
338332
333+ // 다운로드 함수
334+ function download ( ) { }
335+
339336function f_musicDataIconImg ( ) {
340337 if ( mainMode == true ) {
341338 image (
@@ -356,27 +353,27 @@ function f_musicDataIconImg() {
356353 }
357354}
358355
359- function playButtonChange ( ) {
360- if ( playing == true ) {
361- musicPlayButton . attribute ( ' src' , ' buttons/stop.png' ) ;
362- } else {
363- musicPlayButton . attribute ( ' src' , ' buttons/play.png' ) ;
356+ function playButtonChange ( ) {
357+ if ( playing == true ) {
358+ musicPlayButton . attribute ( " src" , " buttons/stop.png" ) ;
359+ } else {
360+ musicPlayButton . attribute ( " src" , " buttons/play.png" ) ;
364361 }
365362}
366363
367364function musicPlay ( ) {
368- if ( playing == false ) {
365+ if ( playing == false ) {
369366 playing = true ;
370367 playButtonChange ( ) ;
371368 delay = 0 ;
372369 recorder = new p5 . SoundRecorder ( ) ;
373370 // 여기에 아무것도 안넣어서 오류뜸
374371 recorder . setInput ( ) ;
372+
375373 soundFile = new p5 . SoundFile ( ) ;
376-
374+
377375 recorder . record ( soundFile ) ;
378-
379-
376+
380377 for ( let i = 0 ; i < musicData . length ; i ++ ) {
381378 sounds [ musicData [ i ] ] . amp ( volumeSlider . value ( ) ) ;
382379 sounds [ musicData [ i ] ] . play ( delay ) ;
@@ -390,7 +387,7 @@ function musicPlay() {
390387 // playing = false;
391388 // playButtonChange();
392389 // }
393- } else {
390+ } else {
394391 playing = false ;
395392 playButtonChange ( ) ;
396393 recorder . stop ( ) ;
@@ -400,25 +397,37 @@ function musicPlay() {
400397 }
401398}
402399
403- function buttonChange ( ) {
400+ function buttonChange ( ) {
404401 drawPiano ( ) ;
405- if ( change == true ) {
406- pianoButton . attribute ( ' src' , ' buttons/piano1.png' ) ;
407- effectButton . attribute ( ' src' , ' buttons/effect0.png' ) ;
402+ if ( change == true ) {
403+ pianoButton . attribute ( " src" , " buttons/piano1.png" ) ;
404+ effectButton . attribute ( " src" , " buttons/effect0.png" ) ;
408405 } else {
409- pianoButton . attribute ( ' src' , ' buttons/piano0.png' ) ;
410- effectButton . attribute ( ' src' , ' buttons/effect1.png' ) ;
406+ pianoButton . attribute ( " src" , " buttons/piano0.png" ) ;
407+ effectButton . attribute ( " src" , " buttons/effect1.png" ) ;
411408 }
412409}
413410
414- function f_keyboardImg ( ) {
415- if ( change == true ) {
416- for ( var i = 0 ; i < octaveImg . length ; i ++ ) {
417- image ( octaveImg [ i ] , i * ( width / octaveImg . length ) + 7 , height - height / 8 , width / 26 , height / 20 ) ;
411+ function f_keyboardImg ( ) {
412+ if ( change == true ) {
413+ for ( var i = 0 ; i < octaveImg . length ; i ++ ) {
414+ image (
415+ octaveImg [ i ] ,
416+ i * ( width / octaveImg . length ) + 7 ,
417+ height - height / 8 ,
418+ width / 26 ,
419+ height / 14
420+ ) ;
418421 }
419422 } else {
420- for ( var i = 0 ; i < keyboardImg . length ; i ++ ) {
421- image ( keyboardImg [ i ] , i * ( width / keyboardImg . length ) + 7 , height - height / 8 , width / 26 , height / 20 )
423+ for ( var i = 0 ; i < keyboardImg . length ; i ++ ) {
424+ image (
425+ keyboardImg [ i ] ,
426+ i * ( width / keyboardImg . length ) + 7 ,
427+ height - height / 8 ,
428+ width / 28 ,
429+ height / 15
430+ ) ;
422431 }
423432 }
424- }
433+ }
0 commit comments