//기미녕이 한부분 private void Form1_KeyPress_1(object sender, KeyPressEventArgs e) { if (!tb_name[0].Enabled && POctl.checkingMaxNode() && e.KeyChar.ToString() != "\0") // "제목입력" 상태의 버튼일 경우 { try { if (e.KeyChar == (char)13) { return; } string input = e.KeyChar.ToString().ToUpper(); keyntValue key = (keyntValue)Enum.Parse(typeof(keyntValue), input); ntValue notevalue = key.keyTontValue(); POctl.note_location(notevalue, p_music[POctl.now_music.smind]); POctl.note_locationInMadi(notevalue, p_madi[POctl.now_music.smind]); POctl.note_sound(POctl.ocIndex, (int)notevalue); } catch (Exception err) { MessageBox.Show("해당키만 누르시오!" + err.Message); } e.KeyChar = '\0'; } }
private void trainningForm_KeyPress(object sender, KeyPressEventArgs e) { if (isNoSelectedMusic() && e.KeyChar.ToString() != "\0") { try { string input = e.KeyChar.ToString().ToUpper(); keyntValue key = (keyntValue)Enum.Parse(typeof(keyntValue), input); ntValue notevalue = key.keyTontValue(); ntkrValue notename = key.keyTontkrValue(); lb_note.Text = notename.ToString(); if (trainningmode(notevalue, POtrCtr.ocIndex, POtrCtr.basicIndex) == true) { POtrCtr.note_location(notevalue, p_trmusic); POtrCtr.note_sound(POtrCtr.ocIndex, (int)notevalue); } } catch (Exception err) { MessageBox.Show("해당키만 누르시오!" + err.Message); } e.KeyChar = '\0'; } }
public bool trainningmode(ntValue nt, int ocIndex, int tempo) { //2017-01-17 김민영 //순서가 맞지않는 경우란 없다 원래 카운트 부분 수정 int crr = trainningindex; if (crr == allindex) { lb_test.Text = "연습이 완료되었습니다!"; return(false); } //MessageBox.Show(trScore[trainningindex].note.ToString()); if (nt.ToString() != trScore[crr].note.ToString()) { lb_test.Text = "음계가 일치하지 않습니다!"; return(false); } //음계가 일치하지 않을 시 종료 if (ocIndex != trScore[crr].octave) { lb_test.Text = "옥타브가 일치하지 않습니다."; return(false); } //옥타브가 일치하지 않을 시 종료*/ if (tempo != trScore[crr].length - 8) { lb_test.Text = "박자가 일치하지 않습니다."; return(false); } //박자가 일치하지 않을 시 종료*/ lb_test.Text = "맞았습니다!"; trainningindex++; return(true); }
public void save(string title, music musicSheet, Panel[] p_music) { string text = ""; text += "[" + title + "]"; for (int i = 0; i <= musicSheet.max_smind; i++) { text += "{"; for (int j = 0; j < musicSheet.sm[i].note_arr.Length; j++) { try { ntValue note = musicSheet.sm[i].note_arr[j].nt; int octave = musicSheet.sm[i].note_arr[j].ocIndex; int length = musicSheet.sm[i].note_arr[j].length; text += "<" + note.ToString() + "," + octave.ToString() + "," + length.ToString() + ">"; } catch { continue; } } text += "}"; } text += "e"; if (text != "e") { SaveFileDialog(text, title, p_music, musicSheet.max_smind); } else { MessageBox.Show("악보를 제작한 후 저장해보세요!"); } }
//################################################## /* ★ 시리얼 포트 값 읽어서 비교한다*/ private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { SerialPort sp = sender as SerialPort; if (sp.BytesToRead >= 0 && POctl.checkingMaxNode()) { byte[] buffer = new byte[2]; int count = sp.Read(buffer, 0, 2); string num = Encoding.ASCII.GetString(buffer); try { // 2016.01.24 정유진 -> 다중 음 낼때 이용 numCheck(int num); /* * 2016.01.17 김민영 아두이노의 입력에 따라 캐스팅되도록 수정 * 참고 인덱스형식으로 매칭하여 받으므로 샵처리를 A B C가 아닌 9,10,11 이런식으로 변환해주세용 * */ ntValue notevalue = (ntValue)Enum.ToObject(typeof(ntValue), int.Parse(num) - 1);//계이름 판정 /* 조이스틱으로 조절하는 부분 * switch(){ * case : * // Invoke(this.delegatenote_octavedown, new object[] {}); // 옥타브올리기 * // Invoke(this.delegatenote_octaveup, new object[] {}); // 옥타브내리기 * // Invoke(this.delegatenote_basicdown, new object[] {}); // 박자 올리기 * // Invoke(this.delegatenote_basicup, new object[] {}); // 박자 내리기 * } */ Invoke(this.delegatenote_location, new object[] { notevalue, p_music[POctl.now_music.smind] }); //음표그리기 Invoke(this.delegatenote_locationMadi, new object[] { notevalue, p_madi[POctl.now_music.smind] }); //마디음표그리기 Invoke(this.delegatenote_sound, new object[] { POctl.ocIndex, (int)notevalue }); //소리 출력하기 // textBox1.Text = num; //Invoke(this.delegate_trainning,new object[] { notevalue, POctl.ocIndex}); } catch { } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//##################### 임유진 ########################### //음표 마디에 그리기 public void note_locationInMadi(ntValue nt, Panel panel) { int y = nt.getLocationMadi(); int _y = 0; if (now_music.sm[now_music.smind].count_madi >= 7) { panel.Controls.Clear(); panel.BackgroundImage = Properties.Resources.emptymadi; now_music.sm[now_music.smind]._x_madi = 15; now_music.sm[now_music.smind].count_madi = 0; } // System.Drawing.Image[] tempo = basic[basicIndex,0]; _y = octave_madi[ocIndex]; //높은 시,도 거꾸로 된 음표 그리기 //20160126 정유진 샾 추가 //높은 시,도 거꾸로 된 음표 그리기 if ((ocIndex == 1 && (y == -27 || y == -41)) || ocIndex == 0) //옥타브==1 && 시or도 { if (nt == ntValue.SA || nt == ntValue.SD || nt == ntValue.SG || nt == ntValue.SF || nt == ntValue.SC) { panel.Controls.Add(note_drawingInMadi(now_music.sm[now_music.smind]._x_madi, _y + y + 50, basic[basicIndex, 3])); } else { panel.Controls.Add(note_drawingInMadi(now_music.sm[now_music.smind]._x_madi, _y + y + 50, basic[basicIndex, 1])); } //y축 위치 + 15(거꾸로 이므로 위치 맞춤) } else { if (nt == ntValue.SA || nt == ntValue.SD || nt == ntValue.SG || nt == ntValue.SF || nt == ntValue.SC) { panel.Controls.Add(note_drawingInMadi(now_music.sm[now_music.smind]._x_madi, _y + y, basic[basicIndex, 2])); } else { panel.Controls.Add(note_drawingInMadi(now_music.sm[now_music.smind]._x_madi, _y + y, basic[basicIndex, 0])); } } now_music.sm[now_music.smind]._x_madi += 60; //옆으로 계속 이동하면서 음표그리기 now_music.sm[now_music.smind].count_madi++; }
//########################################### //###### 배씨 1.20 불러오기 함수 빼놓음 #####??왜빼놓음? void load() { Console.WriteLine("update"); /* * 2016-01-19 김민영 * info 파일을 읽어온다. 추후 수정 필요....최대한 건들지 마시오~ */ if (MessageBox.Show("지금까지 작성한 악보가 사라집니다.\n 악보를 저장하시겠습니까?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { file.save(this.tb_name1.Text, POctl.now_music, p_music); } newfile(); file.OpenFile(); for (int i = 0; i < 5; i++) { tb_name[i].Text = file.title; } //토큰 분리 for (int idx = 0; idx < file.page; idx++) { char[] delimiterChars = { ',' }; string[] words = file.music[idx].Split(delimiterChars); for (int i = 0; i < words.Length - 1; i += 3) { ntValue nt = (ntValue)Enum.Parse(typeof(ntValue), words[i]); int octave = int.Parse(words[i + 1]); //옥타브 int length = int.Parse(words[i + 2]); //길이 POctl.ocIndex = octave; POctl.basicIndex = 4 - (int)Math.Log(length, 2.0); Console.WriteLine("basicIndex = " + POctl.basicIndex); POctl.note_location(nt, p_music[POctl.now_music.smind]); } if (idx != file.page - 1) { pluspage(); //페이지 추가 } } }
private void readFile(string musicName) { File file = new File(); file.readfile(musicName + ".txt"); tb_trName.Text = file.title; allindex = 0; char[] delimiterChars = { ',' }; string[] words = file.music[0].Split(delimiterChars); for (int i = 0; i < words.Length - 1; i += 3) { ntValue nt = (ntValue)Enum.Parse(typeof(ntValue), words[i]); int octave = int.Parse(words[i + 1]); int length = int.Parse(words[i + 2]); //length = 4 - (int)Math.Log(length, 2.0); trNote tmp; tmp.note = nt; tmp.octave = octave; tmp.length = length; trScore.Add(tmp); allindex++; } }
public ntValue nt; //도레미 //public int _sound = 0 ; //음표 생성자수정 20170118 김민영 //위치가 아닌 계이름과 옥타브를 저장하도록함 -> 추후에 박자저장 필요 public note(ntValue nt, int ocIndex, int length) { this.nt = nt; //계이름 this.ocIndex = ocIndex; //옥타브 this.length = length; //박자 }
public static ntValue keyTontValue(this keyntValue note) { ntValue notevalue = (ntValue)Enum.ToObject(typeof(ntValue), (int)note); //계이름 판정 return(notevalue); }
public static int getLocationMadi(this ntValue note) { return(noteTolocationMadi[(int)note]); }
static int[] noteTolocationMadi = { 55, 42, 29, 16, 3, -13, -27, -41, 55, 42, 16, 3, -13 };//샵부분 수정필요 public static int getLocation(this ntValue note) { return(noteToLocation[(int)note]); }
//음표 추가 /* * 2016.01.17 김민영 * note클래스 수정 필요정보만 담도록 변경 * 더 필요한 정보가 있다면 수정 부탁 */ public void add_note(ntValue nt, int ocIndex, int length) { note_arr[noteind++] = new note(nt, ocIndex, length); }
public void note_location(ntValue nt, Panel panel) { //기미녕이 한 부분 2016-01-17 int y = nt.getLocation(); //위치 매칭 int _y = 0; /* * 2016.01.26 정유진 * 템포 이미지 안씀 * 전부basic[,]으로 변경함. */ // System.Drawing.Image[] tempo = this.tempo; _y = octave[ocIndex] + now_music.sm[now_music.smind].crrLine; int madi_y = octave[1] + now_music.sm[now_music.smind].crrLine; if (time_sum == 4) { panel.Controls.Add(madi_line_drawing(now_music.sm[now_music.smind]._x + 10, 6 + madi_y)); // time_sum 한 마디안에 들어갈 수 있는 박자가 모두 채워지면 마디선을 그린다. time_sum = 0; now_music.sm[now_music.smind]._x += 18; //옆으로 계속 이동하면서 음표그리기 } //20160126 정유진 샾 추가 //높은 시,도 거꾸로 된 음표 그리기 if ((ocIndex == 1 && (y == -3 || y == -6)) || ocIndex == 0) //옥타브==1 && 시or도 { if (nt == ntValue.SA || nt == ntValue.SD || nt == ntValue.SG || nt == ntValue.SF || nt == ntValue.SC) { panel.Controls.Add(note_drawing(now_music.sm[now_music.smind]._x, _y + y + 15, basic[basicIndex, 3])); } else { panel.Controls.Add(note_drawing(now_music.sm[now_music.smind]._x, _y + y + 15, basic[basicIndex, 1])); } //y축 위치 + 15(거꾸로 이므로 위치 맞춤) } else { if (nt == ntValue.SA || nt == ntValue.SD || nt == ntValue.SG || nt == ntValue.SF || nt == ntValue.SC) { panel.Controls.Add(note_drawing(now_music.sm[now_music.smind]._x, _y + y, basic[basicIndex, 2])); } else { panel.Controls.Add(note_drawing(now_music.sm[now_music.smind]._x, _y + y, basic[basicIndex, 0])); } } //tempSound 추가 -> 20160117 김민영 수정 /* tempSound가 꼭 필요한가 흘러가는 데이터 발생될듯.. * 어처피 사운드는 계이름만 알면 나오게 할 수있으니까 생략함 */ //basicIndex 0~3 => 16,8,4,2 int tempBasicIndex = 0; if (basicIndex == 0) { tempBasicIndex = 16; } else if (basicIndex == 1) { tempBasicIndex = 8; } else if (basicIndex == 2) { tempBasicIndex = 4; } else { tempBasicIndex = 2; } now_music.sm[now_music.smind].add_note(nt, ocIndex, tempBasicIndex); //아직 박자가 없으므로 임시로 16분음표라 저장 now_music.sm[now_music.smind]._x += 21; //옆으로 계속 이동하면서 음표그리기 now_music.sm[now_music.smind].count++; time_sum += time; // 맨 첫줄은 4/4박자 기호때문에 그려지는 음표 개수가 적다. if (now_music.sm[now_music.smind].count >= 20 && now_music.sm[now_music.smind].crrLine == 0) { //그 줄 마지막부분에 마디선을 그려준다. panel.Controls.Add(madi_line_drawing(569, 6 + madi_y)); time_sum = 0; //다음 줄로 이동 now_music.sm[now_music.smind].count = 0; now_music.sm[now_music.smind].crrLine = now_music.sm[now_music.smind].crrLine + 55; now_music.sm[now_music.smind]._x = base_x; } else if (now_music.sm[now_music.smind].count >= 21) { //그 줄 마지막부분에 마디선을 그려준다. panel.Controls.Add(madi_line_drawing(569, 6 + madi_y)); time_sum = 0; //다음 줄로 이동 now_music.sm[now_music.smind].count = 0; now_music.sm[now_music.smind].crrLine = now_music.sm[now_music.smind].crrLine + 55; now_music.sm[now_music.smind]._x = base_x; } }