private void Guitar_StringMouseDown(object sender, GuitarFret.GuitarEventArgs e) { GuitarFret fret = (GuitarFret)sender; noteValue = Note.ConvertCodeToNotation(fret.GetCode(e.StringNumber)); timer.Reset(); MidiPlayer.Play(new ProgramChange(0, 1, GeneralMidiInstruments.CleanElectricGuitar)); MidiPlayer.Play(new NoteOn(0, 1, noteValue, 127)); timer.Start(); }
private void Guitar_StringMouseUp(object sender, GuitarFret.GuitarEventArgs e) { GuitarFret fret = (GuitarFret)sender; try { MidiPlayer.Play(new NoteOff(0, 1, noteValue, 127)); timer.Stop(); } catch { throw; } }
//private void cmbTunings_SelectedIndexChanged(object sender, EventArgs e) //{ // TuneStrings(cmbTunings.SelectedIndex); // btnClear.Focus(); // //notes.Clear(); //} private void TuneFrets(int[] stringsNotes) { int stringNumber; int fretNumber; //GuitarFret fret = (GuitarFret)this.Controls["guitarFret" + fretNumber.ToString()]; for (fretNumber = 0; fretNumber <= 22; fretNumber++) { if (fretNumber == 0) { for (stringNumber = 0; stringNumber <= 5; stringNumber++) { //open strings GuitarFret fret = (GuitarFret)pnlGuitar.Controls["guitarFret0"]; fret.SetCode(stringNumber, stringsNotes[stringNumber]); stringsNotes[stringNumber]++; if ((stringsNotes[stringNumber] % 100) == 13) //get 1st+2nd digits (note) { stringsNotes[stringNumber] = stringsNotes[stringNumber] + 100 - 12; //up octave/pitch , reset note } } } else { GuitarFret fret = (GuitarFret)pnlGuitar.Controls["guitarFret" + fretNumber.ToString()]; for (stringNumber = 0; stringNumber <= 5; stringNumber++) { fret.SetCode(stringNumber, stringsNotes[stringNumber]); stringsNotes[stringNumber]++; if ((stringsNotes[stringNumber] % 100) == 13) //get 1st+2nd digits (note) { stringsNotes[stringNumber] = stringsNotes[stringNumber] + 100 - 12; //up octave/pitch , reset note } } } } }
private void FretClicked(object sender, GuitarFret.GuitarEventArgs e) { if (!e.AltClicked) ////if alt was held dont register note { GuitarFret fret = (GuitarFret)sender; int noteCode; Color noteColor; noteCode = fret.GetCode(e.StringNumber); //--------------------------------------------------------------------------------------------------------- //--------------------Fret Not Clicked Yet----------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- if (fret.GetColor(e.StringNumber) == Color.Gainsboro) { frmMaster.GetAllNotes().Add(noteCode, e.StringNumber, timer.ElapsedMilliseconds); noteColor = frmMaster.GetAllNotes().GetColor(noteCode); fret.SetColor(noteColor, e.StringNumber); frmMaster.AddNote(this, noteCode); //if shift key was held then dye all other same frets if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(noteColor, stringNumber); } } } } } } //------------------------------------------------------------------------------------------------------------------------- //-------------------------Fret Already Clicked---------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------- else { //SHIFT+CLICK = Remove frets with same code if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if ((((GuitarFret)f).GetCode(stringNumber) == noteCode) && (stringNumber != e.StringNumber)) { ((GuitarFret)f).SetColor(Color.Transparent, stringNumber); } } } } } //CTRL+CLICK = remove clicked fret (if there are frets with same code) else if (e.CtrlClicked) { bool otherFrets; otherFrets = false; foreach (Control f in pnlGuitar.Controls) { //other frets = no need to continue searching, exit loop if (otherFrets) { break; } //check if there are other frets with same code that are clicked if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if ((((GuitarFret)f).GetCode(stringNumber) == noteCode) && (stringNumber != e.StringNumber) && (((GuitarFret)f).GetColor(stringNumber) != Color.Transparent)) { otherFrets = true; } } } } if (otherFrets) { fret.SetColor(Color.Gainsboro, e.StringNumber); } } //CLICK = Remove all frets with same code from array and uncolor them //OR if checkbox is true override the note else { if (frmMaster.chkOverrideNotes.Checked) { frmMaster.GetAllNotes().AddAnother(noteCode, timer.ElapsedMilliseconds); noteColor = frmMaster.GetAllNotes().GetColor(noteCode); //if shift key was held then dye all other same frets if (e.ShiftClicked) { foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(noteColor, stringNumber); } } } } } } else { frmMaster.GetAllNotes().Remove(noteCode); frmMaster.RemoveNote(this, noteCode); foreach (Control f in pnlGuitar.Controls) { if (f is GuitarFret) { int stringNumber; for (stringNumber = 1; stringNumber <= 6; stringNumber++) { if (((GuitarFret)f).GetCode(stringNumber) == noteCode) { ((GuitarFret)f).SetColor(Color.Transparent, stringNumber); } } } } fret.SetColor(Color.Gainsboro, e.StringNumber); } } } } }